Patch for resolving loop devices
I experienced an error where mkfs.btrfs failed when an unrelated cryptoloop device was mounted.
$ sudo /tmp/btrfs-progs/mkfs.btrfs /dev/mapper/mydisk
WARNING! - Btrfs v0.20-rc1-37-g91d9eec-dirty IS EXPERIMENTAL WARNING! - see http://btrfs.wiki.kernel.org before using
error checking /dev/mapper/mydisk mount status
$ sudo losetup -a /dev/loop0: [0014]:71314 (/home/michael/loopfile), encryption aes (type 18)
I found that resolve_loop_device() method in utils.c was returning "aes" as the associated file, instead of /home/michael/loopfile. This eventually causes the realpath() call in is_same_blk_file() to fail. The attached patch fixes this problem.
Regards,
Michael McMaster
utils.c renamed from utils.c.orig +3 -3
@@ -653,16 +653,16 @@ {int loop_fd;int ret_ioctl; -struct loop_info loopinfo; +struct loop_info64 loopinfo;if ((loop_fd =open (loop_dev,O_RDONLY )) <0 )return -errno; - ret_ioctl =ioctl (loop_fd,LOOP_GET_STATUS , &loopinfo); + ret_ioctl =ioctl (loop_fd,LOOP_GET_STATUS64 , &loopinfo);close (loop_fd);if (ret_ioctl ==0 ) { -strncpy (loop_file, loopinfo.lo_name, max_len); +strncpy (loop_file, loopinfo.lo_file_name, max_len);if (max_len >0 ) loop_file[max_len-1 ] =0 ; }else