summaryrefslogtreecommitdiff
path: root/shlibs
diff options
context:
space:
mode:
authorKarel Zak <kzak@redhat.com>2010-09-30 10:42:20 +0200
committerKarel Zak <kzak@redhat.com>2011-01-03 12:28:43 +0100
commitd300992de138c4c1f52a41ade64e24fbf8fbf2ce (patch)
tree5228c4304624bbe39f6a3d161ca2b952632bed5b /shlibs
parentf58168ffb6facb095ec3c618513ed49d730d7488 (diff)
downloadutil-linux-old-d300992de138c4c1f52a41ade64e24fbf8fbf2ce.tar.gz
libmount: extend mnt_update_* API
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'shlibs')
-rw-r--r--shlibs/mount/src/mount.h.in3
-rw-r--r--shlibs/mount/src/mount.sym2
-rw-r--r--shlibs/mount/src/tab_update.c57
3 files changed, 61 insertions, 1 deletions
diff --git a/shlibs/mount/src/mount.h.in b/shlibs/mount/src/mount.h.in
index cf491151..0124a329 100644
--- a/shlibs/mount/src/mount.h.in
+++ b/shlibs/mount/src/mount.h.in
@@ -285,6 +285,8 @@ extern int mnt_tab_find_next_fs(mnt_tab *tb, mnt_iter *itr,
extern mnt_update *mnt_new_update(int action, unsigned long mountflags, const mnt_fs *fs);
extern void mnt_free_update(mnt_update *upd);
extern int mnt_update_set_filename(mnt_update *upd, const char *filename);
+extern const char *mnt_update_get_filename(mnt_update *upd);
+extern int mnt_update_get_format(mnt_update *upd);
extern int mnt_update_set_action(mnt_update *upd, int action);
extern int mnt_update_set_format(mnt_update *upd, int format);
extern int mnt_update_set_mountflags(mnt_update *upd, unsigned long flags);
@@ -295,6 +297,7 @@ extern int mnt_update_set_fs(mnt_update *upd, const mnt_fs *fs);
extern int mnt_prepare_update(mnt_update *upd);
extern int mnt_update_mtab(mnt_update *upd);
+extern int mnt_update_is_pointless(mnt_update *upd);
/*
* mount(8) userspace options masks (MNT_MAP_USERSPACE map)
diff --git a/shlibs/mount/src/mount.sym b/shlibs/mount/src/mount.sym
index bb1ae4f9..19a723a4 100644
--- a/shlibs/mount/src/mount.sym
+++ b/shlibs/mount/src/mount.sym
@@ -125,6 +125,8 @@ global:
mnt_update_set_fs;
mnt_update_set_mountflags;
mnt_update_set_old_target;
+ mnt_update_get_format;
+ mnt_update_get_filename;
local:
*;
};
diff --git a/shlibs/mount/src/tab_update.c b/shlibs/mount/src/tab_update.c
index 1573b58b..8b322dde 100644
--- a/shlibs/mount/src/tab_update.c
+++ b/shlibs/mount/src/tab_update.c
@@ -64,6 +64,7 @@ struct _mnt_update {
int nolock; /* don't alloca private mnt_lock */
mnt_fs *fs; /* entry */
mnt_lock *lc; /* lock or NULL */
+ int pointless; /* update is unnecessary */
};
/**
@@ -137,6 +138,20 @@ int mnt_update_set_filename(mnt_update *upd, const char *filename)
}
/**
+ * mnt_update_get_filename
+ * @upd: update
+ *
+ * Note that function returns NULL if the filename has not been defined (see
+ * mnt_update_set_filename()) or mnt_prepare_update() has not been called.
+ *
+ * Returns: filename or NULL.
+ */
+const char *mnt_update_get_filename(mnt_update *upd)
+{
+ return upd ? upd->filename : NULL;
+}
+
+/**
* mnt_update_set_action:
* @upd: update
* @action: MNT_ACT_{MOUNT,UMOUNT}
@@ -175,10 +190,27 @@ int mnt_update_set_format(mnt_update *upd, int format)
}
/**
+ * mnt_update_get_format
+ * @upd: update
+ *
+ * Note that function returns zero if the format has not been defined (see
+ * mnt_update_set_format()) or mnt_prepare_update() has not been called.
+ *
+ * Returns: MNT_FMT_{MTAB,FSTAB,MOUNTINFO} or 0.
+ */
+int mnt_update_get_format(mnt_update *upd)
+{
+ return upd ? upd->format : 0;
+}
+
+/**
* mnt_update_set_fs:
* @upd: update
* @fs: filesystem to write to file
*
+ * This function replaces the current setting related to the current FS. Note that
+ * format, old target and mountflags are not reseted.
+ *
* Returns; 0 on success, -1 in case of error.
*/
int mnt_update_set_fs(mnt_update *upd, const mnt_fs *fs)
@@ -196,6 +228,7 @@ int mnt_update_set_fs(mnt_update *upd, const mnt_fs *fs)
mnt_free_fs(upd->fs);
upd->fs = x;
+ upd->pointless = FALSE;
return 0;
}
@@ -518,6 +551,20 @@ err:
}
/**
+ * mnt_update_is_pointless:
+ * @upd: update
+ *
+ * This function returns 1 if the previous mnt_prepare_update() call returned 1
+ * too.
+ *
+ * Returns: status of the update.
+ */
+int mnt_update_is_pointless(mnt_update *upd)
+{
+ return upd ? upd->pointless : 0;
+}
+
+/**
* mnt_prepare_update:
* @upd: update
*
@@ -642,6 +689,8 @@ err:
DBG(UPDATE, mnt_debug_h(upd, "prepare update: failed"));
return rc;
nothing:
+ upd->pointless = TRUE;
+ DBG(UPDATE, mnt_debug_h(upd, "prepare update: pointless"));
return 1;
}
@@ -788,7 +837,8 @@ done:
* @upd: update
*
* Updates the update file. The behavior of this function is undefined if
- * mnt_prepare_update() has not been called.
+ * mnt_prepare_update() has not been called. The request to update file will
+ * be ignored for pointless updates (see mnt_update_is_pointless()).
*
* Returns: 0 on success, -1 in case of error.
*/
@@ -802,6 +852,11 @@ int mnt_update_file(mnt_update *upd)
if (!upd || !upd->fs)
return -1;
+ if (upd->pointless) {
+ DBG(UPDATE, mnt_debug_h(upd, "ingnore update requiest (pointless)"));
+ return 0;
+ }
+
DBG(UPDATE, mnt_debug_h(upd, "update (target %s)",
mnt_fs_get_target(upd->fs)));
/*