]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
losetup: remove 32-bit ioctls
authorKarel Zak <kzak@redhat.com>
Tue, 20 Dec 2011 11:20:51 +0000 (12:20 +0100)
committerKarel Zak <kzak@redhat.com>
Tue, 20 Dec 2011 11:20:51 +0000 (12:20 +0100)
 ... kernel 2.4 ?! Who cares?

Signed-off-by: Karel Zak <kzak@redhat.com>
mount/lomount.c
mount/loop.h

index 278c61c380716826b8b3c226e4b5a97f04386dbd..32655cba3787f4a09caba9d701e1c20f735cb470 100644 (file)
 
 static int is_associated(int dev, struct stat *file, unsigned long long offset, int isoff);
 
-static int
-loop_info64_to_old(const struct loop_info64 *info64, struct loop_info *info)
-{
-        memset(info, 0, sizeof(*info));
-        info->lo_number = info64->lo_number;
-        info->lo_device = info64->lo_device;
-        info->lo_inode = info64->lo_inode;
-        info->lo_rdevice = info64->lo_rdevice;
-        info->lo_offset = info64->lo_offset;
-        info->lo_encrypt_type = info64->lo_encrypt_type;
-        info->lo_encrypt_key_size = info64->lo_encrypt_key_size;
-        info->lo_flags = info64->lo_flags;
-        info->lo_init[0] = info64->lo_init[0];
-        info->lo_init[1] = info64->lo_init[1];
-        if (info->lo_encrypt_type == LO_CRYPT_CRYPTOAPI)
-                memcpy(info->lo_name, info64->lo_crypt_name, LO_NAME_SIZE);
-        else
-                memcpy(info->lo_name, info64->lo_file_name, LO_NAME_SIZE);
-        memcpy(info->lo_encrypt_key, info64->lo_encrypt_key, LO_KEY_SIZE);
-
-        /* error in case values were truncated */
-        if (info->lo_device != info64->lo_device ||
-            info->lo_rdevice != info64->lo_rdevice ||
-            info->lo_inode != info64->lo_inode ||
-            info->lo_offset < 0 ||
-           (uint64_t) info->lo_offset != info64->lo_offset)
-                return -EOVERFLOW;
-
-        return 0;
-}
-
 #define LOOPMAJOR              7
 #define NLOOPS_DEFAULT         8       /* /dev/loop[0-7] */
 
@@ -114,7 +83,6 @@ char *loopdev_get_loopfile(const char *device)
        char *res = loopfile_from_sysfs(device);
 
        if (!res) {
-               struct loop_info lo;
                struct loop_info64 lo64;
                int fd;
 
@@ -126,10 +94,6 @@ char *loopdev_get_loopfile(const char *device)
                        lo64.lo_file_name[LO_NAME_SIZE-1] = 0;
                        res = xstrdup((char *) lo64.lo_file_name);
 
-               } else if (ioctl(fd, LOOP_GET_STATUS, &lo) == 0) {
-                       lo.lo_name[LO_NAME_SIZE-2] = '*';
-                       lo.lo_name[LO_NAME_SIZE-1] = 0;
-                       res = xstrdup((char *) lo.lo_name);
                }
                close(fd);
        }
