summaryrefslogtreecommitdiff
path: root/shlibs
diff options
context:
space:
mode:
authorKarel Zak <kzak@redhat.com>2010-11-08 12:21:41 +0100
committerKarel Zak <kzak@redhat.com>2011-01-03 12:28:46 +0100
commit7c118af7a1e898a258f6237e3a12faffe5844c0c (patch)
tree2953e1c7c9bd393e166c8f70ea56a3cd2420ca21 /shlibs
parent1d0cd73f3f8929132e731a821ceb07fa6193c00c (diff)
downloadutil-linux-old-7c118af7a1e898a258f6237e3a12faffe5844c0c.tar.gz
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 a1857a44..af500832 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 09c9cdfa..99b2a890 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 410028fa..0f17edfe 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;
}