* @title: Cache
* @short_description: paths and tags (UUID/LABEL) caching
*
- * The cache is a very simple API for work with tags (LABEL, UUID, ...) and
+ * The cache is a very simple API for working with tags (LABEL, UUID, ...) and
* paths. The cache uses libblkid as a backend for TAGs resolution.
*
* All returned paths are always canonicalized.
free(cache);
}
-/* note that the @key could be tha same pointer as @value */
+/* note that the @key could be the same pointer as @value */
static int cache_add_entry(struct libmnt_cache *cache, char *key,
char *value, int flag)
{
return 0;
}
-/* add tag to the cache, @devname has to be allocated string */
+/* add tag to the cache, @devname has to be an allocated string */
static int cache_add_tag(struct libmnt_cache *cache, const char *tagname,
const char *tagval, char *devname, int flag)
{
DBG(CACHE, mnt_debug_h(cache, "tags for %s requested", devname));
- /* check is device is already cached */
+ /* check if device is already cached */
for (i = 0; i < cache->nents; i++) {
struct mnt_cache_entry *e = &cache->ents[i];
if (!(e->flag & MNT_CACHE_TAGREAD))
continue;
if (strcmp(e->value, devname) == 0)
- /* tags has been already read */
+ /* tags have already been read */
return 0;
}
* @token: tag name (e.g "LABEL")
* @value: tag value
*
- * Look up @cache to check it @tag+@value are associated with @devname.
+ * Look up @cache to check if @tag+@value are associated with @devname.
*
* Returns: 1 on success or 0.
*/
rc = blkid_do_safeprobe(pr);
- DBG(CACHE, mnt_debug_h(cache, "liblkid rc=%d", rc));
+ DBG(CACHE, mnt_debug_h(cache, "libblkid rc=%d", rc));
if (!rc && !blkid_probe_lookup_value(pr, "TYPE", &data, NULL))
type = strdup(data);
* - /dev/loopN to the loop backing filename
* - empty path (NULL) to 'none'
*
- * Returns: new allocated string with path, result has to be always deallocated
+ * Returns: newly allocated string with path, result always has to be deallocated
* by free().
*/
char *mnt_pretty_path(const char *path, struct libmnt_cache *cache)
* mnt_reset_context:
* @cxt: mount context
*
- * Resets all information in the context that are directly related to
+ * Resets all information in the context that is directly related to
* the latest mount (spec, source, target, mount options, ....)
*
- * The match patters, cached fstab, cached canonicalized paths and tags and
- * [e]uid are not reseted. You have to use
+ * The match patterns, cached fstab, cached canonicalized paths and tags and
+ * [e]uid are not reset. You have to use
*
* mnt_context_set_fstab(cxt, NULL);
* mnt_context_set_cache(cxt, NULL);
* mnt_context_set_options_pattern(cxt, NULL);
*
*
- * to reset these stuff.
+ * to reset this stuff.
*
* Returns: 0 on success, negative number in case of error.
*/
mnt_context_reset_status(cxt);
mnt_context_set_tabfilter(cxt, NULL, NULL);
- /* restore non-resetable flags */
+ /* restore non-resettable flags */
cxt->flags |= (fl & MNT_FL_EXTERN_FSTAB);
cxt->flags |= (fl & MNT_FL_EXTERN_CACHE);
cxt->flags |= (fl & MNT_FL_NOMTAB);
* mnt_context_is_restricted:
* @cxt: mount context
*
- * Returns: 0 for unrestricted mount (user is root), or 1 for non-root mounts
+ * Returns: 0 for an unrestricted mount (user is root), or 1 for non-root mounts
*/
int mnt_context_is_restricted(struct libmnt_context *cxt)
{
* @cxt: mount context
* @mode: MNT_OMASK_* flags
*
- * Controls how to use mount optionsmsource and target paths from fstab/mtab.
+ * Controls how to use mount optionssource and target paths from fstab/mtab.
*
* @MNT_OMODE_IGNORE: ignore mtab/fstab options
*
*
* @MNT_OMODE_REPLACE: replace existing options with options from mtab/fstab
*
- * @MNT_OMODE_FORCE: always read mtab/fstab (although source and target is defined)
+ * @MNT_OMODE_FORCE: always read mtab/fstab (although source and target are defined)
*
* @MNT_OMODE_FSTAB: read from fstab
*
* Notes:
*
* - MNT_OMODE_USER is always used if mount context is in restricted mode
- * - MNT_OMODE_AUTO is used if nothing other is defined
- * - the flags are eavaluated in this order: MNT_OMODE_NOTAB, MNT_OMODE_FORCE,
+ * - MNT_OMODE_AUTO is used if nothing else is defined
+ * - the flags are evaluated in this order: MNT_OMODE_NOTAB, MNT_OMODE_FORCE,
* MNT_OMODE_FSTAB, MNT_OMODE_MTAB and then the mount options from fstab/mtab
* are set according to MNT_OMODE_{IGNORE,APPEND,PREPAND,REPLACE}
*
* @disable: TRUE or FALSE
*
* Enable/disable paths canonicalization and tags evaluation. The libmount context
- * canonicalies paths when search in fstab and when prepare source and target paths
+ * canonicalizes paths when searching in fstab and when preparing source and target paths
* for mount(2) syscall.
*
- * This fuction has effect to the private (within context) fstab instance only
+ * This fuction has an effect on the private (within context) fstab instance only
* (see mnt_context_set_fstab()). If you want to use an external fstab then you
- * need manage your private struct libmnt_cache (see mnt_table_set_cache(fstab,
+ * need to manage your private struct libmnt_cache (see mnt_table_set_cache(fstab,
* NULL).
*
* Returns: 0 on success, negative number in case of error.
* mnt_context_is_nocanonicalize:
* @cxt: mount context
*
- * Returns: 1 if no-canonicalize mode enabled or 0.
+ * Returns: 1 if no-canonicalize mode is enabled or 0.
*/
int mnt_context_is_nocanonicalize(struct libmnt_context *cxt)
{
* mnt_context_is_rdonly_umount
* @cxt: mount context
*
- * See also mnt_context_enable_rdonly_umount() and see umount(8) man page,
+ * See also mnt_context_enable_rdonly_umount() and umount(8) man page,
* option -r.
*
* Returns: 1 if read-only remount failed umount(2) is enables or 0
* @cxt: mount context
* @enable: TRUE or FALSE
*
- * Enable/disable loop delete (destroy) after umount (see umount(8), option -d)
+ * Enable/disable the loop delete (destroy) after umount (see umount(8), option -d)
*
* Returns: 0 on success, negative number in case of error.
*/
* @fs instance is not deallocated by mnt_free_context() or mnt_reset_context().
*
* The @fs will be modified by mnt_context_set_{source,target,options,fstype}
- * functions, If the @fs is NULL then all current FS specific setting (source,
- * target, etc., exclude spec) is reseted.
+ * functions, If the @fs is NULL, then all current FS specific settings (source,
+ * target, etc., exclude spec) are reset.
*
* Returns: 0 on success, negative number in case of error.
*/
* Note that the FS is modified by mnt_context_set_{source,target,options,fstype}
* functions.
*
- * Returns: pointer to FS description or NULL in case of calloc() errrr.
+ * Returns: pointer to FS description or NULL in case of a calloc() error.
*/
struct libmnt_fs *mnt_context_get_fs(struct libmnt_context *cxt)
{
* mnt_context_get_source:
* @cxt: mount context
*
- * Returns: returns pointer or NULL in case of error pr if not set.
+ * Returns: returns pointer or NULL in case of error or if not set.
*/
const char *mnt_context_get_source(struct libmnt_context *cxt)
{
* mnt_context_get_target:
* @cxt: mount context
*
- * Returns: returns pointer or NULL in case of error pr if not set.
+ * Returns: returns pointer or NULL in case of error or if not set.
*/
const char *mnt_context_get_target(struct libmnt_context *cxt)
{
* @cxt: mount context
* @fstype: filesystem type
*
- * Note that the @fstype has to be the real FS type. For patterns with
- * comma-separated list of filesystems or for "nofs" notation use
+ * Note that the @fstype has to be a FS type. For patterns with
+ * comma-separated list of filesystems or for the "nofs" notation, use
* mnt_context_set_fstype_pattern().
*
* Returns: 0 on success, negative number in case of error.
* mnt_context_get_fstype:
* @cxt: mount context
*
- * Returns: pointer or NULL in case of error pr if not set.
+ * Returns: pointer or NULL in case of error or if not set.
*/
const char *mnt_context_get_fstype(struct libmnt_context *cxt)
{
* This function returns mount options set by mnt_context_set_options() or
* mnt_context_append_options().
*
- * Note that *after* mnt_context_prepare_mount() may the mount options string
- * also includes options set by mnt_context_set_mflags() or another options
+ * Note that *after* mnt_context_prepare_mount(), the mount options string
+ * may also include options set by mnt_context_set_mflags() or other options
* generated by this library.
*
* Returns: pointer or NULL
* instance. Note that the external instance is not deallocated by mnt_free_context().
*
* The fstab is used read-only and is not modified, it should be possible to
- * share the fstab between more mount contexts (TODO: tests it.)
+ * share the fstab between more mount contexts (TODO: test it.)
*
- * If the @tb argument is NULL then the current private fstab instance is
- * reseted.
+ * If the @tb argument is NULL, then the current private fstab instance is
+ * reset.
*
* Returns: 0 on success, negative number in case of error.
*/
* @tb: returns mtab
*
* See also mnt_table_parse_mtab() for more details about mtab/mountinfo. The
- * result will deallocated by mnt_free_context(@cxt).
+ * result will be deallocated by mnt_free_context(@cxt).
*
* Returns: 0 on success, negative number in case of error.
*/
}
/*
- * Allows to specify filter for tab file entries. The filter is called by
- * table parser. Currently used for mtab and utab only.
+ * Allows to specify a filter for tab file entries. The filter is called by
+ * the table parser. Currently used for mtab and utab only.
*/
int mnt_context_set_tabfilter(struct libmnt_context *cxt,
int (*fltr)(struct libmnt_fs *, void *),
* callback and cache for tags and paths is set according to the @cxt setting.
* See also mnt_table_parse_file().
*
- * It's strongly recommended use mnt_context_get_mtab() and
+ * It's strongly recommended to use the mnt_context_get_mtab() and
* mnt_context_get_fstab() functions for mtab and fstab files. This function
* does not care about LIBMOUNT_* env.variables and does not merge userspace
* options.
* allows to overwrite the private cache with an external instance. Note that
* the external instance is not deallocated by mnt_free_context().
*
- * If the @cache argument is NULL then the current private cache instance is
- * reseted.
+ * If the @cache argument is NULL, then the current private cache instance is
+ * reset.
*
* Returns: 0 on success, negative number in case of error.
*/
* @release: callback to release (delallocate) password
*
* Sets callbacks for encryption password (e.g encrypted loopdev). This
- * function is deprecated (encrypted loops are no ore supported).
+ * function is deprecated (encrypted loops are no longer supported).
*
* Returns: 0 on success, negative number in case of error.
*/
*
* The default behavior is to ignore all signals (except SIGALRM and
* SIGTRAP for mtab udate) when the lock is locked. If this behavior
- * is unacceptable then use:
+ * is unacceptable, then use:
*
* lc = mnt_context_get_lock(cxt);
* if (lc)
*
* mnt_context_set_options(cxt, "noexec,nosuid");
*
- * these both calls have the same effect.
+ * both of these calls have the same effect.
*
* Returns: 0 on success, negative number in case of error.
*/
* @flags: returns MS_* mount flags
*
* Converts mount options string to MS_* flags and bitewise-OR the result with
- * already defined flags (see mnt_context_set_mflags()).
+ * the already defined flags (see mnt_context_set_mflags()).
*
* Returns: 0 on success, negative number in case of error.
*/
*
* Sets userspace mount flags.
*
- * See also notest for mnt_context_set_mflags().
+ * See also notes for mnt_context_set_mflags().
*
* Returns: 0 on success, negative number in case of error.
*/
* @flags: returns mount flags
*
* Converts mount options string to MNT_MS_* flags and bitewise-OR the result
- * with already defined flags (see mnt_context_set_user_mflags()).
+ * with the already defined flags (see mnt_context_set_user_mflags()).
*
* Returns: 0 on success, negative number in case of error.
*/
* function allows to overwrite this behavior, and @data will be used instead
* of mount options.
*
- * The libmount does not deallocated the data by mnt_free_context(). Note that
+ * The libmount does not deallocate the data by mnt_free_context(). Note that
* NULL is also valid mount data.
*
* Returns: 0 on success, negative number in case of error.
return mnt_fs_set_source(cxt->fs, "none");
/* ignore filesystems without source or filesystems
- * where the source is quasi-path (//foo/bar)
+ * where the source is a quasi-path (//foo/bar)
*/
if (!src || mnt_fs_is_netfs(cxt->fs))
return 0;
}
/*
- * It's usully no error when we're not able to detect filesystem type -- we
- * will try to use types from /{etc,proc}/filesystems.
+ * It's usually no error when we're not able to detect the filesystem type -- we
+ * will try to use the types from /{etc,proc}/filesystems.
*/
int mnt_context_guess_fstype(struct libmnt_context *cxt)
{
*
* mount /foo/bar
*
- * the path could be a mountpoint as well as source (for
- * example bind mount, symlink to device, ...).
+ * the path could be a mountpoint as well as a source (for
+ * example bind mount, symlink to a device, ...).
*/
if (src && !mnt_fs_get_tag(cxt->fs, NULL, NULL))
fs = mnt_table_find_target(tb, src, direction);
DBG(CXT, mnt_debug_h(cxt, "force fstab usage for non-root users!"));
cxt->optsmode = MNT_OMODE_USER;
} else if (cxt->optsmode == 0) {
- DBG(CXT, mnt_debug_h(cxt, "use default optmode"));
+ DBG(CXT, mnt_debug_h(cxt, "use default optsmode"));
cxt->optsmode = MNT_OMODE_AUTO;
} else if (cxt->optsmode & MNT_OMODE_NOTAB) {
cxt->optsmode &= ~MNT_OMODE_FSTAB;
}
/*
- * This is not public function!
+ * This is not a public function!
*
* Returns 1 if *only propagation flags* change is requested.
*/
* Global libmount status.
*
* The real exit code of the mount.type helper has to be tested by
- * mnt_context_get_helper_status(). The mnt_context_get_status() only inform
+ * mnt_context_get_helper_status(). The mnt_context_get_status() only informs
* that exec() has been successful.
*
* Returns: 1 if mount.type or mount(2) syscall has been successfully called.
*
* The @status should be 0 on success, or negative number on error (-errno).
*
- * This function should be used only if [u]mount(2) syscall is NOT called by
+ * This function should only be used if the [u]mount(2) syscall is NOT called by
* libmount code.
*
* Returns: 0 or negative number in case of error.
* @action: MNT_ACT_{UMOUNT,MOUNT}
* @flags: not used now
*
- * This function infors libmount that used from [u]mount.type helper.
+ * This function informs libmount that used from [u]mount.type helper.
*
* The function also calls mnt_context_disable_helpers() to avoid recursive
* mount.type helpers calling. It you really want to call another
- * mount.type helper from your helper than you have to explicitly enable this
+ * mount.type helper from your helper, then you have to explicitly enable this
* feature by:
*
* mnt_context_disable_helpers(cxt, FALSE);
* @c: getopt() result
* @arg: getopt() optarg
*
- * This function applies [u]mount.type command line option (for example parsed
+ * This function applies the [u]mount.type command line option (for example parsed
* by getopt or getopt_long) to @cxt. All unknown options are ignored and
* then 1 is returned.
*
* @fs: filesystem
* @mounted: returns 1 for mounted and 0 for non-mounted filesystems
*
- * Please, read mnt_table_is_fs_mounted() description!
+ * Please, read the mnt_table_is_fs_mounted() description!
*
* Returns: 0 on success and negative number in case of error.
*/
mnt_context_set_target(cxt, argv[idx++]);
}
- /* this is unnecessary! -- libmount is able to internaly
+ /* this is unnecessary! -- libmount is able to internally
* create and manage the lock
*/
lock = mnt_context_get_lock(cxt);
/* Automatically create a loop device from a regular file if a
* filesystem is not specified or the filesystem is known for libblkid
* (these filesystems work with block devices only). The file size
- * should be at least 1KiB otherwise we will create empty loopdev where
- * is no mountable filesystem...
+ * should be at least 1KiB, otherwise we will create an empty loopdev with
+ * no mountable filesystem...
*
- * Note that there is not a restriction (on kernel side) that prevents regular
+ * Note that there is no restriction (on kernel side) that would prevent a regular
* file as a mount(2) source argument. A filesystem that is able to mount
* regular files could be implemented.
*/
}
-/* Check, if there already exists a mounted loop device on the mountpoint node
+/* Check if there already exists a mounted loop device on the mountpoint node
* with the same parameters.
*/
static int __attribute__((nonnull))
cache = mnt_context_get_cache(cxt);
mnt_reset_iter(&itr, MNT_ITER_BACKWARD);
- /* Search for mountpoint node in mtab, procceed if any of these has the
+ /* Search for a mountpoint node in mtab, proceed if any of these have the
* loop option set or the device is a loop device
*/
while (mnt_table_next_fs(tb, &itr, &fs) == 0) {
if ((cxt->user_mountflags & MNT_MS_LOOP) &&
loopcxt_is_autoclear(&lc)) {
/*
- * autoclear flag accepted by kernel, don't store
+ * autoclear flag accepted by the kernel, don't store
* the "loop=" option to mtab.
*/
cxt->user_mountflags &= ~MNT_MS_LOOP;
mnt_context_set_mflags(cxt, cxt->mountflags | MS_RDONLY);
/* we have to keep the device open until mount(1),
- * otherwise it will auto-cleared by kernel
+ * otherwise it will be auto-cleared by kernel
*/
cxt->loopdev_fd = loopcxt_get_fd(&lc);
loopcxt_set_fd(&lc, -1, 0);
/*
* The "user" options is our business (so we can modify the option),
- * but exception is command line for /sbin/mount.<type> helpers. Let's
- * save the original user=<name> to call the helpers with unchanged
+ * the exception is command line for /sbin/mount.<type> helpers. Let's
+ * save the original user=<name> to call the helpers with an unchanged
* "user" setting.
*/
if (cxt->user_mountflags & MNT_MS_USER) {
}
/*
- * Converts already evaluated and fixed options to the form that is compatible
+ * Converts the already evaluated and fixed options to the form that is compatible
* with /sbin/mount.type helpers.
*/
static int generate_helper_optstr(struct libmnt_context *cxt, char **optstr)
if (cxt->user_mountflags & MNT_MS_USER) {
/*
* This is unnecessary for real user-mounts as mount.<type>
- * helpers have to always follow fstab rather than mount
- * options on command line.
+ * helpers always have to follow fstab rather than mount
+ * options on the command line.
*
- * But if you call mount.<type> as root then the helper follows
- * command line. If there is (for example) "user,exec" in fstab
+ * However, if you call mount.<type> as root, then the helper follows
+ * the command line. If there is (for example) "user,exec" in fstab,
* then we have to manually append the "exec" back to the options
- * string, bacause there is nothing like MS_EXEC (we have only
+ * string, bacause there is nothing like MS_EXEC (we only have
* MS_NOEXEC in mount flags and we don't care about the original
* mount string in libmount for VFS options).
*/
/*
* this has to be called before fix_optstr()
*
- * Note that user=<name> maybe be used by some filesystems as filesystem
+ * Note that user=<name> may be used by some filesystems as a filesystem
* specific option (e.g. cifs). Yes, developers of such filesystems have
* allocated pretty hot place in hell...
*/
/*
* mnt_context_helper_setopt() backend
*
- * This function applies mount.type command line option (for example parsed
+ * This function applies the mount.type command line option (for example parsed
* by getopt() or getopt_long()) to @cxt. All unknown options are ignored and
* then 1 is returned.
*
/*
* TODO: remove the exception for "nfs", -s is documented
- * for years should be usable everywhere.
+ * for years and should be usable everywhere.
*/
if (mnt_context_is_sloppy(cxt) &&
type && startswith(type, "nfs"))
return -EINVAL;
if (!src) {
/* unnecessary, should be already resolved in
- * mnt_context_prepare_srcpath(), but for sure... */
+ * mnt_context_prepare_srcpath(), but to be sure... */
DBG(CXT, mnt_debug_h(cxt, "WARNING: source is NULL -- using \"none\"!"));
src = "none";
}
* Call mount(2) or mount.type helper. Unnecessary for mnt_context_mount().
*
* Note that this function could be called only once. If you want to mount
- * another source or target than you have to call mnt_reset_context().
+ * another source or target, then you have to call mnt_reset_context().
*
- * If you want to call mount(2) for the same source and target with a different
- * mount flags or fstype then call mnt_context_reset_status() and then try
+ * If you want to call mount(2) for the same source and target with different
+ * mount flags or fstype, then call mnt_context_reset_status() and then try
* again mnt_context_do_mount().
*
* WARNING: non-zero return code does not mean that mount(2) syscall or
type = mnt_fs_get_fstype(cxt->fs);
if (type) {
if (strchr(type, ','))
- /* this only happens if fstab contains list of filesystems */
+ /* this only happens if fstab contains a list of filesystems */
res = do_mount_by_pattern(cxt, type);
else
res = do_mount(cxt, NULL);
* mnt_context_mount:
* @cxt: mount context
*
- * High-level, mounts filesystem by mount(2) or fork()+exec(/sbin/mount.type).
+ * High-level, mounts the filesystem by mount(2) or fork()+exec(/sbin/mount.type).
*
* This is similar to:
*
*
* See also mnt_context_disable_helpers().
*
- * Note that this function could be called only once. If you want to mount with
- * different setting than you have to call mnt_reset_context(). It's NOT enough
- * to call mnt_context_reset_status() if you want call this function more than
- * once, whole context has to be reseted.
+ * Note that this function should be called only once. If you want to mount with
+ * different settings, then you have to call mnt_reset_context(). It's NOT enough
+ * to call mnt_context_reset_status(). If you want to call this function more than
+ * once, the whole context has to be reset.
*
* WARNING: non-zero return code does not mean that mount(2) syscall or
* mount.type helper wasn't successfully called.
if (!rc)
rc = mnt_context_do_mount(cxt);
- /* TODO: if mtab update is expected then check if the
+ /* TODO: if a mtab update is expected, then check if the
* target is really mounted read-write to avoid 'ro' in
* mtab and 'rw' in /proc/mounts.
*/
* @itr: iterator
* @fs: returns the current filesystem
* @mntrc: returns the return code from mnt_context_mount()
- * @ignored: returns 1 for not matching and 2 for already mounted filesystems
+ * @ignored: returns 1 for non-matching and 2 for already mounted filesystems
*
* This function tries to mount the next filesystem from fstab (as returned by
* mnt_context_get_fstab()). See also mnt_context_set_fstab().
/* ignore noauto filesystems */
(o && mnt_optstr_get_option(o, "noauto", NULL, NULL) == 0) ||
- /* ignore filesystems not match with options patterns */
+ /* ignore filesystems which don't match options patterns */
(cxt->fstype_pattern && !mnt_fs_match_fstype(*fs,
cxt->fstype_pattern)) ||
- /* ignore filesystems not match with type patterns */
+ /* ignore filesystems which don't match type patterns */
(cxt->optstr_pattern && !mnt_fs_match_options(*fs,
cxt->optstr_pattern))) {
if (ignored)
* umount2 flags
*/
#ifndef MNT_FORCE
-# define MNT_FORCE 0x00000001 /* Attempt to forcibily umount */
+# define MNT_FORCE 0x00000001 /* Attempt to forcibly umount */
#endif
#ifndef MNT_DETACH
#endif
/*
- * Called by mtab parser to filter out entries, nonzero means that
- * entry has to be filter out.
+ * Called by mtab parser to filter out entries, non-zero means that
+ * an entry has to be filtered out.
*/
static int mtab_filter(struct libmnt_fs *fs, void *data)
{
DBG(CXT, mnt_debug_h(cxt, "umount: lookup FS for '%s'", tgt));
if (!*tgt)
- return 1; /* empty string is not error */
+ return 1; /* empty string is not an error */
/*
- * The mtab file maybe huge and on systems with utab we have to merge
+ * The mtab file may be huge and on systems with utab we have to merge
* userspace mount options into /proc/self/mountinfo. This all is
* expensive. The mtab filter allows to filter out entries, then
* mtab and utab are very tiny files.
*
* *but*... the filter uses mnt_fs_streq_{target,srcpath} functions
- * where LABEL, UUID or symlinks are to canonicalized. It means that
+ * where LABEL, UUID or symlinks are canonicalized. It means that
* it's usable only for canonicalized stuff (e.g. kernel mountinfo).
*/
if (!cxt->mtab_writable && *tgt == '/' &&
struct stat st;
if (stat(tgt, &st) == 0 && S_ISDIR(st.st_mode)) {
- /* we'll canonicalized /proc/self/mountinfo */
+ /* we'll canonicalize /proc/self/mountinfo */
cache = mnt_context_get_cache(cxt);
cn_tgt = mnt_resolve_path(tgt, cache);
if (cn_tgt)
if (!src)
return 0;
- /* check for offset option in @fs */
+ /* check for the offset option in @fs */
optstr = (char *) mnt_fs_get_user_options(fs);
if (optstr &&
}
/*
- * User mounts has to be in /etc/fstab
+ * User mounts have to be in /etc/fstab
*/
rc = mnt_context_get_fstab(cxt, &fstab);
if (rc)
* /dev/sda1 /mnt/zip auto user,noauto 0 0
* /dev/sda4 /mnt/zip auto user,noauto 0 0
* then "mount /dev/sda4" followed by "umount /mnt/zip" used to fail.
- * So, we must not look for file, but for the pair (dev,file) in fstab.
+ * So, we must not look for the file, but for the pair (dev,file) in fstab.
*/
fs = mnt_table_find_pair(fstab, src, tgt, MNT_ITER_FORWARD);
if (!fs) {
/*
* It's possible that there is /path/file.img in fstab and
- * /dev/loop0 in mtab -- then we have to check releation
+ * /dev/loop0 in mtab -- then we have to check the relation
* between loopdev and the file.
*/
fs = mnt_table_find_target(fstab, tgt, MNT_ITER_FORWARD);
return 0;
}
/*
- * Check user=<username> setting from mtab if there is user, owner or
+ * Check user=<username> setting from mtab if there is a user, owner or
* group option in /etc/fstab
*/
if (u_flags & (MNT_MS_USER | MNT_MS_OWNER | MNT_MS_GROUP)) {
return rc;
}
-/* Check whether the kernel supports UMOUNT_NOFOLLOW flag */
+/* Check whether the kernel supports the UMOUNT_NOFOLLOW flag */
static int umount_nofollow_support(void)
{
int res = umount2("", UMOUNT_UNUSED);
* mnt_context_set_options_pattern() to simulate umount -a -O pattern
* mnt_context_set_fstype_pattern() to simulate umount -a -t pattern
*
- * If the filesystem is not mounted or does not match defined criteria,
+ * If the filesystem is not mounted or does not match the defined criteria,
* then the function mnt_context_next_umount() returns zero, but the @ignored is
* non-zero. Note that the root filesystem is always ignored.
*
DBG(CXT, mnt_debug_h(cxt, "next-umount: trying %s", tgt));
- /* ignore filesystems not match with options patterns */
+ /* ignore filesystems which don't match options patterns */
if ((cxt->fstype_pattern && !mnt_fs_match_fstype(*fs,
cxt->fstype_pattern)) ||
- /* ignore filesystems not match with type patterns */
+ /* ignore filesystems which don't match type patterns */
(cxt->optstr_pattern && !mnt_fs_match_options(*fs,
cxt->optstr_pattern))) {
if (ignored)
char **n = (char **) (new + offset);
if (*n)
- return 0; /* already set, not overwrite */
+ return 0; /* already set, don't overwrite */
return update_str(n, *o);
}
* @src: source FS
*
* If @dest is NULL, then a new FS is allocated, if any @dest field is already
- * set then the field is NOT overwrited.
+ * set, then the field is NOT overwritten.
*
* This function does not copy userdata (se mnt_fs_set_userdata()). A new copy is
* not linked with any existing mnt_tab.
}
/*
- * Used by parser ONLY (@source has to be freed on error)
+ * Used by the parser ONLY (@source has to be freed on error)
*/
int __mnt_fs_set_source_ptr(struct libmnt_fs *fs, char *source)
{
* @fs: fs
* @path: source path
*
- * Compares @fs source path with @path. The tailing slash is ignored.
+ * Compares @fs source path with @path. The trailing slash is ignored.
* See also mnt_fs_match_source().
*
* Returns: 1 if @fs source path equal to @path, otherwise 0.
* @fs: fs
* @path: mount point
*
- * Compares @fs target path with @path. The tailing slash is ignored.
+ * Compares @fs target path with @path. The trailing slash is ignored.
* See also mnt_fs_match_target().
*
* Returns: 1 if @fs target path equal to @path, otherwise 0.
*
* "TAG" is NAME=VALUE (e.g. LABEL=foo)
*
- * The TAG is the first column in the fstab file. The TAG or "srcpath" has to
- * be always set for all entries.
+ * The TAG is the first column in the fstab file. The TAG or "srcpath" always has
+ * to be set for all entries.
*
* See also mnt_fs_get_source().
*
* </programlisting>
* </informalexample>
*
- * Returns: 0 on success or negative number in case that a TAG is not defined.
+ * Returns: 0 on success or negative number in case a TAG is not defined.
*/
int mnt_fs_get_tag(struct libmnt_fs *fs, const char **name, const char **value)
{
/**
* mnt_fs_get_propagation:
* @fs: mountinfo entry
- * @flags: returns propagation MS_* flags as present in mountinfo file
+ * @flags: returns propagation MS_* flags as present in the mountinfo file
*
- * Note that this function set @flags to zero if not found any propagation flag
- * in mountinfo file. The kernel default is MS_PRIVATE, this flag is not stored
+ * Note that this function sets @flags to zero if no propagation flags are found
+ * in the mountinfo file. The kernel default is MS_PRIVATE, this flag is not stored
* in the mountinfo file.
*
* Returns: 0 on success or negative number in case of error.
return fs ? fs->fstype : NULL;
}
-/* Used by struct libmnt_file parser only */
+/* Used by the struct libmnt_file parser only */
int __mnt_fs_set_fstype_ptr(struct libmnt_fs *fs, char *fstype)
{
assert(fs);
if (!strcmp(vfs, fs))
return strdup(vfs); /* e.g. "aaa" and "aaa" */
- /* leave space for leading "r[ow],", "," and trailing zero */
+ /* leave space for the leading "r[ow],", "," and the trailing zero */
sz = strlen(vfs) + strlen(fs) + 5;
res = malloc(sz);
if (!res)
* mnt_fs_strdup_options:
* @fs: fstab/mtab/mountinfo entry pointer
*
- * Merges all mount options (VFS, FS and userspace) to the one options string
+ * Merges all mount options (VFS, FS and userspace) to one options string
* and returns the result. This function does not modigy @fs.
*
* Returns: pointer to string (can be freed by free(3)) or NULL in case of error.
* @fs: fstab/mtab/mountinfo entry pointer
* @optstr: options string
*
- * Splits @optstr to VFS, FS and userspace mount options and update relevat
+ * Splits @optstr to VFS, FS and userspace mount options and updates relevant
* parts of @fs.
*
- * Returns: 0 on success, or negative number icase of error.
+ * Returns: 0 on success, or negative number in case of error.
*/
int mnt_fs_set_options(struct libmnt_fs *fs, const char *optstr)
{
* Parses (splits) @optstr and appends results to VFS, FS and userspace lists
* of options.
*
- * If @optstr is NULL then @fs is not modified and 0 is returned.
+ * If @optstr is NULL, then @fs is not modified and 0 is returned.
*
* Returns: 0 on success or negative number in case of error.
*/
* @fs: fstab/mtab/mountinfo entry
* @optstr: mount options
*
- * Parses (splits) @optstr and prepands results to VFS, FS and userspace lists
+ * Parses (splits) @optstr and prepends the results to VFS, FS and userspace lists
* of options.
*
- * If @optstr is NULL then @fs is not modified and 0 is returned.
+ * If @optstr is NULL, then @fs is not modified and 0 is returned.
*
* Returns: 0 on success or negative number in case of error.
*/
* @optstr: options string
*
* Sets mount attributes. The attributes are mount(2) and mount(8) independent
- * options, these options are not send to kernel and are not interpreted by
+ * options, these options are not sent to the kernel and are not interpreted by
* libmount. The attributes are stored in /run/mount/utab only.
*
- * The atrtributes are managed by libmount in userspace only. It's possible
+ * The attributes are managed by libmount in userspace only. It's possible
* that information stored in userspace will not be available for libmount
* after CLONE_FS unshare. Be careful, and don't use attributes if possible.
*
* mnt_fs_get_tid:
* @fs: /proc/tid/mountinfo entry
*
- * Returns: TID (task ID) for filesystems read from mountinfo file
+ * Returns: TID (task ID) for filesystems read from the mountinfo file
*/
pid_t mnt_fs_get_tid(struct libmnt_fs *fs)
{
* mnt_fs_get_option:
* @fs: fstab/mtab/mountinfo entry pointer
* @name: option name
- * @value: returns pointer to the begin of the value (e.g. name=VALUE) or NULL
+ * @value: returns pointer to the beginning of the value (e.g. name=VALUE) or NULL
* @valsz: returns size of options value or 0
*
- * Returns: 0 on success, 1 when not found the @name or negative number in case of error.
+ * Returns: 0 on success, 1 when @name not found or negative number in case of error.
*/
int mnt_fs_get_option(struct libmnt_fs *fs, const char *name,
char **value, size_t *valsz)
* mnt_fs_get_attribute:
* @fs: fstab/mtab/mountinfo entry pointer
* @name: option name
- * @value: returns pointer to the begin of the value (e.g. name=VALUE) or NULL
+ * @value: returns pointer to the beginning of the value (e.g. name=VALUE) or NULL
* @valsz: returns size of options value or 0
*
- * Returns: 0 on success, 1 when not found the @name or negative number in case of error.
+ * Returns: 0 on success, 1 when @name not found or negative number in case of error.
*/
int mnt_fs_get_attribute(struct libmnt_fs *fs, const char *name,
char **value, size_t *valsz)
* @comm: comment string
*
* Note that the comment has to be terminated by '\n' (new line), otherwise
- * whole filesystem entry will be written as a comment to the tabfile (e.g.
+ * the whole filesystem entry will be written as a comment to the tabfile (e.g.
* fstab).
*
* Returns: 0 on success or <0 in case of error.
*
* The 2nd and 3rd attempts are not performed when @cache is NULL.
*
- * Returns: 1 if @fs target is equal to @target else 0.
+ * Returns: 1 if @fs target is equal to @target, else 0.
*/
int mnt_fs_match_target(struct libmnt_fs *fs, const char *target,
struct libmnt_cache *cache)
* @source: tag or path (device or so) or NULL
* @cache: tags/paths cache or NULL
*
- * Possible are four attempts:
+ * Four attempts are possible:
* 1) compare @source with @fs->source
* 2) compare realpath(@source) with @fs->source
* 3) compare realpath(@source) with realpath(@fs->source)
* The 2nd, 3rd and 4th attempts are not performed when @cache is NULL. The
* 2nd and 3rd attempts are not performed if @fs->source is tag.
*
- * Returns: 1 if @fs source is equal to @source else 0.
+ * Returns: 1 if @fs source is equal to @source, else 0.
*/
int mnt_fs_match_source(struct libmnt_fs *fs, const char *source,
struct libmnt_cache *cache)
return 1;
}
if (src || mnt_fs_get_tag(fs, &t, &v))
- /* src path does not match and tag is not defined */
+ /* src path does not match and the tag is not defined */
return 0;
/* read @source's tags to the cache */
if (mnt_cache_read_tags(cache, cn) < 0) {
if (errno == EACCES) {
/* we don't have permissions to read TAGs from
- * @source, but can translate @fs tag to devname.
+ * @source, but can translate the @fs tag to devname.
*
* (because libblkid uses udev symlinks and this is
* accessible for non-root uses)
return 0;
}
- /* 4) has the @source a tag that matches with tag from @fs ? */
+ /* 4) has the @source a tag that matches with the tag from @fs ? */
if (mnt_cache_device_has_tag(cache, cn, t, v))
return 1;
*
* For more details see mnt_match_fstype().
*
- * Returns: 1 if @fs type is matching to @types else 0. The function returns
+ * Returns: 1 if @fs type is matching to @types, else 0. The function returns
* 0 when types is NULL.
*/
int mnt_fs_match_fstype(struct libmnt_fs *fs, const char *types)
*
* For more details see mnt_match_options().
*
- * Returns: 1 if @fs type is matching to @options else 0. The function returns
+ * Returns: 1 if @fs type is matching to @options, else 0. The function returns
* 0 when types is NULL.
*/
int mnt_fs_match_options(struct libmnt_fs *fs, const char *options)
* mnt_free_mntent:
* @mnt: mount entry
*
- * Deallocates "mntent.h" mount entry.
+ * Deallocates the "mntent.h" mount entry.
*/
void mnt_free_mntent(struct mntent *mnt)
{
* @fs: filesystem
* @mnt: mount description (as described in mntent.h)
*
- * Copies information from @fs to struct mntent @mnt. If @mnt is already set
+ * Copies the information from @fs to struct mntent @mnt. If @mnt is already set,
* then the struct mntent items are reallocated and updated. See also
* mnt_free_mntent().
*
- * Returns: 0 on success and negative number in case of error.
+ * Returns: 0 on success and a negative number in case of error.
*/
int mnt_fs_to_mntent(struct libmnt_fs *fs, struct mntent **mnt)
{
/**
* SECTION: init
* @title: Library initialization
- * @short_description: initialize debuging
+ * @short_description: initialize debugging
*/
#include <stdarg.h>
/**
* mnt_init_debug:
- * @mask: debug mask (0xffff to enable full debuging)
+ * @mask: debug mask (0xffff to enable full debugging)
*
- * If the @mask is not specified then this function reads
- * LIBMOUNT_DEBUG environment variable to get the mask.
+ * If the @mask is not specified, then this function reads
+ * the LIBMOUNT_DEBUG environment variable to get the mask.
*
- * Already initialized debugging stuff cannot be changed. It does not
- * have effect to call this function twice.
+ * Already initialized debugging stuff cannot be changed. Calling
+ * this function twice has no effect.
*/
void mnt_init_debug(int mask)
{
* @title: Iterator
* @short_description: unified iterator
*
- * The iterator keeps direction and last position for access to the internal
- * library tables/lists.
+ * The iterator keeps the direction and the last position
+ * for access to the internal library tables/lists.
*/
#include <stdio.h>
#include <string.h>
* mnt_free_iter:
* @itr: iterator pointer
*
- * Deallocates iterator.
+ * Deallocates the iterator.
*/
void mnt_free_iter(struct libmnt_iter *itr)
{
/**
* mnt_reset_iter:
* @itr: iterator pointer
- * @direction: MNT_INTER_{FOR,BACK}WARD or -1 to keep the derection unchanged
+ * @direction: MNT_INTER_{FOR,BACK}WARD or -1 to keep the direction unchanged
*
- * Resets iterator.
+ * Resets the iterator.
*/
void mnt_reset_iter(struct libmnt_iter *itr, int direction)
{
/**
* libmnt_lock:
*
- * Stores information about locked file (e.g. /etc/mtab)
+ * Stores information about the locked file (e.g. /etc/mtab)
*/
struct libmnt_lock;
#define MS_NODIRATIME 0x800 /* 2048: Don't update directory access times */
#endif
#ifndef MS_BIND
-#define MS_BIND 0x1000 /* 4096: Mount existing tree also elsewhere */
+#define MS_BIND 0x1000 /* 4096: Mount existing tree elsewhere as well */
#endif
#ifndef MS_MOVE
-#define MS_MOVE 0x2000 /* 8192: Atomically move tree */
+#define MS_MOVE 0x2000 /* 8192: Atomically move the tree */
#endif
#ifndef MS_REC
#define MS_REC 0x4000 /* 16384: Recursive loopback */
* @title: Locking
* @short_description: locking methods for /etc/mtab or another libmount files
*
- * The mtab lock is backwardly compatible with the standard linux /etc/mtab
+ * The mtab lock is backwards compatible with the standard linux /etc/mtab
* locking. Note, it's necessary to use the same locking schema in all
- * application that access the file.
+ * applications that access the file.
*/
#include <sys/time.h>
#include <time.h>
/*
* Waits for F_SETLKW, unfortunately we have to use SIGALRM here to interrupt
- * fcntl() to avoid never ending waiting.
+ * fcntl() to avoid neverending waiting.
*
* Returns: 0 on success, 1 on timeout, -errno on error.
*/
* soon as the lock file is deleted by the first mount, and immediately
* afterwards a third mount comes, creates a new /etc/mtab~, applies
* flock to that, and also proceeds, so that the second and third mount
- * now both are scribbling in /etc/mtab.
+ * are now both scribbling in /etc/mtab.
*
* The new code uses a link() instead of a creat(), where we proceed
* only if it was us that created the lock, and hence we always have
* The original mount locking code has used sleep(1) between attempts and
* maximal number of attempts has been 5.
*
- * There was very small number of attempts and extremely long waiting (1s)
+ * There was a very small number of attempts and extremely long waiting (1s)
* that is useless on machines with large number of mount processes.
*
- * Now we wait few thousand microseconds between attempts and we have a global
- * time limit (30s) rather than limit for number of attempts. The advantage
+ * Now we wait for a few thousand microseconds between attempts and we have a global
+ * time limit (30s) rather than a limit for the number of attempts. The advantage
* is that this method also counts time which we spend in fcntl(F_SETLKW) and
- * number of attempts is not restricted.
+ * the number of attempts is not restricted.
* -- kzak@redhat.com [Mar-2007]
*
*
* -- kzak@redhat.com [May-2009]
*/
-/* maximum seconds between first and last attempt */
+/* maximum seconds between the first and the last attempt */
#define MOUNTLOCK_MAXTIME 30
/* sleep time (in microseconds, max=999999) between attempts */
if (!ml->locked && ml->lockfile && ml->linkfile)
{
- /* We have (probably) all files, but we don't own the lock,
+ /* We (probably) have all the files, but we don't own the lock,
* Really? Check it! Maybe ml->locked wasn't set properly
- * because code was interrupted by signal. Paranoia? Yes.
+ * because the code was interrupted by a signal. Paranoia? Yes.
*
* We own the lock when linkfile == lockfile.
*/
* mnt_lock_file
* @ml: pointer to struct libmnt_lock instance
*
- * Creates lock file (e.g. /etc/mtab~). Note that this function may
+ * Creates a lock file (e.g. /etc/mtab~). Note that this function may
* use alarm().
*
- * Your application has to always call mnt_unlock_file() before exit.
+ * Your application always has to call mnt_unlock_file() before exit.
*
* Traditional mtab locking scheme:
*
* mnt_unlock_file:
* @ml: lock struct
*
- * Unlocks the file. The function could be called independently on the
+ * Unlocks the file. The function could be called independently of the
* lock status (for example from exit(3)).
*/
void mnt_unlock_file(struct libmnt_lock *ml)
mnt_free_lock(lock);
lock = NULL;
- /* The mount command usually finish after mtab update. We
+ /* The mount command usually finishes after a mtab update. We
* simulate this via short sleep -- it's also enough to make
* concurrent processes happy.
*/
/*
- * This struct represents one entry in mtab/fstab/mountinfo file.
+ * This struct represents one entry in a mtab/fstab/mountinfo file.
* (note that fstab[1] means the first column from fstab, and so on...)
*/
struct libmnt_fs {
struct list_head ents; /* list of entries (libmnt_fs) */
+ void *userdata;
};
extern struct libmnt_table *__mnt_new_table_from_file(const char *filename, int fmt);
#define MNT_FL_SAVED_USER (1 << 23)
#define MNT_FL_PREPARED (1 << 24)
#define MNT_FL_HELPER (1 << 25) /* [u]mount.<type> */
-#define MNT_FL_LOOPDEV_READY (1 << 26) /* /dev/loop<N> initialized by library */
+#define MNT_FL_LOOPDEV_READY (1 << 26) /* /dev/loop<N> initialized by the library */
#define MNT_FL_MOUNTOPTS_FIXED (1 << 27)
/* default flags */
{ "dirsync", MS_DIRSYNC }, /* synchronous directory modifications */
{ "remount", MS_REMOUNT, MNT_NOMTAB }, /* alter flags of mounted FS */
- { "bind", MS_BIND }, /* Remount part of tree elsewhere */
+ { "bind", MS_BIND }, /* Remount part of the tree elsewhere */
{ "rbind", MS_BIND | MS_REC }, /* Idem, plus mounted subtrees */
#ifdef MS_NOSUB
{ "sub", MS_NOSUB, MNT_INVERT }, /* allow submounts */
{ "defaults", 0, 0 }, /* default options */
{ "auto", MNT_MS_NOAUTO, MNT_NOHLPS | MNT_INVERT | MNT_NOMTAB }, /* Can be mounted using -a */
- { "noauto", MNT_MS_NOAUTO, MNT_NOHLPS | MNT_NOMTAB }, /* Can only be mounted explicitly */
+ { "noauto", MNT_MS_NOAUTO, MNT_NOHLPS | MNT_NOMTAB }, /* Can only be mounted explicitly */
{ "user[=]", MNT_MS_USER }, /* Allow ordinary user to mount (mtab) */
{ "nouser", MNT_MS_USER, MNT_INVERT | MNT_NOMTAB }, /* Forbid ordinary user to mount */
{ "nogroup", MNT_MS_GROUP, MNT_INVERT | MNT_NOMTAB }, /* Device group has no special privs */
/*
- * Note that traditional init scripts assume _netdev option in /etc/mtab to
+ * Note that traditional init scripts assume the _netdev option in /etc/mtab to
* umount network block devices on shutdown.
*/
{ "_netdev", MNT_MS_NETDEV }, /* Device requires network */
}
/*
- * Lookups for the @name in @maps and returns a map and in @mapent
+ * Looks up the @name in @maps and returns a map and in @mapent
* returns the map entry
*/
const struct libmnt_optmap *mnt_optmap_get_entry(
/**
* SECTION: optstr
* @title: Options string
- * @short_description: low-level API for work with mount options
+ * @short_description: low-level API for working with mount options
*
- * This is simple and low-level API to work with mount options that are stored
- * in string.
+ * This is a simple and low-level API to working with mount options that are stored
+ * in a string.
*/
#include <ctype.h>
(e && (e)->name && !strchr((e)->name, '=') && !((e)->mask & MNT_PREFIX))
/*
- * Parses the first option from @optstr. The @optstr pointer is set to begin of
- * the next option.
+ * Parses the first option from @optstr. The @optstr pointer is set to the beginning
+ * of the next option.
*
* Returns -EINVAL on parse error, 1 at the end of optstr and 0 on success.
*/
for (p = optstr0; p && *p; p++) {
if (!start)
- start = p; /* begin of the option item */
+ start = p; /* beginning of the option item */
if (*p == '"')
open_quote ^= 1; /* reverse the status */
if (open_quote)
}
/*
- * Locates the first option that match with @name. The @end is set to
+ * Locates the first option that matches @name. The @end is set to the
* char behind the option (it means ',' or \0).
*
* Returns negative number on parse error, 1 when not found and 0 on success.
/**
* mnt_optstr_next_option:
- * @optstr: option string, returns position to next option
- * @name: returns option name
- * @namesz: returns option name length
- * @value: returns option value or NULL
- * @valuesz: returns option value length or zero
+ * @optstr: option string, returns the position of the next option
+ * @name: returns the option name
+ * @namesz: returns the option name length
+ * @value: returns the option value or NULL
+ * @valuesz: returns the option value length or zero
*
* Parses the first option in @optstr.
*
/**
* mnt_optstr_append_option:
- * @optstr: option string or NULL, returns reallocated string
+ * @optstr: option string or NULL, returns a reallocated string
* @name: value name
* @value: value
*
- * Returns: 0 on success or -1 in case of error. After error the @optstr should
+ * Returns: 0 on success or -1 in case of error. After an error the @optstr should
* be unmodified.
*/
int mnt_optstr_append_option(char **optstr, const char *name, const char *value)
/**
* mnt_optstr_prepend_option:
- * @optstr: option string or NULL, returns reallocated string
+ * @optstr: option string or NULL, returns a reallocated string
* @name: value name
* @value: value
*
- * Returns: 0 on success or -1 in case of error. After error the @optstr should
+ * Returns: 0 on success or -1 in case of error. After an error the @optstr should
* be unmodified.
*/
int mnt_optstr_prepend_option(char **optstr, const char *name, const char *value)
/**
* mnt_optstr_get_option:
- * @optstr: string with comma separated list of options
+ * @optstr: string with a comma separated list of options
* @name: requested option name
- * @value: returns pointer to the begin of the value (e.g. name=VALUE) or NULL
+ * @value: returns a pointer to the beginning of the value (e.g. name=VALUE) or NULL
* @valsz: returns size of the value or 0
*
* Returns: 0 on success, 1 when not found the @name or negative number in case
/**
* mnt_optstr_deduplicate_option:
- * @optstr: string with comma separated list of options
+ * @optstr: string with a comma separated list of options
* @name: requested option name
*
* Removes all instances of @name except the last one.
rc = mnt_optstr_locate_option(opt, name, &ol);
if (!rc) {
if (begin) {
- /* remove previous instance */
+ /* remove the previous instance */
size_t shift = strlen(*optstr);
mnt_optstr_remove_option_at(optstr, begin, end);
- /* now all offset are not valied anymore - recount */
+ /* now all the offsets are not valid anymore - recount */
shift -= strlen(*optstr);
ol.begin -= shift;
ol.end -= shift;
}
/*
- * The result never starts or ends with comma or contains two commas
+ * The result never starts or ends with a comma or contains two commas
* (e.g. ",aaa,bbb" or "aaa,,bbb" or "aaa,")
*/
int mnt_optstr_remove_option_at(char **optstr, char *begin, char *end)
/* is it necessary to prepend '=' before the substring ? */
sep = !(pos > *str && *(pos - 1) == '=');
- /* save an offset of the place where we need add substr */
+ /* save an offset of the place where we need to add substr */
posoff = pos - *str;
p = realloc(*str, strsz + sep + subsz + 1);
if (!p)
return -ENOMEM;
- /* zeroize new allocated memory -- valgind loves is... */
+ /* zeroize the newly allocated memory -- valgrind loves us... */
memset(p + strsz, 0, sep + subsz + 1);
/* set pointers to the reallocated string */
pos = p + posoff;
if (possz)
- /* create a room for new substring */
+ /* create a room for the new substring */
memmove(pos + subsz + sep, pos, possz + 1);
if (sep)
*pos++ = '=';
/**
* mnt_optstr_set_option:
- * @optstr: string with comma separated list of options
+ * @optstr: string with a comma separated list of options
* @name: requested option
* @value: new value or NULL
*
- * Set or unset option @value.
+ * Set or unset the option @value.
*
* Returns: 0 on success, 1 when not found the @name or negative number in case
* of error.
/**
* mnt_optstr_remove_option:
- * @optstr: string with comma separated list of options
+ * @optstr: string with a comma separated list of options
* @name: requested option name
*
* Returns: 0 on success, 1 when not found the @name or negative number in case
*
* mnt_split_optstr(optstr, &u, NULL, NULL, MNT_NOMTAB, 0);
*
- * returns all userspace options, the options that does not belong to
+ * returns all userspace options, the options that do not belong to
* mtab are ignored.
*
* Note that FS options are all options that are undefined in MNT_USERSPACE_MAP
* or MNT_LINUX_MAP.
*
- * Returns: 0 on success, or negative number in case of error.
+ * Returns: 0 on success, or a negative number in case of error.
*/
int mnt_split_optstr(const char *optstr, char **user, char **vfs,
char **fs, int ignore_user, int ignore_vfs)
/**
* mnt_optstr_get_options
- * @optstr: string with comma separated list of options
+ * @optstr: string with a comma separated list of options
* @subset: returns newly allocated string with options
* @map: options map
* @ignore: mask of the options that should be ignored
*
- * Extracts options from @optstr that belongs to the @map, for example:
+ * Extracts options from @optstr that belong to the @map, for example:
*
* mnt_optstr_get_options(optstr, &p,
* mnt_get_builtin_optmap(MNT_LINUX_MAP),
* MNT_NOMTAB);
*
- * the 'p' returns all VFS options, the options that does not belong to mtab
+ * the 'p' returns all VFS options, the options that do not belong to mtab
* are ignored.
*
- * Returns: 0 on success, or negative number in case of error.
+ * Returns: 0 on success, or a negative number in case of error.
*/
int mnt_optstr_get_options(const char *optstr, char **subset,
const struct libmnt_optmap *map, int ignore)
*
* "bind,noexec,foo,bar" --returns-> MS_BIND|MS_NOEXEC
*
- * Note that @flags are not zeroized by this function! This function set/unset
- * bites in the @flags only.
+ * Note that @flags are not zeroized by this function! This function sets/unsets
+ * bits in the @flags only.
*
* Returns: 0 on success or negative number in case of error
*/
fl = flags;
/*
- * There is a convetion that 'rw/ro' flags is always at the begin of
- * the string (athough the 'rw' is unnecessary).
+ * There is a convention that 'rw/ro' flags are always at the beginning of
+ * the string (although the 'rw' is unnecessary).
*/
if (map == mnt_get_builtin_optmap(MNT_LINUX_MAP)) {
const char *o = (fl & MS_RDONLY) ? "ro" : "rw";
if (next && *next) {
/*
* scan @optstr and remove options that are missing in
- * the @flags
+ * @flags
*/
while(!mnt_optstr_next_option(&next, &name, &namesz,
&val, &valsz)) {
* modify @optstr and returns zero if libmount is compiled without SELinux
* support.
*
- * Returns: 0 on success, negative number in case of error.
+ * Returns: 0 on success, a negative number in case of error.
*/
#ifndef HAVE_LIBSELINUX
int mnt_optstr_fix_secontext(char **optstr __attribute__ ((__unused__)),
return -EINVAL;
- /* create quoted string from the raw context */
+ /* create a quoted string from the raw context */
sz = strlen((char *) raw);
if (!sz)
return -EINVAL;
}
/*
- * @optstr: string with comma separated list of options
- * @value: pointer to the begin of the uid value
+ * @optstr: string with a comma separated list of options
+ * @value: pointer to the beginning of the uid value
* @valsz: size of the value
* @next: returns pointer to the next option (optional argument)
* if (!mnt_optstr_get_option(optstr, "uid", &val, &valsz))
* mnt_optstr_fix_uid(&optstr, val, valsz, NULL);
*
- * Returns: 0 on success, negative number in case of error.
+ * Returns: 0 on success, a negative number in case of error.
*/
int mnt_optstr_fix_uid(char **optstr, char *value, size_t valsz, char **next)
{
}
/*
- * @optstr: string with comma separated list of options
- * @value: pointer to the begin of the uid value
+ * @optstr: string with a comma separated list of options
+ * @value: pointer to the beginning of the uid value
* @valsz: size of the value
* @next: returns pointer to the next option (optional argument)
* Translates "groupname" or "usergid" to the real GID.
*
- * Returns: 0 on success, negative number in case of error.
+ * Returns: 0 on success, a negative number in case of error.
*/
int mnt_optstr_fix_gid(char **optstr, char *value, size_t valsz, char **next)
{
{
struct libmnt_test tss[] = {
{ "--append", test_append, "<optstr> <name> [<value>] append value to optstr" },
- { "--prepend",test_prepend,"<optstr> <name> [<value>] prepend value to optstr" },
+ { "--prepend",test_prepend,"<optstr> <name> [<value>] prepend value to optstr" },
{ "--set", test_set, "<optstr> <name> [<value>] (un)set value" },
{ "--get", test_get, "<optstr> <name> search name in optstr" },
{ "--remove", test_remove, "<optstr> <name> remove name in optstr" },
* @short_description: container for entries from fstab, mtab or mountinfo
*
* Note that mnt_table_find_* functions are mount(8) compatible. These functions
- * try to find an entry in more iterations where the first attempt is always
+ * try to find an entry in more iterations, where the first attempt is always
* based on comparison with unmodified (non-canonicalized or un-evaluated)
- * paths or tags. For example fstab with two entries:
+ * paths or tags. For example a fstab with two entries:
* <informalexample>
* <programlisting>
* LABEL=foo /foo auto rw
* mnt_table_find_source(tb, "UUID=anyuuid", &fs);
* </programlisting>
* </informalexample>
- * will returns the first entry (if UUID matches with the device).
+ * will return the first entry (if UUID matches with the device).
*/
#include <blkid.h>
* mnt_reset_table:
* @tb: tab pointer
*
- * Dealocates all entries (filesystems) from the table
+ * Deallocates all entries (filesystems) from the table.
*
* Returns: 0 on success or negative number in case of error.
*/
* The initial (intro) file comment is accessible by
* mnt_table_get_intro_comment(). The intro and the comment of the first fstab
* entry has to be separated by blank line. The filesystem comments are
- * accessible by mnt_fs_get_comment(). The tailing fstab comment is accessible
+ * accessible by mnt_fs_get_comment(). The trailing fstab comment is accessible
* by mnt_table_get_trailing_comment().
*
* <informalexample>
* @tb: pointer to tab
* @comm: comment or NULL
*
- * Sets initial comment in tb.
+ * Sets the initial comment in tb.
*
* Returns: 0 on success or negative number in case of error.
*/
* mnt_table_get_trailing_comment:
* @tb: pointer to tab
*
- * Returns: table tailing comment
+ * Returns: table trailing comment
*/
const char *mnt_table_get_trailing_comment(struct libmnt_table *tb)
{
* @tb: pointer to tab
* @comm: comment string
*
- * Sets tailing comment in table.
+ * Sets the trailing comment in table.
*
* Returns: 0 on success or negative number in case of error.
*/
* @tb: pointer to tab
* @comm: comment of NULL
*
- * Appends to the tailing table comment.
+ * Appends to the trailing table comment.
*
* Returns: 0 on success or negative number in case of error.
*/
* @tb: pointer to tab
* @mpc: pointer to struct libmnt_cache instance
*
- * Setups a cache for canonicalized paths and evaluated tags (LABEL/UUID). The
+ * Sets up a cache for canonicalized paths and evaluated tags (LABEL/UUID). The
* cache is recommended for mnt_table_find_*() functions.
*
* The cache could be shared between more tabs. Be careful when you share the
* @tb: mountinfo file (/proc/self/mountinfo)
* @root: returns pointer to the root filesystem (/)
*
- * The function uses parent ID from mountinfo file to determine root filesystem
+ * The function uses the parent ID from the mountinfo file to determine the root filesystem
* (the filesystem with the smallest ID). The function is designed mostly for
- * applications where is necessary to sort mountpoints by IDs to get the tree
+ * applications where it is necessary to sort mountpoints by IDs to get the tree
* of the mountpoints (e.g. findmnt default output).
*
- * If you're not sure than use
+ * If you're not sure, then use
*
* mnt_table_find_target(tb, "/", MNT_ITER_BACKWARD);
*
- * this is more robust and usable for arbitrary tab file (including fstab).
+ * this is more robust and usable for arbitrary tab files (including fstab).
*
- * Returns: 0 on success or less then zero case of error.
+ * Returns: 0 on success or negative number in case of error.
*/
int mnt_table_get_root_fs(struct libmnt_table *tb, struct libmnt_fs **root)
{
while(mnt_table_next_fs(tb, &itr, &fs) == 0) {
int id = mnt_fs_get_parent_id(fs);
if (!id)
- break; /* @tab is not mountinfo file? */
+ break; /* @tab is not a mountinfo file? */
if (!*root || id < root_id) {
*root = fs;
* @parent: parental FS
* @chld: returns the next child filesystem
*
- * Note that filesystems are returned in the order how was mounted (according to
+ * Note that filesystems are returned in the order of mounting (according to
* IDs in /proc/self/mountinfo).
*
- * Returns: 0 on success, negative number in case of error or 1 at end of list.
+ * Returns: 0 on success, negative number in case of error or 1 at the end of list.
*/
int mnt_table_next_child_fs(struct libmnt_table *tb, struct libmnt_iter *itr,
struct libmnt_fs *parent, struct libmnt_fs **chld)
id = mnt_fs_get_id(fs);
- /* avoid infinite loop. This only happens in rare cases
+ /* avoid an infinite loop. This only happens in rare cases
* such as in early userspace when the rootfs is its own parent */
if (id == parent_id)
continue;
* @itr: iterator
* @fs: returns the next tab entry
*
- * Returns: 0 on success, negative number in case of error or 1 at end of list.
+ * Returns: 0 on success, negative number in case of error or 1 at the end of list.
*
* Example:
* <informalexample>
* </programlisting>
* </informalexample>
*
- * lists all mountpoints from fstab in backward order.
+ * lists all mountpoints from fstab in reverse order.
*/
int mnt_table_next_fs(struct libmnt_table *tb, struct libmnt_iter *itr, struct libmnt_fs **fs)
{
* mnt_table_find_next_fs:
* @tb: table
* @itr: iterator
- * @match_func: function returns 1 or 0
+ * @match_func: function returning 1 or 0
* @userdata: extra data for match_func
* @fs: returns pointer to the next matching table entry
*
- * This function allows search in @tb.
+ * This function allows searching in @tb.
*
* Returns: negative number in case of error, 1 at end of table or 0 o success.
*/
* @path: directory
* @direction: MNT_ITER_{FORWARD,BACKWARD}
*
- * Same like mnt_get_mountpoint(), but this function does not rely on
+ * Same as mnt_get_mountpoint(), except this function does not rely on
* st_dev numbers.
*
* Returns: a tab entry or NULL.
* @path: mountpoint directory
* @direction: MNT_ITER_{FORWARD,BACKWARD}
*
- * Try to lookup an entry in given tab, possible are three iterations, first
- * with @path, second with realpath(@path) and third with realpath(@path)
+ * Try to lookup an entry in the given tab, three iterations are possible, the first
+ * with @path, the second with realpath(@path) and the third with realpath(@path)
* against realpath(fs->target). The 2nd and 3rd iterations are not performed
- * when @tb cache is not set (see mnt_table_set_cache()).
+ * when the @tb cache is not set (see mnt_table_set_cache()).
*
* Returns: a tab entry or NULL.
*/
/* non-canonicaled path in struct libmnt_table
* -- note that mountpoint in /proc/self/mountinfo is already
- * canonicalized by kernel
+ * canonicalized by the kernel
*/
mnt_reset_iter(&itr, direction);
while(mnt_table_next_fs(tb, &itr, &fs) == 0) {
* @path: source path (devname or dirname) or NULL
* @direction: MNT_ITER_{FORWARD,BACKWARD}
*
- * Try to lookup an entry in given tab, possible are four iterations, first
- * with @path, second with realpath(@path), third with tags (LABEL, UUID, ..)
- * from @path and fourth with realpath(@path) against realpath(entry->srcpath).
+ * Try to lookup an entry in the given tab, four iterations are possible, the first
+ * with @path, the second with realpath(@path), the third with tags (LABEL, UUID, ..)
+ * from @path and the fourth with realpath(@path) against realpath(entry->srcpath).
*
- * The 2nd, 3rd and 4th iterations are not performed when @tb cache is not
+ * The 2nd, 3rd and 4th iterations are not performed when the @tb cache is not
* set (see mnt_table_set_cache()).
*
* Note that NULL is a valid source path; it will be replaced with "none". The
return fs;
}
} else if (rc < 0 && errno == EACCES) {
- /* @path is unaccessible, try evaluate all TAGs in @tb
+ /* @path is inaccessible, try evaluating all TAGs in @tb
* by udev symlinks -- this could be expensive on systems
- * with huge fstab/mtab */
+ * with a huge fstab/mtab */
while(mnt_table_next_fs(tb, &itr, &fs) == 0) {
const char *t, *v, *x;
if (mnt_fs_get_tag(fs, &t, &v))
* @val: tag value
* @direction: MNT_ITER_{FORWARD,BACKWARD}
*
- * Try to lookup an entry in given tab, first attempt is lookup by @tag and
+ * Try to lookup an entry in the given tab, the first attempt is to lookup by @tag and
* @val, for the second attempt the tag is evaluated (converted to the device
- * name) and mnt_table_find_srcpath() is preformed. The second attempt is not
+ * name) and mnt_table_find_srcpath() is performed. The second attempt is not
* performed when @tb cache is not set (see mnt_table_set_cache()).
* Returns: a tab entry or NULL.
* @source: TAG or path
* @direction: MNT_ITER_{FORWARD,BACKWARD}
*
- * This is high-level API for mnt_table_find_{srcpath,tag}. You needn't to care
- * about @source format (device, LABEL, UUID, ...). This function parses @source
- * and calls mnt_table_find_tag() or mnt_table_find_srcpath().
+ * This is a high-level API for mnt_table_find_{srcpath,tag}. You needn't care
+ * about the @source format (device, LABEL, UUID, ...). This function parses
+ * the @source and calls mnt_table_find_tag() or mnt_table_find_srcpath().
*
* Returns: a tab entry or NULL.
*/
* @direction: MNT_ITER_{FORWARD,BACKWARD}
*
* This function is implemented by mnt_fs_match_source() and
- * mnt_fs_match_target() functions. It means that this is more expensive that
+ * mnt_fs_match_target() functions. It means that this is more expensive than
* others mnt_table_find_* function, because every @tab entry is fully evaluated.
*
* Returns: a tab entry or NULL.
* @devno: device number
* @direction: MNT_ITER_{FORWARD,BACKWARD}
*
- * Note that zero could be valid device number for root pseudo filesystem (e.g.
+ * Note that zero could be a valid device number for the root pseudo filesystem (e.g.
* tmpfs).
*
* Returns: a tab entry or NULL.
* tb: /proc/self/mountinfo
* fs: filesystem
* mountflags: MS_BIND or 0
- * fsroot: fs-root that will be probably used in the mountinfo file
+ * fsroot: fs-root that will probably be used in the mountinfo file
* for @fs after mount(2)
*
* For btrfs subvolumes this function returns NULL, but @fsroot properly set.
}
/**
- * mnt_table_is_mounted:
+ * mnt_table_is_fs__mounted:
* @tb: /proc/self/mountinfo file
* @fstab_fs: /etc/fstab entry
*
* Checks if the @fstab_fs entry is already in the @tb table. The "swap" is
- * ignored. This function explicitly compares source, target and root of the
+ * ignored. This function explicitly compares the source, target and root of the
* filesystems.
*
* Note that source and target are canonicalized only if a cache for @tb is
* defined (see mnt_table_set_cache()). The target canonicalization may
- * triggers automount on autofs mountpoints!
+ * trigger automount on autofs mountpoints!
*
* Don't use it if you want to know if a device is mounted, just use
- * mnt_table_find_source() for the device.
+ * mnt_table_find_source() on the device.
*
* This function is designed mostly for "mount -a".
*
}
/*
- * Compare target, try to minimize number of situations when we
+ * Compare target, try to minimize the number of situations when we
* need to canonicalize the path to avoid readlink() on
* mountpoints.
*/
{
fprintf(stderr, "%s:%d: parse error\n", filename, line);
- return 1; /* all errors are recoverable -- this is default */
+ return 1; /* all errors are recoverable -- this is the default */
}
struct libmnt_table *create_table(const char *file, int comments)
int nchanges; /* number of changes */
struct list_head changes; /* list with modified entries */
- struct list_head unused; /* list with unuused entries */
+ struct list_head unused; /* list with unused entries */
};
/**
*
* The options @old_fs, @new_fs and @oper are optional.
*
- * Returns: 0 on success, negative number in case of error or 1 at end of list.
+ * Returns: 0 on success, negative number in case of error or 1 at the end of list.
*/
int mnt_tabdiff_next_change(struct libmnt_tabdiff *df, struct libmnt_iter *itr,
struct libmnt_fs **old_fs, struct libmnt_fs **new_fs, int *oper)
{
assert(df);
- DBG(DIFF, mnt_debug_h(df, "reseting"));
+ DBG(DIFF, mnt_debug_h(df, "resetting"));
- /* zeroize all entries and move them to the list of unuused
+ /* zeroize all entries and move them to the list of unused
*/
while (!list_empty(&df->changes)) {
struct tabdiff_entry *de = list_entry(df->changes.next,
*s = end;
- /* valid end of number is space or terminator */
+ /* valid end of number is a space or a terminator */
if (*end == ' ' || *end == '\t' || *end == '\0')
return 0;
return -1;
if (optstr && *optstr)
unmangle_string(optstr);
- /* note that __foo functions does not reallocate the string
+ /* note that __foo functions do not reallocate the string
*/
rc = __mnt_fs_set_source_ptr(fs, src);
if (!rc) {
}
/*
- * Parses one line from mountinfo file
+ * Parses one line from a mountinfo file
*/
static int mnt_parse_mountinfo_line(struct libmnt_fs *fs, char *s)
{
/* (7) optional fields, terminated by " - " */
p = strstr(s, " - ");
if (!p) {
- DBG(TAB, mnt_debug("mountinfo parse error: not found separator"));
+ DBG(TAB, mnt_debug("mountinfo parse error: separator not found"));
return -EINVAL;
}
if (p > s + 1)
src = NULL;
}
- /* merge VFS and FS options to the one string */
+ /* merge VFS and FS options to one string */
fs->optstr = mnt_fs_strdup_options(fs);
if (!fs->optstr)
rc = -ENOMEM;
/*
* Returns {m,fs}tab or mountinfo file format (MNT_FMT_*)
*
- * Note that we aren't trying to guess utab file format, because this file has
- * to be always parsed by private libmount routines with explicitly defined
+ * Note that we aren't trying to guess the utab file format, because this file
+ * always has to be parsed by private libmount routines with an explicitly defined
* format.
*
* mountinfo: "<number> <number> ... "
/*
* Reads the next line from the file.
*
- * Returns 0 if the line is comment
- * 1 if the line is not comment
+ * Returns 0 if the line is a comment
+ * 1 if the line is not a comment
* <0 on error
*/
static int next_comment_line(char *buf, size_t bufsz,
DBG(TAB, mnt_debug_h(tb, "appending %s comment",
intro ? "intro" :
- eof ? "tailing" : "fs"));
+ eof ? "trailing" : "fs"));
if (intro)
rc = mnt_table_append_intro_comment(tb, comm);
else if (eof) {
++*nlines;
s = strchr (buf, '\n');
if (!s) {
- /* Missing final newline? Otherwise extremely */
+ /* Missing final newline? Otherwise an extremely */
/* long line - assume file was corrupted */
if (feof(f)) {
DBG(TAB, mnt_debug_h(tb,
tb->fmt == MNT_FMT_FSTAB ? "tab" : "utab"));
/* by default all errors are recoverable, otherwise behavior depends on
- * errcb() function. See mnt_table_set_parser_errcb().
+ * the errcb() function. See mnt_table_set_parser_errcb().
*/
return tb->errcb ? tb->errcb(tb, filename, *nlines) : 1;
}
int rc = 0;
const char *src = mnt_fs_get_srcpath(fs);
- /* This is filesystem description from /proc, so we're in some process
+ /* This is a filesystem description from /proc, so we're in some process
* namespace. Let's remember the process PID.
*/
if (filename && *tid == -1)
* @tb: tab pointer
* @filename: file
*
- * Parses whole table (e.g. /etc/mtab) and appends new records to the @tab.
+ * Parses the whole table (e.g. /etc/mtab) and appends new records to the @tab.
*
* The libmount parser ignores broken (syntax error) lines, these lines are
- * reported to caller by errcb() function (see mnt_table_set_parser_errcb()).
+ * reported to the caller by the errcb() function (see mnt_table_set_parser_errcb()).
*
* Returns: 0 on success, negative number in case of error.
*/
if (n <= 0)
return 0;
- /* let use "at" functions rather than play crazy games with paths... */
+ /* let's use "at" functions rather than playing crazy games with paths... */
dir = opendir(dirname);
if (!dir) {
r = -errno;
*
* The directory:
* - files are sorted by strverscmp(3)
- * - files that starts with "." are ignored (e.g. ".10foo.fstab")
+ * - files that start with "." are ignored (e.g. ".10foo.fstab")
* - files without the ".fstab" extension are ignored
*
* Returns: 0 on success or negative number in case of error.
* @filename: /etc/{m,fs}tab or /proc/self/mountinfo path
*
* Same as mnt_new_table() + mnt_table_parse_file(). Use this function for private
- * files only. This function does not allow to use error callback, so you
+ * files only. This function does not allow using the error callback, so you
* cannot provide any feedback to end-users about broken records in files (e.g.
* fstab).
*
* @cb: pointer to callback function
*
* The error callback function is called by table parser (mnt_table_parse_file())
- * in case of syntax error. The callback function could be used for errors
+ * in case of a syntax error. The callback function could be used for error
* evaluation, libmount will continue/stop parsing according to callback return
* codes:
*
* <0 : fatal error (abort parsing)
- * 0 : success (parsing continue)
- * >0 : recoverable error (the line is ignored, parsing continue).
+ * 0 : success (parsing continues)
+ * >0 : recoverable error (the line is ignored, parsing continues).
*
* Returns: 0 on success or negative number in case of error.
*/
}
/*
- * Filter out entries during tab file parsing. If @cb returns 1 then the entry
+ * Filter out entries during tab file parsing. If @cb returns 1, then the entry
* is ignored.
*/
int mnt_table_set_parser_fltrcb(struct libmnt_table *tb,
* @filename: overwrites default (/etc/fstab or $LIBMOUNT_FSTAB) or NULL
*
* This function parses /etc/fstab and appends new lines to the @tab. If the
- * @filename is a directory then mnt_table_parse_dir() is called.
+ * @filename is a directory, then mnt_table_parse_dir() is called.
*
* See also mnt_table_set_parser_errcb().
*
}
/*
- * This function uses @uf to found corresponding record in @tb, then the record
+ * This function uses @uf to find a corresponding record in @tb, then the record
* from @tb is updated (user specific mount options are added).
*
* Note that @uf must contain only user specific mount options instead of
if (mnt_table_get_nents(tb) == 0)
return 0; /* empty, ignore utab */
/*
- * try to read user specific information from /run/mount/utabs
+ * try to read the user specific information from /run/mount/utabs
*/
utab = mnt_get_utab_path();
if (!utab || is_file_empty(utab))
mnt_reset_iter(&itr, MNT_ITER_BACKWARD);
- /* merge user options into mountinfo from kernel */
+ /* merge user options into mountinfo from the kernel */
while(mnt_table_next_fs(u_tb, &itr, &u_fs) == 0)
mnt_table_merge_user_fs(tb, u_fs);
}
* @title: Tables update
* @short_description: userspace mount information management
*
- * The struct libmnt_update provides abstraction to manage mount options in
- * userspace independently on system configuration. This low-level API works on
- * system with and without /etc/mtab. On systems without the regular /etc/mtab
- * file are userspace mount options (e.g. user=) stored to the /run/mount/utab
+ * The struct libmnt_update provides an abstraction to manage mount options in
+ * userspace independently of system configuration. This low-level API works on
+ * systems both with and without /etc/mtab. On systems without the regular /etc/mtab
+ * file, the userspace mount options (e.g. user=) are stored in the /run/mount/utab
* file.
*
* It's recommended to use high-level struct libmnt_context API.
* mnt_update_get_filename:
* @upd: update
*
- * This function returns file name (e.g. /etc/mtab) for the up-dated file.
+ * This function returns the file name (e.g. /etc/mtab) of the up-dated file.
*
* Returns: pointer to filename that will be updated or NULL in case of error.
*/
* @upd: update handler
*
* Returns: 1 if entry described by @upd is successfully prepared and will be
- * written to mtab/utab file.
+ * written to the mtab/utab file.
*/
int mnt_update_is_ready(struct libmnt_update *upd)
{
}
/*
- * Allocates utab entry (upd->fs) for mount/remount. This function should be
+ * Allocates an utab entry (upd->fs) for mount/remount. This function should be
* called *before* mount(2) syscall. The @fs is used as a read-only template.
*
- * Returns: 0 on success, negative number on error, 1 if utabs update is
+ * Returns: 0 on success, negative number on error, 1 if utab's update is
* unnecessary.
*/
static int utab_new_entry(struct libmnt_update *upd, struct libmnt_fs *fs,
/*
* Sets fs-root and fs-type to @upd->fs according to the @fs template and
- * @mountfalgs. For MS_BIND mountflag it reads information about source
+ * @mountfalgs. For MS_BIND mountflag it reads information about the source
* filesystem from /proc/self/mountinfo.
*/
static int set_fs_root(struct libmnt_update *upd, struct libmnt_fs *fs,
* @tb: parsed file (e.g. fstab)
* @filename: target
*
- * This function repaces @file by the new content from @tb.
+ * This function replaces @file by the new content from @tb.
*
* Returns: 0 on success, negative number on error.
*/
* High-level API to update /etc/mtab (or private /run/mount/utab file).
*
* The @lc lock is optional and will be created if necessary. Note that
- * the automatically created lock blocks all signals.
+ * an automatically created lock blocks all signals.
*
* See also mnt_lock_block_signals() and mnt_context_get_lock().
*
goto done;
}
- /* [... here should be mount(2) call ...] */
+ /* [... mount(2) call should be here...] */
rc = mnt_update_table(upd, NULL);
done:
int main(int argc, char *argv[])
{
struct libmnt_test tss[] = {
- { "--add", test_add, "<src> <target> <type> <options> add line to mtab" },
+ { "--add", test_add, "<src> <target> <type> <options> add a line to mtab" },
{ "--remove", test_remove, "<target> MS_REMOUNT mtab change" },
{ "--move", test_move, "<old_target> <target> MS_MOVE mtab change" },
{ "--remount",test_remount, "<target> <options> MS_REMOUNT mtab change" },
}
/*
- * Return 1 if the file does not accessible of empty
+ * Return 1 if the file is not accessible or empty
*/
int is_file_empty(const char *name)
{
}
/*
- * Note that the @target has to be absolute path (so at least "/"). The
- * @filename returns allocated buffer with last path component, for example:
+ * Note that the @target has to be an absolute path (so at least "/"). The
+ * @filename returns an allocated buffer with the last path component, for example:
*
* mnt_chdir_to_parent("/mnt/test", &buf) ==> chdir("/mnt"), buf="test"
*/
}
/*
- * Check if @path is on read-only filesystem independently on file permissions.
+ * Check if @path is on a read-only filesystem independently of file permissions.
*/
int mnt_is_readonly(const char *path)
{
* accessible for the current rUID. (Note that euidaccess(2) does not
* check for EROFS at all).
*
- * - for read-write filesystem with read-only VFS node (aka -o remount,ro,bind)
+ * - for a read-write filesystem with a read-only VFS node (aka -o remount,ro,bind)
*/
{
struct timespec times[2];
*
* Encode @str to be compatible with fstab/mtab
*
- * Returns: new allocated string or NULL in case of error.
+ * Returns: newly allocated string or NULL in case of error.
*/
char *mnt_mangle(const char *str)
{
*
* Decode @str from fstab/mtab
*
- * Returns: new allocated string or NULL in case of error.
+ * Returns: newly allocated string or NULL in case of error.
*/
char *mnt_unmangle(const char *str)
{
* @type: filesystem type
* @pattern: filesystem name or comma delimited list of names
*
- * The @pattern list of filesystem can be prefixed with a global
+ * The @pattern list of filesystems can be prefixed with a global
* "no" prefix to invert matching of the whole list. The "no" could
* also be used for individual items in the @pattern list. So,
* "nofoo,bar" has the same meaning as "nofoo,nobar".
* @optstr: options string
* @pattern: comma delimited list of options
*
- * The "no" could used for individual items in the @options list. The "no"
+ * The "no" could be used for individual items in the @options list. The "no"
* prefix does not have a global meaning.
*
* Unlike fs type matching, nonetdev,user and nonetdev,nouser have
* DIFFERENT meanings; each option is matched explicitly as specified.
*
- * The "no" prefix interpretation could be disable by "+" prefix, for example
- * "+noauto" matches if @optstr literally contains "noauto" string.
+ * The "no" prefix interpretation could be disabled by the "+" prefix, for example
+ * "+noauto" matches if @optstr literally contains the "noauto" string.
*
* "xxx,yyy,zzz" : "nozzz" -> False
*
}
/*
- * Always check @filesystems pointer!
+ * Always check the @filesystems pointer!
*
* man mount:
*
rc = get_filesystems(_PATH_PROC_FILESYSTEMS, filesystems, pattern);
if (rc == 1 && *filesystems)
- rc = 0; /* not found /proc/filesystems */
+ rc = 0; /* /proc/filesystems not found */
return rc;
}
}
/*
- * Returns allocated string with username or NULL.
+ * Returns an allocated string with username or NULL.
*/
char *mnt_get_username(const uid_t uid)
{
* @mtab: returns path to mtab
* @writable: returns 1 if the file is writable
*
- * If the file does not exist and @writable argument is not NULL then it will
- * try to create the file
+ * If the file does not exist and @writable argument is not NULL, then it will
+ * try to create the file.
*
* Returns: 1 if /etc/mtab is a regular file, and 0 in case of error (check
* errno for more details).
rc = lstat(filename, &st);
if (rc == 0) {
- /* file exist */
+ /* file exists */
if (S_ISREG(st.st_mode)) {
if (writable)
*writable = !try_write(filename);
/*
* Don't export this to libmount API -- utab is private library stuff.
*
- * If the file does not exist and @writable argument is not NULL then it will
+ * If the file does not exist and @writable argument is not NULL, then it will
* try to create the directory (e.g. /run/mount) and the file.
*
* Returns: 1 if utab is a regular file, and 0 in case of
rc = lstat(filename, &st);
if (rc == 0) {
- /* file exist */
+ /* file exists */
if (S_ISREG(st.st_mode)) {
if (writable)
*writable = !try_write(filename);
return 1;
}
- goto done; /* it's not regular file */
+ goto done; /* it's not a regular file */
}
if (writable) {
/**
* mnt_get_mtab_path:
*
- * This function returns *default* location of the mtab file. The result does
+ * This function returns the *default* location of the mtab file. The result does
* not have to be writable. See also mnt_has_regular_mtab().
*
* Returns: path to /etc/mtab or $LIBMOUNT_MTAB.
}
-/* returns file descriptor or -errno, @name returns uniques filename
+/* returns file descriptor or -errno, @name returns a unique filename
*/
int mnt_open_uniq_filename(const char *filename, char **name)
{
if (rc <= 0)
return -errno;
- /* This is for very old glibc and for compatibility with Posix where is
+ /* This is for very old glibc and for compatibility with Posix, which says
* nothing about mkstemp() mode. All sane glibc use secure mode (0600).
*/
oldmode = umask(S_IRGRP|S_IWGRP|S_IXGRP|
* This function finds the mountpoint that a given path resides in. @path
* should be canonicalized. The returned pointer should be freed by the caller.
*
- * Returns: allocated string with target of the mounted device or NULL on error
+ * Returns: allocated string with the target of the mounted device or NULL on error
*/
char *mnt_get_mountpoint(const char *path)
{
/*
* Search for @name kernel command parametr.
*
- * Returns newly allocated string with parameter argument if the @name is
+ * Returns newly allocated string with a parameter argument if the @name is
* specified as "name=" or returns pointer to @name or returns NULL if not
* found.
*
if (p != buf && !isblank(*(p - 1)))
continue; /* no space before the option */
if (!val && *(p + len) != '\0' && !isblank(*(p + len)))
- continue; /* no space behind the option */
+ continue; /* no space after the option */
if (val) {
char *v = p + len;
/**
* SECTION: version
* @title: Version functions
- * @short_description: functions to get library version.
+ * @short_description: functions to get the library version.
*/
#include <ctype.h>
/**
* mnt_get_library_features:
- * @features: returns pointer to the static array of strings, the array is
+ * @features: returns a pointer to the static array of strings, the array is
* terminated by NULL.
*
* Returns: number of items in the features array not including the last NULL,
- * or less then zero in case of error
+ * or less than zero in case of error
*
* Example:
* <informalexample>