root/include/uapi/linux/fsmap.h

/* [<][>][^][v][top][bottom][index][help] */

INCLUDED FROM


DEFINITIONS

This source file includes following definitions.
  1. fsmap_sizeof
  2. fsmap_advance

   1 /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
   2 /*
   3  * FS_IOC_GETFSMAP ioctl infrastructure.
   4  *
   5  * Copyright (C) 2017 Oracle.  All Rights Reserved.
   6  *
   7  * Author: Darrick J. Wong <darrick.wong@oracle.com>
   8  */
   9 #ifndef _LINUX_FSMAP_H
  10 #define _LINUX_FSMAP_H
  11 
  12 #include <linux/types.h>
  13 
  14 /*
  15  *      Structure for FS_IOC_GETFSMAP.
  16  *
  17  *      The memory layout for this call are the scalar values defined in
  18  *      struct fsmap_head, followed by two struct fsmap that describe
  19  *      the lower and upper bound of mappings to return, followed by an
  20  *      array of struct fsmap mappings.
  21  *
  22  *      fmh_iflags control the output of the call, whereas fmh_oflags report
  23  *      on the overall record output.  fmh_count should be set to the
  24  *      length of the fmh_recs array, and fmh_entries will be set to the
  25  *      number of entries filled out during each call.  If fmh_count is
  26  *      zero, the number of reverse mappings will be returned in
  27  *      fmh_entries, though no mappings will be returned.  fmh_reserved
  28  *      must be set to zero.
  29  *
  30  *      The two elements in the fmh_keys array are used to constrain the
  31  *      output.  The first element in the array should represent the
  32  *      lowest disk mapping ("low key") that the user wants to learn
  33  *      about.  If this value is all zeroes, the filesystem will return
  34  *      the first entry it knows about.  For a subsequent call, the
  35  *      contents of fsmap_head.fmh_recs[fsmap_head.fmh_count - 1] should be
  36  *      copied into fmh_keys[0] to have the kernel start where it left off.
  37  *
  38  *      The second element in the fmh_keys array should represent the
  39  *      highest disk mapping ("high key") that the user wants to learn
  40  *      about.  If this value is all ones, the filesystem will not stop
  41  *      until it runs out of mapping to return or runs out of space in
  42  *      fmh_recs.
  43  *
  44  *      fmr_device can be either a 32-bit cookie representing a device, or
  45  *      a 32-bit dev_t if the FMH_OF_DEV_T flag is set.  fmr_physical,
  46  *      fmr_offset, and fmr_length are expressed in units of bytes.
  47  *      fmr_owner is either an inode number, or a special value if
  48  *      FMR_OF_SPECIAL_OWNER is set in fmr_flags.
  49  */
  50 struct fsmap {
  51         __u32           fmr_device;     /* device id */
  52         __u32           fmr_flags;      /* mapping flags */
  53         __u64           fmr_physical;   /* device offset of segment */
  54         __u64           fmr_owner;      /* owner id */
  55         __u64           fmr_offset;     /* file offset of segment */
  56         __u64           fmr_length;     /* length of segment */
  57         __u64           fmr_reserved[3];        /* must be zero */
  58 };
  59 
  60 struct fsmap_head {
  61         __u32           fmh_iflags;     /* control flags */
  62         __u32           fmh_oflags;     /* output flags */
  63         __u32           fmh_count;      /* # of entries in array incl. input */
  64         __u32           fmh_entries;    /* # of entries filled in (output). */
  65         __u64           fmh_reserved[6];        /* must be zero */
  66 
  67         struct fsmap    fmh_keys[2];    /* low and high keys for the mapping search */
  68         struct fsmap    fmh_recs[];     /* returned records */
  69 };
  70 
  71 /* Size of an fsmap_head with room for nr records. */
  72 static inline size_t
  73 fsmap_sizeof(
  74         unsigned int    nr)
  75 {
  76         return sizeof(struct fsmap_head) + nr * sizeof(struct fsmap);
  77 }
  78 
  79 /* Start the next fsmap query at the end of the current query results. */
  80 static inline void
  81 fsmap_advance(
  82         struct fsmap_head       *head)
  83 {
  84         head->fmh_keys[0] = head->fmh_recs[head->fmh_entries - 1];
  85 }
  86 
  87 /*      fmh_iflags values - set by FS_IOC_GETFSMAP caller in the header. */
  88 /* no flags defined yet */
  89 #define FMH_IF_VALID            0
  90 
  91 /*      fmh_oflags values - returned in the header segment only. */
  92 #define FMH_OF_DEV_T            0x1     /* fmr_device values will be dev_t */
  93 
  94 /*      fmr_flags values - returned for each non-header segment */
  95 #define FMR_OF_PREALLOC         0x1     /* segment = unwritten pre-allocation */
  96 #define FMR_OF_ATTR_FORK        0x2     /* segment = attribute fork */
  97 #define FMR_OF_EXTENT_MAP       0x4     /* segment = extent map */
  98 #define FMR_OF_SHARED           0x8     /* segment = shared with another file */
  99 #define FMR_OF_SPECIAL_OWNER    0x10    /* owner is a special value */
 100 #define FMR_OF_LAST             0x20    /* segment is the last in the dataset */
 101 
 102 /* Each FS gets to define its own special owner codes. */
 103 #define FMR_OWNER(type, code)   (((__u64)type << 32) | \
 104                                  ((__u64)code & 0xFFFFFFFFULL))
 105 #define FMR_OWNER_TYPE(owner)   ((__u32)((__u64)owner >> 32))
 106 #define FMR_OWNER_CODE(owner)   ((__u32)(((__u64)owner & 0xFFFFFFFFULL)))
 107 #define FMR_OWN_FREE            FMR_OWNER(0, 1) /* free space */
 108 #define FMR_OWN_UNKNOWN         FMR_OWNER(0, 2) /* unknown owner */
 109 #define FMR_OWN_METADATA        FMR_OWNER(0, 3) /* metadata */
 110 
 111 #define FS_IOC_GETFSMAP         _IOWR('X', 59, struct fsmap_head)
 112 
 113 #endif /* _LINUX_FSMAP_H */

/* [<][>][^][v][top][bottom][index][help] */