summaryrefslogtreecommitdiffstats
path: root/shlibs
diff options
context:
space:
mode:
authorKarel Zak2010-11-08 12:21:41 +0100
committerKarel Zak2011-01-03 12:28:46 +0100
commit7c118af7a1e898a258f6237e3a12faffe5844c0c (patch)
tree2953e1c7c9bd393e166c8f70ea56a3cd2420ca21 /shlibs
parentlibmount: rewrite update (diff)
downloadkernel-qcow2-util-linux-7c118af7a1e898a258f6237e3a12faffe5844c0c.tar.gz
kernel-qcow2-util-linux-7c118af7a1e898a258f6237e3a12faffe5844c0c.tar.xz
kernel-qcow2-util-linux-7c118af7a1e898a258f6237e3a12faffe5844c0c.zip
libmount: add debug messages and fix typos in tab_update
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'shlibs')
-rw-r--r--shlibs/mount/src/tab_parse.c6
-rw-r--r--shlibs/mount/src/tab_update.c14
-rw-r--r--shlibs/mount/src/utils.c25
3 files changed, 32 insertions, 13 deletions
diff --git a/shlibs/mount/src/tab_parse.c b/shlibs/mount/src/tab_parse.c
index a1857a44b..af5008328 100644
--- a/shlibs/mount/src/tab_parse.c
+++ b/shlibs/mount/src/tab_parse.c
@@ -148,7 +148,11 @@ static int mnt_parse_mountinfo_line(mnt_fs *fs, char *s)
} else
unmangle_string(src);
- unmangle_string(fs->fs_optstr);
+ if (!strcmp(fs->fs_optstr, "none")) {
+ free(fs->fs_optstr);
+ fs->fs_optstr = NULL;
+ } else
+ unmangle_string(fs->fs_optstr);
rc = __mnt_fs_set_fstype_ptr(fs, fstype);
if (!rc)
diff --git a/shlibs/mount/src/tab_update.c b/shlibs/mount/src/tab_update.c
index 09c9cdfa0..99b2a890b 100644
--- a/shlibs/mount/src/tab_update.c
+++ b/shlibs/mount/src/tab_update.c
@@ -676,18 +676,22 @@ static int update(const char *target, mnt_fs *fs, unsigned long mountflags)
if (rc && writable)
upd = mnt_new_update(TRUE);
- else
- return -EACCES;
+ else {
+ fprintf(stderr, "utab useless: %m\n");
+ return -1;
+ }
}
rc = mnt_update_set_fs(upd, mountflags, target, fs);
- if (rc)
- goto done;
if (rc == 1) {
- fprintf(stderr, "update is unnecessary\n");
+ /* update is unnecessary */
rc = 0;
goto done;
}
+ if (rc) {
+ fprintf(stderr, "failed to set FS\n");
+ goto done;
+ }
/* [... here should be mount(2) call ...] */
diff --git a/shlibs/mount/src/utils.c b/shlibs/mount/src/utils.c
index 410028fa7..0f17edfea 100644
--- a/shlibs/mount/src/utils.c
+++ b/shlibs/mount/src/utils.c
@@ -448,6 +448,8 @@ int mnt_has_regular_mtab(const char **mtab, int *writable)
int rc;
const char *filename = mtab && *mtab ? *mtab : mnt_get_mtab_path();
+ if (writable)
+ *writable = 0;
if (mtab && !*mtab)
*mtab = filename;
@@ -462,17 +464,21 @@ int mnt_has_regular_mtab(const char **mtab, int *writable)
*writable = !try_write(filename);
return 1;
}
- return 0; /* it's not regular file */
+ goto done;
}
/* try to create the file */
if (writable) {
*writable = !try_write(filename);
- return *writable;
+ if (*writable)
+ return 1;
}
+done:
+ DBG(UTILS, mnt_debug("%s: irregular/non-writable", filename));
return 0;
}
+
/**
*
* mnt_has_regular_utab:
@@ -492,6 +498,8 @@ int mnt_has_regular_utab(const char **utab, int *writable)
int rc;
const char *filename = utab && *utab ? *utab : mnt_get_utab_path();
+ if (writable)
+ *writable = 0;
if (utab && !*utab)
*utab = filename;
@@ -503,28 +511,31 @@ int mnt_has_regular_utab(const char **utab, int *writable)
/* file exist */
if (S_ISREG(st.st_mode)) {
if (writable)
- *writable = try_write(filename);
+ *writable = !try_write(filename);
return 1;
}
- return 0; /* it's not regular file */
+ goto done; /* it's not regular file */
}
if (writable) {
char *dirname = strdup(filename);
if (!dirname)
- return 0;
+ goto done;
stripoff_last_component(dirname); /* remove filename */
rc = mkdir(dirname, 755);
free(dirname);
if (rc && errno != EEXIST)
- return 0; /* probably EACCES */
+ goto done; /* probably EACCES */
*writable = !try_write(filename);
- return *writable;
+ if (*writable)
+ return 1;
}
+done:
+ DBG(UTILS, mnt_debug("%s: irregular/non-writable file", filename));
return 0;
}