loop.c (1dded9acf6dc9a34cd27fcf8815507e4e65b3c4f) | loop.c (c28445fa06a3a54e06938559b9514c5a7f01c90f) |
---|---|
1/* 2 * linux/drivers/block/loop.c 3 * 4 * Written by Theodore Ts'o, 3/29/93 5 * 6 * Copyright 1993 by Theodore Ts'o. Redistribution of this file is 7 * permitted under the GNU General Public License. 8 * --- 667 unchanged lines hidden (view full) --- 676 */ 677static int loop_change_fd(struct loop_device *lo, struct block_device *bdev, 678 unsigned int arg) 679{ 680 struct file *file = NULL, *old_file; 681 int error; 682 bool partscan; 683 | 1/* 2 * linux/drivers/block/loop.c 3 * 4 * Written by Theodore Ts'o, 3/29/93 5 * 6 * Copyright 1993 by Theodore Ts'o. Redistribution of this file is 7 * permitted under the GNU General Public License. 8 * --- 667 unchanged lines hidden (view full) --- 676 */ 677static int loop_change_fd(struct loop_device *lo, struct block_device *bdev, 678 unsigned int arg) 679{ 680 struct file *file = NULL, *old_file; 681 int error; 682 bool partscan; 683 |
684 error = mutex_lock_killable_nested(&loop_ctl_mutex, 1); | 684 error = mutex_lock_killable(&loop_ctl_mutex); |
685 if (error) 686 return error; 687 error = -ENXIO; 688 if (lo->lo_state != Lo_bound) 689 goto out_err; 690 691 /* the loop device has to be read-only */ 692 error = -EINVAL; --- 221 unchanged lines hidden (view full) --- 914 /* This is safe, since we have a reference from open(). */ 915 __module_get(THIS_MODULE); 916 917 error = -EBADF; 918 file = fget(arg); 919 if (!file) 920 goto out; 921 | 685 if (error) 686 return error; 687 error = -ENXIO; 688 if (lo->lo_state != Lo_bound) 689 goto out_err; 690 691 /* the loop device has to be read-only */ 692 error = -EINVAL; --- 221 unchanged lines hidden (view full) --- 914 /* This is safe, since we have a reference from open(). */ 915 __module_get(THIS_MODULE); 916 917 error = -EBADF; 918 file = fget(arg); 919 if (!file) 920 goto out; 921 |
922 error = mutex_lock_killable_nested(&loop_ctl_mutex, 1); | 922 error = mutex_lock_killable(&loop_ctl_mutex); |
923 if (error) 924 goto out_putf; 925 926 error = -EBUSY; 927 if (lo->lo_state != Lo_unbound) 928 goto out_unlock; 929 930 error = loop_validate_file(file, bdev); --- 199 unchanged lines hidden (view full) --- 1130 fput(filp); 1131 return err; 1132} 1133 1134static int loop_clr_fd(struct loop_device *lo) 1135{ 1136 int err; 1137 | 923 if (error) 924 goto out_putf; 925 926 error = -EBUSY; 927 if (lo->lo_state != Lo_unbound) 928 goto out_unlock; 929 930 error = loop_validate_file(file, bdev); --- 199 unchanged lines hidden (view full) --- 1130 fput(filp); 1131 return err; 1132} 1133 1134static int loop_clr_fd(struct loop_device *lo) 1135{ 1136 int err; 1137 |
1138 err = mutex_lock_killable_nested(&loop_ctl_mutex, 1); | 1138 err = mutex_lock_killable(&loop_ctl_mutex); |
1139 if (err) 1140 return err; 1141 if (lo->lo_state != Lo_bound) { 1142 mutex_unlock(&loop_ctl_mutex); 1143 return -ENXIO; 1144 } 1145 /* 1146 * If we've explicitly asked to tear down the loop device, --- 20 unchanged lines hidden (view full) --- 1167loop_set_status(struct loop_device *lo, const struct loop_info64 *info) 1168{ 1169 int err; 1170 struct loop_func_table *xfer; 1171 kuid_t uid = current_uid(); 1172 struct block_device *bdev; 1173 bool partscan = false; 1174 | 1139 if (err) 1140 return err; 1141 if (lo->lo_state != Lo_bound) { 1142 mutex_unlock(&loop_ctl_mutex); 1143 return -ENXIO; 1144 } 1145 /* 1146 * If we've explicitly asked to tear down the loop device, --- 20 unchanged lines hidden (view full) --- 1167loop_set_status(struct loop_device *lo, const struct loop_info64 *info) 1168{ 1169 int err; 1170 struct loop_func_table *xfer; 1171 kuid_t uid = current_uid(); 1172 struct block_device *bdev; 1173 bool partscan = false; 1174 |
1175 err = mutex_lock_killable_nested(&loop_ctl_mutex, 1); | 1175 err = mutex_lock_killable(&loop_ctl_mutex); |
1176 if (err) 1177 return err; 1178 if (lo->lo_encrypt_key_size && 1179 !uid_eq(lo->lo_key_owner, uid) && 1180 !capable(CAP_SYS_ADMIN)) { 1181 err = -EPERM; 1182 goto out_unlock; 1183 } --- 88 unchanged lines hidden (view full) --- 1272 1273static int 1274loop_get_status(struct loop_device *lo, struct loop_info64 *info) 1275{ 1276 struct path path; 1277 struct kstat stat; 1278 int ret; 1279 | 1176 if (err) 1177 return err; 1178 if (lo->lo_encrypt_key_size && 1179 !uid_eq(lo->lo_key_owner, uid) && 1180 !capable(CAP_SYS_ADMIN)) { 1181 err = -EPERM; 1182 goto out_unlock; 1183 } --- 88 unchanged lines hidden (view full) --- 1272 1273static int 1274loop_get_status(struct loop_device *lo, struct loop_info64 *info) 1275{ 1276 struct path path; 1277 struct kstat stat; 1278 int ret; 1279 |
1280 ret = mutex_lock_killable_nested(&loop_ctl_mutex, 1); | 1280 ret = mutex_lock_killable(&loop_ctl_mutex); |
1281 if (ret) 1282 return ret; 1283 if (lo->lo_state != Lo_bound) { 1284 mutex_unlock(&loop_ctl_mutex); 1285 return -ENXIO; 1286 } 1287 1288 memset(info, 0, sizeof(*info)); --- 172 unchanged lines hidden (view full) --- 1461 return 0; 1462} 1463 1464static int lo_simple_ioctl(struct loop_device *lo, unsigned int cmd, 1465 unsigned long arg) 1466{ 1467 int err; 1468 | 1281 if (ret) 1282 return ret; 1283 if (lo->lo_state != Lo_bound) { 1284 mutex_unlock(&loop_ctl_mutex); 1285 return -ENXIO; 1286 } 1287 1288 memset(info, 0, sizeof(*info)); --- 172 unchanged lines hidden (view full) --- 1461 return 0; 1462} 1463 1464static int lo_simple_ioctl(struct loop_device *lo, unsigned int cmd, 1465 unsigned long arg) 1466{ 1467 int err; 1468 |
1469 err = mutex_lock_killable_nested(&loop_ctl_mutex, 1); | 1469 err = mutex_lock_killable(&loop_ctl_mutex); |
1470 if (err) 1471 return err; 1472 switch (cmd) { 1473 case LOOP_SET_CAPACITY: 1474 err = loop_set_capacity(lo); 1475 break; 1476 case LOOP_SET_DIRECT_IO: 1477 err = loop_set_dio(lo, arg); --- 750 unchanged lines hidden --- | 1470 if (err) 1471 return err; 1472 switch (cmd) { 1473 case LOOP_SET_CAPACITY: 1474 err = loop_set_capacity(lo); 1475 break; 1476 case LOOP_SET_DIRECT_IO: 1477 err = loop_set_dio(lo, arg); --- 750 unchanged lines hidden --- |