History

btrfs: Add unprivileged ioctl which returns subvolume information

Add new unprivileged ioctl BTRFS_IOC_GET_SUBVOL_INFO which returns the information of subvolume containing this inode. (i.e. returns the information in ROOT_ITEM and ROOT_BACKREF.)

Tomohiro Misono committed 8 years ago

Commit b64ec071 parent ad7e1a72 files · +183 −0Browse files

Showing the changes to include/uapi/linux (1 of 2 files). Show all

Unified · Split

include/uapi/linux/btrfs.h+62−0
@@ -725,6 +725,66 @@ struct btrfs_ioctl_send_args { · 724 unmodified lines
725725 __u64 reserved[4]; /* in */
726726 };
727727
728+/*
729+ * Information about a fs tree root.
730+ *
731+ * All items are filled by the ioctl
732+ */
733+struct btrfs_ioctl_get_subvol_info_args {
734+ /* Id of this subvolume */
735+ __u64 treeid;
736+
737+ /* Name of this subvolume, used to get the real name at mount point */
738+ char name[BTRFS_VOL_NAME_MAX + 1];
739+
740+ /*
741+ * Id of the subvolume which contains this subvolume.
742+ * Zero for top-level subvolume or a deleted subvolume.
743+ */
744+ __u64 parent_id;
745+
746+ /*
747+ * Inode number of the directory which contains this subvolume.
748+ * Zero for top-level subvolume or a deleted subvolume
749+ */
750+ __u64 dirid;
751+
752+ /* Latest transaction id of this subvolume */
753+ __u64 generation;
754+
755+ /* Flags of this subvolume */
756+ __u64 flags;
757+
758+ /* UUID of this subvolume */
759+ __u8 uuid[BTRFS_UUID_SIZE];
760+
761+ /*
762+ * UUID of the subvolume of which this subvolume is a snapshot.
763+ * All zero for a non-snapshot subvolume.
764+ */
765+ __u8 parent_uuid[BTRFS_UUID_SIZE];
766+
767+ /*
768+ * UUID of the subvolume from which this subvolume was received.
769+ * All zero for non-received subvolume.
770+ */
771+ __u8 received_uuid[BTRFS_UUID_SIZE];
772+
773+ /* Transaction id indicating when change/create/send/receive happened */
774+ __u64 ctransid;
775+ __u64 otransid;
776+ __u64 stransid;
777+ __u64 rtransid;
778+ /* Time corresponding to c/o/s/rtransid */
779+ struct btrfs_ioctl_timespec ctime;
780+ struct btrfs_ioctl_timespec otime;
781+ struct btrfs_ioctl_timespec stime;
782+ struct btrfs_ioctl_timespec rtime;
783+
784+ /* Must be zero */
785+ __u64 reserved[8];
786+};
787+
728788 /* Error codes as returned by the kernel */
729789 enum btrfs_err_code {
730790 BTRFS_ERROR_DEV_RAID1_MIN_NOT_MET = 1,
@@ -843,5 +903,7 @@ enum btrfs_err_code { · 112 unmodified lines
843903 struct btrfs_ioctl_vol_args_v2)
844904 #define BTRFS_IOC_LOGICAL_INO_V2 _IOWR(BTRFS_IOCTL_MAGIC, 59, \
845905 struct btrfs_ioctl_logical_ino_args)
906+#define BTRFS_IOC_GET_SUBVOL_INFO _IOR(BTRFS_IOCTL_MAGIC, 60, \
907+ struct btrfs_ioctl_get_subvol_info_args)
846908
847909 #endif /* _UAPI_LINUX_BTRFS_H */