X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Fudev%2Fudev-builtin-btrfs.c;h=3352821567e405723ab6287bd0dbf4decca48bb3;hb=e530ed5e1407e0571afc01552e41365ffb01befa;hp=f7bea69b26c1acd5c119c13acdf0460146d88441;hpb=d5a89d7dc17a5ba5cf4fc71f82963c5c94a31c3d;p=elogind.git
diff --git a/src/udev/udev-builtin-btrfs.c b/src/udev/udev-builtin-btrfs.c
index f7bea69b2..335282156 100644
--- a/src/udev/udev-builtin-btrfs.c
+++ b/src/udev/udev-builtin-btrfs.c
@@ -17,44 +17,35 @@
along with systemd; If not, see .
***/
-#include
#include
-#include
-#include
#include
-#include
#include
-#include "udev.h"
+#ifdef HAVE_LINUX_BTRFS_H
+#include
+#endif
-#define BTRFS_PATH_NAME_MAX 4087
-struct btrfs_ioctl_vol_args {
- int64_t fd;
- char name[BTRFS_PATH_NAME_MAX + 1];
-};
-#define BTRFS_IOCTL_MAGIC 0x94
-#define BTRFS_IOC_DEVICES_READY _IOR(BTRFS_IOCTL_MAGIC, 39, struct btrfs_ioctl_vol_args)
+#include "missing.h"
+#include "udev.h"
-static int builtin_btrfs(struct udev_device *dev, int argc, char *argv[], bool test)
-{
- struct btrfs_ioctl_vol_args args;
- int fd;
+static int builtin_btrfs(struct udev_device *dev, int argc, char *argv[], bool test) {
+ struct btrfs_ioctl_vol_args args = {};
+ _cleanup_close_ int fd = -1;
int err;
if (argc != 3 || !streq(argv[1], "ready"))
return EXIT_FAILURE;
- fd = open("/dev/btrfs-control", O_RDWR);
+ fd = open("/dev/btrfs-control", O_RDWR|O_CLOEXEC);
if (fd < 0)
return EXIT_FAILURE;
strscpy(args.name, sizeof(args.name), argv[2]);
err = ioctl(fd, BTRFS_IOC_DEVICES_READY, &args);
- close(fd);
if (err < 0)
return EXIT_FAILURE;
- udev_builtin_add_property(dev, test, "ID_BTRFS_READY", err == 0 ? "1" : "0");
+ udev_builtin_add_property(dev, test, "ID_BTRFS_READY", one_zero(err == 0));
return EXIT_SUCCESS;
}