]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libmount: add loop to debug output
authorKarel Zak <kzak@redhat.com>
Tue, 16 Feb 2016 14:03:22 +0000 (15:03 +0100)
committerKarel Zak <kzak@redhat.com>
Tue, 16 Feb 2016 14:03:22 +0000 (15:03 +0100)
Signed-off-by: Karel Zak <kzak@redhat.com>
libmount/src/context_loopdev.c
libmount/src/init.c
libmount/src/mountP.h

index 787114228c650cafa04603be0c654f4ccaf423fc..a1ff971c632b25dbc74255691d6f933e9ae922a8 100644 (file)
@@ -36,7 +36,7 @@ int mnt_context_is_loopdev(struct libmnt_context *cxt)
                                    MNT_MS_OFFSET |
                                    MNT_MS_SIZELIMIT)) {
 
-               DBG(CXT, ul_debugobj(cxt, "loopdev specific options detected"));
+               DBG(LOOP, ul_debugobj(cxt, "loopdev specific options detected"));
                return 1;
        }
 
@@ -62,7 +62,7 @@ int mnt_context_is_loopdev(struct libmnt_context *cxt)
 
                if (stat(src, &st) == 0 && S_ISREG(st.st_mode) &&
                    st.st_size > 1024) {
-                       DBG(CXT, ul_debugobj(cxt, "automatically enabling loop= option"));
+                       DBG(LOOP, ul_debugobj(cxt, "automatically enabling loop= option"));
                        cxt->user_mountflags |= MNT_MS_LOOP;
                        mnt_optstr_append_option(&cxt->fs->user_optstr, "loop", NULL);
                        return 1;
@@ -96,7 +96,7 @@ is_mounted_same_loopfile(struct libmnt_context *cxt,
        if (!target || !backing_file || mnt_context_get_mtab(cxt, &tb))
                return 0;
 
-       DBG(CXT, ul_debugobj(cxt, "checking if %s mounted on %s",
+       DBG(LOOP, ul_debugobj(cxt, "checking if %s mounted on %s",
                                backing_file, target));
 
        cache = mnt_context_get_cache(cxt);
@@ -130,7 +130,7 @@ is_mounted_same_loopfile(struct libmnt_context *cxt,
                }
        }
        if (rc)
-               DBG(CXT, ul_debugobj(cxt, "%s already mounted", backing_file));
+               DBG(LOOP, ul_debugobj(cxt, "%s already mounted", backing_file));
        return rc;
 }
 
@@ -151,10 +151,10 @@ int mnt_context_setup_loopdev(struct libmnt_context *cxt)
        if (!backing_file)
                return -EINVAL;
 
-       DBG(CXT, ul_debugobj(cxt, "trying to setup loopdev for %s", backing_file));
+       DBG(LOOP, ul_debugobj(cxt, "trying to setup device for %s", backing_file));
 
        if (cxt->mountflags & MS_RDONLY) {
-               DBG(CXT, ul_debugobj(cxt, "enabling READ-ONLY flag"));
+               DBG(LOOP, ul_debugobj(cxt, "enabling READ-ONLY flag"));
                lo_flags |= LO_FLAGS_READ_ONLY;
        }
 
@@ -185,7 +185,7 @@ int mnt_context_setup_loopdev(struct libmnt_context *cxt)
            mnt_optstr_get_option(optstr, "offset", &val, &len) == 0) {
                rc = mnt_parse_offset(val, len, &offset);
                if (rc) {
-                       DBG(CXT, ul_debugobj(cxt, "failed to parse offset="));
+                       DBG(LOOP, ul_debugobj(cxt, "failed to parse offset="));
                        rc = -MNT_ERR_MOUNTOPT;
                }
        }
@@ -197,7 +197,7 @@ int mnt_context_setup_loopdev(struct libmnt_context *cxt)
            mnt_optstr_get_option(optstr, "sizelimit", &val, &len) == 0) {
                rc = mnt_parse_offset(val, len, &sizelimit);
                if (rc) {
-                       DBG(CXT, ul_debugobj(cxt, "failed to parse sizelimit="));
+                       DBG(LOOP, ul_debugobj(cxt, "failed to parse sizelimit="));
                        rc = -MNT_ERR_MOUNTOPT;
                }
        }
@@ -207,7 +207,7 @@ int mnt_context_setup_loopdev(struct libmnt_context *cxt)
         */
        if (rc == 0 && (cxt->user_mountflags & MNT_MS_ENCRYPTION) &&
            mnt_optstr_get_option(optstr, "encryption", &val, &len) == 0) {
-               DBG(CXT, ul_debugobj(cxt, "encryption no longer supported"));
+               DBG(LOOP, ul_debugobj(cxt, "encryption no longer supported"));
                rc = -MNT_ERR_MOUNTOPT;
        }
 
