libmount: read optional mountinfo fields
[kzak@redhat.com: - rename struct member and functions from "propagation" to "optional fields" - split the original patch - fix parser] Signed-off-by: Ondrej Oprala <ondrej.oprala@gmail.com> Signed-off-by: Karel Zak <kzak@redhat.com>
This commit is contained in:
parent
0770effc00
commit
e47a19312f
|
@ -169,6 +169,7 @@ mnt_fs_get_fs_options
|
|||
mnt_fs_get_fstype
|
||||
mnt_fs_get_id
|
||||
mnt_fs_get_option
|
||||
mnt_fs_get_optional_fields
|
||||
mnt_fs_get_options
|
||||
mnt_fs_get_parent_id
|
||||
mnt_fs_get_passno
|
||||
|
|
|
@ -691,6 +691,18 @@ const char *mnt_fs_get_options(struct libmnt_fs *fs)
|
|||
return fs ? fs->optstr : NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* mnt_fs_get_optional_fields
|
||||
* @fs: mountinfo entry pointer
|
||||
*
|
||||
* Returns: pointer to string with mountinfo optional fields
|
||||
* or NULL in case of error.
|
||||
*/
|
||||
const char *mnt_fs_get_optional_fields(struct libmnt_fs *fs)
|
||||
{
|
||||
assert(fs);
|
||||
return fs ? fs->opt_fields : NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* mnt_fs_set_options:
|
||||
|
@ -1394,6 +1406,8 @@ int mnt_fs_print_debug(struct libmnt_fs *fs, FILE *file)
|
|||
fprintf(file, "FS-opstr: %s\n", mnt_fs_get_fs_options(fs));
|
||||
if (mnt_fs_get_user_options(fs))
|
||||
fprintf(file, "user-optstr: %s\n", mnt_fs_get_user_options(fs));
|
||||
if (mnt_fs_get_optional_fields(fs))
|
||||
fprintf(file, "optional-fields: '%s'\n", mnt_fs_get_optional_fields(fs));
|
||||
if (mnt_fs_get_attributes(fs))
|
||||
fprintf(file, "attributes: %s\n", mnt_fs_get_attributes(fs));
|
||||
|
||||
|
|
|
@ -327,6 +327,9 @@ extern char *mnt_fs_strdup_options(struct libmnt_fs *fs)
|
|||
extern const char *mnt_fs_get_options(struct libmnt_fs *fs)
|
||||
__ul_attribute__((nonnull))
|
||||
__ul_attribute__((warn_unused_result));
|
||||
extern const char *mnt_fs_get_optional_fields(struct libmnt_fs *fs)
|
||||
__ul_attribute__((nonnull))
|
||||
__ul_attribute__((warn_unused_result));
|
||||
extern int mnt_fs_set_options(struct libmnt_fs *fs, const char *optstr);
|
||||
extern int mnt_fs_append_options(struct libmnt_fs *fs, const char *optstr);
|
||||
extern int mnt_fs_prepend_options(struct libmnt_fs *fs, const char *optstr);
|
||||
|
|
|
@ -248,3 +248,8 @@ global:
|
|||
mnt_table_find_devno;
|
||||
mnt_table_parse_swaps;
|
||||
} MOUNT_2.21;
|
||||
|
||||
MOUNT_2.23 {
|
||||
global:
|
||||
mnt_fs_get_optional_fields;
|
||||
} MOUNT_2.22;
|
||||
|
|
|
@ -217,6 +217,7 @@ struct libmnt_fs {
|
|||
|
||||
char *optstr; /* fstab[4], merged options */
|
||||
char *vfs_optstr; /* mountinfo[6]: fs-independent (VFS) options */
|
||||
char *opt_fields; /* mountinfo[7]: optional fields */
|
||||
char *fs_optstr; /* mountinfo[11]: fs-dependent options */
|
||||
char *user_optstr; /* userspace mount options */
|
||||
char *attrs; /* mount attributes */
|
||||
|
|
|
@ -161,6 +161,8 @@ static int mnt_parse_mountinfo_line(struct libmnt_fs *fs, char *s)
|
|||
DBG(TAB, mnt_debug("mountinfo parse error: not found separator"));
|
||||
return -EINVAL;
|
||||
}
|
||||
if (p > s + 1)
|
||||
fs->opt_fields = strndup(s + 1, p - s - 1);
|
||||
s = p + 3;
|
||||
|
||||
rc += sscanf(s, UL_SCNsA" " /* (8) FS type */
|
||||
|
|
Loading…
Reference in New Issue