@@ -148,10 +112,10 @@ is_loop_device (const char *device) {
 static int
 is_loop_used(int fd)
 {
-       struct loop_info li;
+       struct loop_info64 li;
 
        errno = 0;
-       if (ioctl (fd, LOOP_GET_STATUS, &li) < 0 && errno == ENXIO)
+       if (ioctl (fd, LOOP_GET_STATUS64, &li) < 0 && errno == ENXIO)
                return 0;
        return 1;
 }
@@ -159,16 +123,12 @@ is_loop_used(int fd)
 static int
 is_loopfd_autoclear(int fd)
 {
-       struct loop_info lo;
        struct loop_info64 lo64;
 
        if (ioctl(fd, LOOP_GET_STATUS64, &lo64) == 0) {
                if (lo64.lo_flags & LO_FLAGS_AUTOCLEAR)
                        return 1;
 
-       } else if (ioctl(fd, LOOP_GET_STATUS, &lo) == 0) {
-               if (lo.lo_flags & LO_FLAGS_AUTOCLEAR)
-                       return 1;
        }
        return 0;
 }
@@ -472,7 +432,6 @@ err:
 
 static int
 show_loop_fd(int fd, char *device) {
-       struct loop_info loopinfo;
        struct loop_info64 loopinfo64;
        int errsv;
 
@@ -518,22 +477,6 @@ show_loop_fd(int fd, char *device) {
                return 0;
        }
 
-       if (ioctl(fd, LOOP_GET_STATUS, &loopinfo) == 0) {
-               printf ("%s: [%04x]:%ld (%s)",
-                       device, (unsigned int)loopinfo.lo_device, loopinfo.lo_inode,
-                       loopinfo.lo_name);
-
-               if (loopinfo.lo_offset)
-                       printf(_(", offset %d"), loopinfo.lo_offset);
-
-               if (loopinfo.lo_encrypt_type)
-                       printf(_(", encryption type %d\n"),
-                              loopinfo.lo_encrypt_type);
-
-               printf("\n");
-               return 0;
-       }
-
        errsv = errno;
        fprintf(stderr, _("loop: can't get info on device %s: %s\n"),
                device, strerror (errsv));
@@ -618,7 +561,6 @@ static int
 is_associated(int dev, struct stat *file, unsigned long long offset, int isoff)
 {
        struct loop_info64 linfo64;
-       struct loop_info64 linfo;
        int ret = 0;
 
        if (ioctl(dev, LOOP_GET_STATUS64, &linfo64) == 0) {
@@ -627,11 +569,6 @@ is_associated(int dev, struct stat *file, unsigned long long offset, int isoff)
                    (isoff == 0 || offset == linfo64.lo_offset))
                        ret = 1;
 
-       } else if (ioctl(dev, LOOP_GET_STATUS, &linfo) == 0) {
-               if (file->st_dev == linfo.lo_device &&
-                   file->st_ino == linfo.lo_inode &&
-                   (isoff == 0 || offset == linfo.lo_offset))
-                       ret = 1;
        }
 
        return ret;
@@ -887,22 +824,8 @@ set_loop(const char *device, const char *file, unsigned long long offset,
                loopinfo64.lo_flags = LO_FLAGS_AUTOCLEAR;
 
        i = ioctl(fd, LOOP_SET_STATUS64, &loopinfo64);
-       if (i) {
-               struct loop_info loopinfo;
-               int errsv = errno;
-
-               i = loop_info64_to_old(&loopinfo64, &loopinfo);
-               if (i) {
-                       errno = errsv;
-                       *options &= ~SETLOOP_AUTOCLEAR;
-                       perror("ioctl: LOOP_SET_STATUS64");
-               } else {
-                       i = ioctl(fd, LOOP_SET_STATUS, &loopinfo);
-                       if (i)
-                               perror("ioctl: LOOP_SET_STATUS");
-               }
-               memset(&loopinfo, 0, sizeof(loopinfo));
-       }
+       if (i)
+               perror("ioctl: LOOP_SET_STATUS64");
 
        if ((*options & SETLOOP_AUTOCLEAR) && !is_loopfd_autoclear(fd))
                /* kernel doesn't support loop auto-destruction */
index 64df33916fb101ed3ed44b963ff57796f6236695..891826f7d8a392fe98b1a04ca4556a8922dfe913 100644 (file)
@@ -35,21 +35,6 @@ enum {
 #define LO_NAME_SIZE   64
 #define LO_KEY_SIZE    32
 
-struct loop_info {
-       int             lo_number;
-       my_dev_t        lo_device;
-       unsigned long   lo_inode;
-       my_dev_t        lo_rdevice;
-       int             lo_offset;
-       int             lo_encrypt_type;
-       int             lo_encrypt_key_size;
-       int             lo_flags;
-       char            lo_name[LO_NAME_SIZE];
-       unsigned char   lo_encrypt_key[LO_KEY_SIZE];
-       unsigned long   lo_init[2];
-       char            reserved[4];
-};
-
 struct loop_info64 {
        uint64_t        lo_device;
        uint64_t        lo_inode;