Browse Source

btrfs: implement decoding of BTRFS_IOC_FORGET_DEV argument

... introduced by Linux kernel commit v5.1-rc1~47^2~47.

* btrfs.c (btrfs_ioctl) [BTRFS_IOC_FORGET_DEV]: Handle
BTRFS_IOC_FORGET_DEV.
* tests/btrfs.c (btrfs_test_device_ioctls) [BTRFS_IOC_FORGET_DEV]:
Check it.
Dmitry V. Levin 5 months ago
parent
commit
a9328c6dc8
2 changed files with 14 additions and 0 deletions
  1. 3
    0
      btrfs.c
  2. 11
    0
      tests/btrfs.c

+ 3
- 0
btrfs.c View File

@@ -1161,6 +1161,9 @@ MPERS_PRINTER_DECL(int, btrfs_ioctl,
1161 1161
 	case BTRFS_IOC_SNAP_CREATE:
1162 1162
 	case BTRFS_IOC_RESIZE:
1163 1163
 	case BTRFS_IOC_SCAN_DEV:
1164
+# ifdef BTRFS_IOC_FORGET_DEV
1165
+	case BTRFS_IOC_FORGET_DEV:
1166
+# endif
1164 1167
 	case BTRFS_IOC_ADD_DEV:
1165 1168
 	case BTRFS_IOC_RM_DEV:
1166 1169
 	case BTRFS_IOC_SUBVOL_CREATE:

+ 11
- 0
tests/btrfs.c View File

@@ -752,6 +752,17 @@ btrfs_test_device_ioctls(void)
752 752
 	printf("ioctl(-1, %s, {fd=%d, name=\"%s\"}) = -1 EBADF (%m)\n",
753 753
 	       ioc(BTRFS_IOC_SCAN_DEV), (int) args.fd, args.name);
754 754
 
755
+# ifdef BTRFS_IOC_FORGET_DEV
756
+	ioctl(-1, BTRFS_IOC_FORGET_DEV, NULL);
757
+	printf("ioctl(-1, %s, NULL) = -1 EBADF (%m)\n",
758
+	       ioc(BTRFS_IOC_FORGET_DEV));
759
+
760
+	strcpy(args.name, devname);
761
+	ioctl(-1, BTRFS_IOC_FORGET_DEV, &args);
762
+	printf("ioctl(-1, %s, {fd=%d, name=\"%s\"}) = -1 EBADF (%m)\n",
763
+	       ioc(BTRFS_IOC_FORGET_DEV), (int) args.fd, args.name);
764
+# endif
765
+
755 766
 	ioctl(-1, BTRFS_IOC_ADD_DEV, NULL);
756 767
 	printf("ioctl(-1, %s, NULL) = -1 EBADF (%m)\n", ioc(BTRFS_IOC_ADD_DEV));
757 768
 

Loading…
Cancel
Save