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);
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)
int nolock; /* don't alloca private mnt_lock */
mnt_fs *fs; /* entry */
mnt_lock *lc; /* lock or NULL */
+ int pointless; /* update is unnecessary */
};
/**
return 0;
}
+/**
+ * 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
return 0;
}
+/**
+ * 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)
mnt_free_fs(upd->fs);
upd->fs = x;
+ upd->pointless = FALSE;
return 0;
}
return -1;
}
+/**
+ * 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
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;
}
* @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.
*/
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)));
/*