@@ -224,7 +224,7 @@ int mnt_context_setup_loopdev(struct libmnt_context *cxt)
         */
        if (get_linux_version() >= KERNEL_VERSION(2, 6, 37) ||
            !mnt_context_mtab_writable(cxt)) {
-               DBG(CXT, ul_debugobj(cxt, "enabling AUTOCLEAR flag"));
+               DBG(LOOP, ul_debugobj(cxt, "enabling AUTOCLEAR flag"));
                lo_flags |= LO_FLAGS_AUTOCLEAR;
        }
 
@@ -234,7 +234,7 @@ int mnt_context_setup_loopdev(struct libmnt_context *cxt)
                        rc = loopcxt_find_unused(&lc);
                        if (rc)
                                goto done;
-                       DBG(CXT, ul_debugobj(cxt, "trying to use %s",
+                       DBG(LOOP, ul_debugobj(cxt, "trying to use %s",
                                                loopcxt_get_device(&lc)));
                }
 
@@ -250,7 +250,7 @@ int mnt_context_setup_loopdev(struct libmnt_context *cxt)
                if (!rc)
                        loopcxt_set_flags(&lc, lo_flags);
                if (rc) {
-                       DBG(CXT, ul_debugobj(cxt, "failed to set loopdev attributes"));
+                       DBG(LOOP, ul_debugobj(cxt, "failed to set loop attributes"));
                        goto done;
                }
 
@@ -260,11 +260,11 @@ int mnt_context_setup_loopdev(struct libmnt_context *cxt)
                        break;          /* success */
 
                if (loopdev || rc != -EBUSY) {
-                       DBG(CXT, ul_debugobj(cxt, "failed to setup device"));
+                       DBG(LOOP, ul_debugobj(cxt, "failed to setup device"));
                        rc = -MNT_ERR_LOOPDEV;
                        goto done;
                }
-               DBG(CXT, ul_debugobj(cxt, "loopdev stolen...trying again"));
+               DBG(LOOP, ul_debugobj(cxt, "device stolen...trying again"));
        } while (1);
 
        if (!rc)
@@ -280,6 +280,7 @@ int mnt_context_setup_loopdev(struct libmnt_context *cxt)
                         * autoclear flag accepted by the kernel, don't store
                         * the "loop=" option to mtab.
                         */
+                       DBG(LOOP, ul_debugobj(cxt, "removing unnecessary loop= from mtab"));
                        cxt->user_mountflags &= ~MNT_MS_LOOP;
                        mnt_optstr_remove_option(&cxt->fs->user_optstr, "loop");
                }
@@ -325,7 +326,7 @@ int mnt_context_delete_loopdev(struct libmnt_context *cxt)
        cxt->flags &= ~MNT_FL_LOOPDEV_READY;
        cxt->loopdev_fd = -1;
 
-       DBG(CXT, ul_debugobj(cxt, "loopdev deleted [rc=%d]", rc));
+       DBG(LOOP, ul_debugobj(cxt, "deleted [rc=%d]", rc));
        return rc;
 }
 
@@ -348,7 +349,7 @@ int mnt_context_clear_loopdev(struct libmnt_context *cxt)
                /*
                 * mount(2) success, close the device
                 */
-               DBG(CXT, ul_debugobj(cxt, "closing loopdev FD"));
+               DBG(LOOP, ul_debugobj(cxt, "closing FD"));
                close(cxt->loopdev_fd);
        }
        cxt->loopdev_fd = -1;
index 917008dc2965eadeeb23c0ac497fb45e0c158535..9d3e4b539d9bcf1bda183797654db29d482e8e0f 100644 (file)
@@ -25,6 +25,7 @@ UL_DEBUG_DEFINE_MASKNAMES(libmount) =
        { "fs", MNT_DEBUG_FS,           "FS abstraction" },
        { "help", MNT_DEBUG_HELP,       "this help" },
        { "locks", MNT_DEBUG_LOCKS,     "mtab and utab locking" },
+       { "loop", MNT_DEBUG_LOOP,       "loop devices routines" },
        { "options", MNT_DEBUG_OPTIONS, "mount options parsing" },
        { "tab", MNT_DEBUG_TAB,         "fstab, mtab, mounninfo routines" },
        { "update", MNT_DEBUG_UPDATE,   "mtab, utab updates" },
index 0bc67e5f7a7818001c09ff649861d5303e448dfb..46919f2a0e9ab184520de9197114e585e13b51ad 100644 (file)
@@ -41,6 +41,7 @@
 #define MNT_DEBUG_DIFF         (1 << 10)
 #define MNT_DEBUG_MONITOR      (1 << 11)
 #define MNT_DEBUG_BTRFS                (1 << 12)
+#define MNT_DEBUG_LOOP         (1 << 13)
 
 #define MNT_DEBUG_ALL          0xFFFF