X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=ioctl.h;h=709e996f401c32fc625106fc15f105ba1fe7f835;hb=9708f0d54e0381017114c0a4ca1f48e7aa8a8bbc;hp=cab9ec2d5501de7a38454795676acf914413ae7a;hpb=2490de5da527969a9178418155120bf50f2a8421;p=platform%2Fupstream%2Fbtrfs-progs.git diff --git a/ioctl.h b/ioctl.h index cab9ec2..709e996 100644 --- a/ioctl.h +++ b/ioctl.h @@ -25,11 +25,17 @@ extern "C" { #include #include +#include #ifndef __user #define __user #endif +/* We don't want to include entire kerncompat.h */ +#ifndef BUILD_ASSERT +#define BUILD_ASSERT(x) +#endif + #define BTRFS_IOCTL_MAGIC 0x94 #define BTRFS_VOL_NAME_MAX 255 @@ -39,6 +45,7 @@ struct btrfs_ioctl_vol_args { __s64 fd; char name[BTRFS_PATH_NAME_MAX + 1]; }; +BUILD_ASSERT(sizeof(struct btrfs_ioctl_vol_args) == 4096); #define BTRFS_DEVICE_PATH_NAME_MAX 1024 @@ -65,6 +72,7 @@ struct btrfs_qgroup_limit { __u64 rsv_referenced; __u64 rsv_exclusive; }; +BUILD_ASSERT(sizeof(struct btrfs_qgroup_limit) == 40); struct btrfs_qgroup_inherit { __u64 flags; @@ -74,11 +82,13 @@ struct btrfs_qgroup_inherit { struct btrfs_qgroup_limit lim; __u64 qgroups[0]; }; +BUILD_ASSERT(sizeof(struct btrfs_qgroup_inherit) == 72); struct btrfs_ioctl_qgroup_limit_args { __u64 qgroupid; struct btrfs_qgroup_limit lim; }; +BUILD_ASSERT(sizeof(struct btrfs_ioctl_qgroup_limit_args) == 48); #define BTRFS_SUBVOL_NAME_MAX 4039 struct btrfs_ioctl_vol_args_v2 { @@ -94,9 +104,10 @@ struct btrfs_ioctl_vol_args_v2 { }; union { char name[BTRFS_SUBVOL_NAME_MAX + 1]; - u64 devid; + __u64 devid; }; }; +BUILD_ASSERT(sizeof(struct btrfs_ioctl_vol_args_v2) == 4096); /* * structure to report errors and progress to userspace, either as a @@ -109,7 +120,7 @@ struct btrfs_scrub_progress { __u64 tree_bytes_scrubbed; /* # of tree bytes scrubbed */ __u64 read_errors; /* # of read errors encountered (EIO) */ __u64 csum_errors; /* # of failed csum checks */ - __u64 verify_errors; /* # of occurences, where the metadata + __u64 verify_errors; /* # of occurrences, where the metadata * of a tree block did not match the * expected values, like generation or * logical */ @@ -129,7 +140,7 @@ struct btrfs_scrub_progress { __u64 last_physical; /* last physical address scrubbed. In * case a scrub was aborted, this can * be used to restart the scrub */ - __u64 unverified_errors; /* # of occurences where a read for a + __u64 unverified_errors; /* # of occurrences where a read for a * full (64k) bio failed, but the re- * check succeeded for each 4k piece. * Intermittent error. */ @@ -145,6 +156,7 @@ struct btrfs_ioctl_scrub_args { /* pad to 1k */ __u64 unused[(1024-32-sizeof(struct btrfs_scrub_progress))/8]; }; +BUILD_ASSERT(sizeof(struct btrfs_ioctl_scrub_args) == 1024); #define BTRFS_IOCTL_DEV_REPLACE_CONT_READING_FROM_SRCDEV_MODE_ALWAYS 0 #define BTRFS_IOCTL_DEV_REPLACE_CONT_READING_FROM_SRCDEV_MODE_AVOID 1 @@ -155,6 +167,7 @@ struct btrfs_ioctl_dev_replace_start_params { __u8 srcdev_name[BTRFS_DEVICE_PATH_NAME_MAX + 1]; /* in */ __u8 tgtdev_name[BTRFS_DEVICE_PATH_NAME_MAX + 1]; /* in */ }; +BUILD_ASSERT(sizeof(struct btrfs_ioctl_dev_replace_start_params) == 2072); #define BTRFS_IOCTL_DEV_REPLACE_STATE_NEVER_STARTED 0 #define BTRFS_IOCTL_DEV_REPLACE_STATE_STARTED 1 @@ -169,6 +182,7 @@ struct btrfs_ioctl_dev_replace_status_params { __u64 num_write_errors; /* out */ __u64 num_uncorrectable_read_errors; /* out */ }; +BUILD_ASSERT(sizeof(struct btrfs_ioctl_dev_replace_status_params) == 48); #define BTRFS_IOCTL_DEV_REPLACE_CMD_START 0 #define BTRFS_IOCTL_DEV_REPLACE_CMD_STATUS 1 @@ -189,6 +203,7 @@ struct btrfs_ioctl_dev_replace_args { __u64 spare[64]; }; +BUILD_ASSERT(sizeof(struct btrfs_ioctl_dev_replace_args) == 2600); struct btrfs_ioctl_dev_info_args { __u64 devid; /* in/out */ @@ -198,6 +213,7 @@ struct btrfs_ioctl_dev_info_args { __u64 unused[379]; /* pad to 4k */ __u8 path[BTRFS_DEVICE_PATH_NAME_MAX]; /* out */ }; +BUILD_ASSERT(sizeof(struct btrfs_ioctl_dev_info_args) == 4096); struct btrfs_ioctl_fs_info_args { __u64 max_id; /* out */ @@ -209,12 +225,14 @@ struct btrfs_ioctl_fs_info_args { __u32 reserved32; __u64 reserved[122]; /* pad to 1k */ }; +BUILD_ASSERT(sizeof(struct btrfs_ioctl_fs_info_args) == 1024); struct btrfs_ioctl_feature_flags { __u64 compat_flags; __u64 compat_ro_flags; __u64 incompat_flags; }; +BUILD_ASSERT(sizeof(struct btrfs_ioctl_feature_flags) == 24); /* balance control ioctl modes */ #define BTRFS_BALANCE_CTL_PAUSE 1 @@ -271,7 +289,7 @@ struct btrfs_balance_args { /* report balance progress to userspace */ struct btrfs_balance_progress { __u64 expected; /* estimated # of chunks that will be - * relocated to fulfill the request */ + * relocated to fulfil the request */ __u64 considered; /* # of chunks we have considered so far */ __u64 completed; /* # of chunks relocated so far */ }; @@ -292,6 +310,7 @@ struct btrfs_ioctl_balance_args { __u64 unused[72]; /* pad to 1k */ }; +BUILD_ASSERT(sizeof(struct btrfs_ioctl_balance_args) == 1024); #define BTRFS_INO_LOOKUP_PATH_MAX 4080 struct btrfs_ioctl_ino_lookup_args { @@ -299,6 +318,7 @@ struct btrfs_ioctl_ino_lookup_args { __u64 objectid; char name[BTRFS_INO_LOOKUP_PATH_MAX]; }; +BUILD_ASSERT(sizeof(struct btrfs_ioctl_ino_lookup_args) == 4096); struct btrfs_ioctl_search_key { /* which root are we searching. 0 is the tree of tree roots */ @@ -366,6 +386,7 @@ struct btrfs_ioctl_search_args_v2 { * to store item */ __u64 buf[0]; /* out - found items */ }; +BUILD_ASSERT(sizeof(struct btrfs_ioctl_search_args_v2) == 112); /* With a @src_length of zero, the range from @src_offset->EOF is cloned! */ struct btrfs_ioctl_clone_range_args { @@ -373,6 +394,7 @@ struct btrfs_ioctl_clone_range_args { __u64 src_offset, src_length; __u64 dest_offset; }; +BUILD_ASSERT(sizeof(struct btrfs_ioctl_clone_range_args) == 32); /* flags for the defrag range ioctl */ #define BTRFS_DEFRAG_RANGE_COMPRESS 1 @@ -402,6 +424,7 @@ struct btrfs_ioctl_same_args { __u32 reserved2; struct btrfs_ioctl_same_extent_info info[0]; }; +BUILD_ASSERT(sizeof(struct btrfs_ioctl_same_args) == 24); struct btrfs_ioctl_defrag_range_args { /* start of the defrag operation */ @@ -433,6 +456,7 @@ struct btrfs_ioctl_defrag_range_args { /* spare for later */ __u32 unused[4]; }; +BUILD_ASSERT(sizeof(struct btrfs_ioctl_defrag_range_args) == 48); struct btrfs_ioctl_space_info { __u64 flags; @@ -445,6 +469,7 @@ struct btrfs_ioctl_space_args { __u64 total_spaces; struct btrfs_ioctl_space_info spaces[0]; }; +BUILD_ASSERT(sizeof(struct btrfs_ioctl_space_args) == 16); struct btrfs_data_container { __u32 bytes_left; /* out -- bytes not needed to deliver output */ @@ -461,6 +486,7 @@ struct btrfs_ioctl_ino_path_args { /* struct btrfs_data_container *fspath; out */ __u64 fspath; /* out */ }; +BUILD_ASSERT(sizeof(struct btrfs_ioctl_ino_path_args) == 56); struct btrfs_ioctl_logical_ino_args { __u64 logical; /* in */ @@ -500,8 +526,9 @@ struct btrfs_ioctl_get_dev_stats { /* out values: */ __u64 values[BTRFS_DEV_STAT_VALUES_MAX]; - __u64 unused[128 - 2 - BTRFS_DEV_STAT_VALUES_MAX]; /* pad to 1k */ + __u64 unused[128 - 2 - BTRFS_DEV_STAT_VALUES_MAX]; /* pad to 1k + 8B */ }; +BUILD_ASSERT(sizeof(struct btrfs_ioctl_get_dev_stats) == 1032); /* BTRFS_IOC_SNAP_CREATE is no longer used by the btrfs command */ #define BTRFS_QUOTA_CTL_ENABLE 1 @@ -511,12 +538,14 @@ struct btrfs_ioctl_quota_ctl_args { __u64 cmd; __u64 status; }; +BUILD_ASSERT(sizeof(struct btrfs_ioctl_quota_ctl_args) == 16); struct btrfs_ioctl_quota_rescan_args { __u64 flags; __u64 progress; __u64 reserved[6]; }; +BUILD_ASSERT(sizeof(struct btrfs_ioctl_quota_rescan_args) == 64); struct btrfs_ioctl_qgroup_assign_args { __u64 assign; @@ -528,6 +557,8 @@ struct btrfs_ioctl_qgroup_create_args { __u64 create; __u64 qgroupid; }; +BUILD_ASSERT(sizeof(struct btrfs_ioctl_qgroup_create_args) == 16); + struct btrfs_ioctl_timespec { __u64 sec; __u32 nsec; @@ -542,6 +573,39 @@ struct btrfs_ioctl_received_subvol_args { __u64 flags; /* in */ __u64 reserved[16]; /* in */ }; +BUILD_ASSERT(sizeof(struct btrfs_ioctl_received_subvol_args) == 200); + +/* + * If we have a 32-bit userspace and 64-bit kernel, then the UAPI + * structures are incorrect, as the timespec structure from userspace + * is 4 bytes too small. We define these alternatives here for backward + * compatibility, the kernel understands both values. + */ + +/* + * Structure size is different on 32bit and 64bit, has some padding if the + * structure is embedded. Packing makes sure the size is same on both, but will + * be misaligned on 64bit. + * + * NOTE: do not use in your code, this is for testing only + */ +struct btrfs_ioctl_timespec_32 { + __u64 sec; + __u32 nsec; +} __attribute__ ((__packed__)); + +struct btrfs_ioctl_received_subvol_args_32 { + char uuid[BTRFS_UUID_SIZE]; /* in */ + __u64 stransid; /* in */ + __u64 rtransid; /* out */ + struct btrfs_ioctl_timespec_32 stime; /* in */ + struct btrfs_ioctl_timespec_32 rtime; /* out */ + __u64 flags; /* in */ + __u64 reserved[16]; /* in */ +} __attribute__ ((__packed__)); +BUILD_ASSERT(sizeof(struct btrfs_ioctl_received_subvol_args_32) == 192); + +#define BTRFS_IOC_SET_RECEIVED_SUBVOL_32_COMPAT_DEFINED 1 /* * Caller doesn't want file data in the send stream, even if the @@ -576,6 +640,37 @@ struct btrfs_ioctl_send_args { __u64 flags; /* in */ __u64 reserved[4]; /* in */ }; +/* + * Size of structure depends on pointer width, was not caught in the early + * days. Kernel handles pointer width differences transparently. + */ +BUILD_ASSERT(sizeof(__u64 *) == 8 + ? sizeof(struct btrfs_ioctl_send_args) == 72 + : (sizeof(void *) == 4 + ? sizeof(struct btrfs_ioctl_send_args) == 68 + : 0)); + +/* + * Different pointer width leads to structure size change. Kernel should accept + * both ioctl values (derived from the structures) for backward compatibility. + * Size of this structure is same on 32bit and 64bit though. + * + * NOTE: do not use in your code, this is for testing only + */ +struct btrfs_ioctl_send_args_64 { + __s64 send_fd; /* in */ + __u64 clone_sources_count; /* in */ + union { + __u64 __user *clone_sources; /* in */ + __u64 __clone_sources_alignment; + }; + __u64 parent_root; /* in */ + __u64 flags; /* in */ + __u64 reserved[4]; /* in */ +} __attribute__((packed)); +BUILD_ASSERT(sizeof(struct btrfs_ioctl_send_args_64) == 72); + +#define BTRFS_IOC_SEND_64_COMPAT_DEFINED 1 /* Error codes as returned by the kernel */ enum btrfs_err_code { @@ -685,9 +780,20 @@ static inline char *btrfs_err_str(enum btrfs_err_code err_code) #define BTRFS_IOC_INO_PATHS _IOWR(BTRFS_IOCTL_MAGIC, 35, \ struct btrfs_ioctl_ino_path_args) #define BTRFS_IOC_LOGICAL_INO _IOWR(BTRFS_IOCTL_MAGIC, 36, \ - struct btrfs_ioctl_ino_path_args) + struct btrfs_ioctl_logical_ino_args) #define BTRFS_IOC_SET_RECEIVED_SUBVOL _IOWR(BTRFS_IOCTL_MAGIC, 37, \ struct btrfs_ioctl_received_subvol_args) + +#ifdef BTRFS_IOC_SET_RECEIVED_SUBVOL_32_COMPAT_DEFINED +#define BTRFS_IOC_SET_RECEIVED_SUBVOL_32 _IOWR(BTRFS_IOCTL_MAGIC, 37, \ + struct btrfs_ioctl_received_subvol_args_32) +#endif + +#ifdef BTRFS_IOC_SEND_64_COMPAT_DEFINED +#define BTRFS_IOC_SEND_64 _IOW(BTRFS_IOCTL_MAGIC, 38, \ + struct btrfs_ioctl_send_args_64) +#endif + #define BTRFS_IOC_SEND _IOW(BTRFS_IOCTL_MAGIC, 38, struct btrfs_ioctl_send_args) #define BTRFS_IOC_DEVICES_READY _IOR(BTRFS_IOCTL_MAGIC, 39, \ struct btrfs_ioctl_vol_args)