History

btrfs: Add unprivileged version of ino_lookup ioctl

Add unprivileged version of ino_lookup ioctl BTRFS_IOC_INO_LOOKUP_USER to allow normal users to call "btrfs subvolume list/show" etc. in combination with BTRFS_IOC_GET_SUBVOL_INFO/BTRFS_IOC_GET_SUBVOL_ROOTREF. This can be used like BTRFS_IOC_INO_LOOKUP but the argument is different. This is because it always searches the fs/file tree correspoinding to the fd with which this ioctl is called and also returns the name of bottom subvolume. The main differences from original ino_lookup ioctl are: 1. Read + Exec permission will be checked using inode_permission() during path construction. -EACCES will be returned in case of failure. 2. Path construction will be stopped at the inode number which corresponds to the fd with which this ioctl is called. If constructed path does not exist under fd's inode, -EACCES will be returned. 3. The name of bottom subvolume is also searched and filled. Note that the maximum length of path is shorter 256 (BTRFS_VOL_NAME_MAX+1) bytes than ino_lookup ioctl because of space of subvolume's name.

Tomohiro Misono committed 8 years ago

Commit 23d0b791 parent 42e4b522 files · +221 −0Browse files

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

Unified · Split

include/uapi/linux/btrfs.h+17−0
@@ -422,6 +422,21 @@ struct btrfs_ioctl_ino_lookup_args { · 421 unmodified lines
422 char name[BTRFS_INO_LOOKUP_PATH_MAX];422 char name[BTRFS_INO_LOOKUP_PATH_MAX];
423};423};
424 424
425#define BTRFS_INO_LOOKUP_USER_PATH_MAX (4080 - BTRFS_VOL_NAME_MAX - 1)
426struct btrfs_ioctl_ino_lookup_user_args {
427 /* in, inode number containing the subvolume of 'subvolid' */
428 __u64 dirid;
429 /* in */
430 __u64 treeid;
431 /* out, name of the subvolume of 'treeid' */
432 char name[BTRFS_VOL_NAME_MAX + 1];
433 /*
434 * out, constructed path from the directory with which the ioctl is
435 * called to dirid
436 */
437 char path[BTRFS_INO_LOOKUP_USER_PATH_MAX];
438};
439
425/* Search criteria for the btrfs SEARCH ioctl family. */440/* Search criteria for the btrfs SEARCH ioctl family. */
426struct btrfs_ioctl_search_key {441struct btrfs_ioctl_search_key {
427 /*442 /*
@@ -923,5 +938,7 @@ enum btrfs_err_code { · 495 unmodified lines
923 struct btrfs_ioctl_get_subvol_info_args)938 struct btrfs_ioctl_get_subvol_info_args)
924#define BTRFS_IOC_GET_SUBVOL_ROOTREF _IOWR(BTRFS_IOCTL_MAGIC, 61, \939#define BTRFS_IOC_GET_SUBVOL_ROOTREF _IOWR(BTRFS_IOCTL_MAGIC, 61, \
925 struct btrfs_ioctl_get_subvol_rootref_args)940 struct btrfs_ioctl_get_subvol_rootref_args)
941#define BTRFS_IOC_INO_LOOKUP_USER _IOWR(BTRFS_IOCTL_MAGIC, 62, \
942 struct btrfs_ioctl_ino_lookup_user_args)
926 943
927#endif /* _UAPI_LINUX_BTRFS_H */944#endif /* _UAPI_LINUX_BTRFS_H */

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t