]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
losetup: rename function *_delete_* to *_detach_*
authorwguanghao <wuguanghao3@huawei.com>
Mon, 22 Sep 2025 14:37:57 +0000 (22:37 +0800)
committerwguanghao <wuguanghao3@huawei.com>
Wed, 24 Sep 2025 02:36:09 +0000 (10:36 +0800)
Signed-off-by: Wu Guanghao <wuguanghao3@huawei.com>
include/loopdev.h
lib/loopdev.c
libmount/src/hook_loopdev.c
sys-utils/losetup.c

index ec57a8c2f7185e2fa2ea1c7f11933b68ae677f61..396ade2640fd1dd375d365d5351ddbc2d42a0034 100644 (file)
@@ -160,7 +160,7 @@ extern int loopdev_is_used(const char *device, const char *filename,
 extern char *loopdev_find_by_backing_file(const char *filename,
                                uint64_t offset, uint64_t sizelimit, int flags);
 extern int loopcxt_find_unused(struct loopdev_cxt *lc);
-extern int loopdev_delete(const char *device);
+extern int loopdev_detach(const char *device);
 extern int loopdev_count_by_backing_file(const char *filename, char **loopdev);
 
 /*
@@ -185,7 +185,7 @@ extern int loopcxt_deinit_iterator(struct loopdev_cxt *lc);
 extern int loopcxt_next(struct loopdev_cxt *lc);
 
 extern int loopcxt_setup_device(struct loopdev_cxt *lc);
-extern int loopcxt_delete_device(struct loopdev_cxt *lc);
+extern int loopcxt_detach_device(struct loopdev_cxt *lc);
 
 extern int loopcxt_ioctl_status(struct loopdev_cxt *lc);
 extern int loopcxt_ioctl_capacity(struct loopdev_cxt *lc);
index 8a51e5e5f46f1d1fcecab16fcc7c26110566b6fe..4836a3ab5de2b0125f3ebdbc7ca4b40ffdaddca1 100644 (file)
@@ -1603,14 +1603,14 @@ int loopcxt_ioctl_blocksize(struct loopdev_cxt *lc, uint64_t blocksize)
        return 0;
 }
 
-int loopcxt_delete_device(struct loopdev_cxt *lc)
+int loopcxt_detach_device(struct loopdev_cxt *lc)
 {
        int rc, fd = loopcxt_get_fd(lc);
 
        if (fd < 0)
                return -EINVAL;
 
-       DBG(SETUP, ul_debugobj(lc, "calling LOOP_SET_CLR_FD"));
+       DBG(SETUP, ul_debugobj(lc, "calling LOOP_CLR_FD"));
 
        rc = repeat_on_eagain( ioctl(fd, LOOP_CLR_FD, 0) );
        if (rc != 0) {
@@ -1786,7 +1786,7 @@ int loopdev_is_used(const char *device, const char *filename,
 /*
  * Returns: 0 = success, < 0 error
  */
-int loopdev_delete(const char *device)
+int loopdev_detach(const char *device)
 {
        struct loopdev_cxt lc;
        int rc;
@@ -1798,7 +1798,7 @@ int loopdev_delete(const char *device)
        if (!rc)
                rc = loopcxt_set_device(&lc, device);
        if (!rc)
-               rc = loopcxt_delete_device(&lc);
+               rc = loopcxt_detach_device(&lc);
        loopcxt_deinit(&lc);
        return rc;
 }
index 444d69d6f4c7b3fb80e922d9d4d78fb4e3ed1475..b72164535c5594e7c85afee575d01c3a34d71201 100644 (file)
@@ -398,7 +398,7 @@ static int delete_loopdev(struct libmnt_context *cxt, struct hook_data *hd)
                hd->loopdev_fd = -1;
        }
 
-       rc = loopdev_delete(src);       /* see lib/loopdev.c */
+       rc = loopdev_detach(src);       /* see lib/loopdev.c */
 
        DBG(LOOP, ul_debugobj(cxt, "deleted [rc=%d]", rc));
        return rc;
index f35bd79fc4889a6e2294389e3599a62402bfae4f..efda75c034ea54d229b98e2267f364faaad9cdef 100644 (file)
@@ -38,8 +38,8 @@
 
 enum {
        A_CREATE = 1,           /* setup a new device */
-       A_DELETE,               /* delete given device(s) */
-       A_DELETE_ALL,           /* delete all devices */
+       A_DETACH,               /* detach given device(s) */
+       A_DETACH_ALL,           /* detach all devices */
        A_SHOW,                 /* list devices */
        A_SHOW_ONE,             /* print info about one device */
        A_FIND_FREE,            /* find first unused */
@@ -233,9 +233,9 @@ static void warn_lost(struct loopdev_cxt *lc)
                        loopcxt_get_device(lc), major(devno), minor(devno));
 }
 
-static int delete_loop(struct loopdev_cxt *lc)
+static int detach_loop(struct loopdev_cxt *lc)
 {
-       if (loopcxt_delete_device(lc)) {
+       if (loopcxt_detach_device(lc)) {
                warn(_("%s: detach failed"), loopcxt_get_device(lc));
                if (loopcxt_is_lost(lc))
                        warn_lost(lc);
@@ -245,7 +245,7 @@ static int delete_loop(struct loopdev_cxt *lc)
        return -1;
 }
 
-static int delete_all_loops(struct loopdev_cxt *lc)
+static int detach_all_loops(struct loopdev_cxt *lc)
 {
        int res = 0;
 
@@ -253,7 +253,7 @@ static int delete_all_loops(struct loopdev_cxt *lc)
                return -1;
 
        while (loopcxt_next(lc) == 0)
-               res += delete_loop(lc);
+               res += detach_loop(lc);
 
        loopcxt_deinit_iterator(lc);
        return res;
@@ -766,13 +766,13 @@ int main(int argc, char **argv)
                        refname = optarg;
                        break;
                case 'd':
-                       act = A_DELETE;
+                       act = A_DETACH;
                        if (loopcxt_set_device(&lc, optarg))
                                err(EXIT_FAILURE, _("%s: failed to use device"),
                                                optarg);
                        break;
                case 'D':
-                       act = A_DELETE_ALL;
+                       act = A_DETACH_ALL;
                        break;
                case 'f':
                        act = A_FIND_FREE;
@@ -833,6 +833,7 @@ int main(int argc, char **argv)
                        usage();
                case 'V':
                        print_version(EXIT_SUCCESS);
+
                default:
                        errtryhelp(EXIT_FAILURE);
                }
@@ -943,18 +944,18 @@ int main(int argc, char **argv)
                        warn_size(file, sizelimit, offset, flags);
                }
                break;
-       case A_DELETE:
-               res = delete_loop(&lc);
+       case A_DETACH:
+               res = detach_loop(&lc);
                while (optind < argc) {
                        if (loopcxt_set_device(&lc, argv[optind]))
                                warn(_("%s: failed to use device"),
                                                argv[optind]);
                        optind++;
-                       res += delete_loop(&lc);
+                       res += detach_loop(&lc);
                }
                break;
-       case A_DELETE_ALL:
-               res = delete_all_loops(&lc);
+       case A_DETACH_ALL:
+               res = detach_all_loops(&lc);
                break;
        case A_FIND_FREE:
                res = find_unused(&lc);