X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Fudev%2Fudev-builtin-btrfs.c;h=74b220928ecd7dba17df0426f238ea3ec8bbd803;hb=65eb4378c3e1de25383d8cd606909e64c71edc80;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..74b220928 100644 --- a/src/udev/udev-builtin-btrfs.c +++ b/src/udev/udev-builtin-btrfs.c @@ -25,32 +25,27 @@ #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;