}
}
+/* returns whole option with name @optname from @src list */
static char *
get_option(const char *optname, const char *src, size_t *len)
{
return NULL;
}
+ /* If @list contains "user=peter" and @s is "user=", return "peter" */
+char *
+get_option_value(const char *list, const char *s)
+{
+ const char *t;
+ size_t n = strlen(s);
+
+ while (list && *list) {
+ if (strncmp(list, s, n) == 0) {
+ s = t = list + n;
+ while (*s && *s != ',')
+ s++;
+ return xstrndup(t, s-t);
+ }
+ while (*list && *list++ != ',') ;
+ }
+ return NULL;
+}
+
static int
cpy_option(const char *optname, char *dest, const char *src)
{
void unlock_mtab (void);
void update_mtab (const char *special, struct my_mntent *with);
+char *get_option_value(const char *list, const char *s);
+
#endif /* MOUNT_FSTAB_H */
if ((strstr(mc->m.mnt_opts, "loop=") ||
(stat(mc->m.mnt_fsname, &st) == 0 && S_ISREG(st.st_mode)))) {
- char *p = strstr(mc->m.mnt_opts, "offset=");
+ char *p = get_option_value(mc->m.mnt_opts, "offset=");
uintmax_t offset = 0;
- if (p && strtosize(p + 7, &offset) != 0) {
+ if (p && strtosize(p, &offset) != 0) {
if (verbose)
printf(_("mount: ignore %s "
"(unparsable offset= option)\n"),
mc->m.mnt_fsname);
return -1;
}
+ free(p);
if (is_mounted_same_loopfile(mc->m.mnt_dir, mc->m.mnt_fsname, offset))
goto yes;
}
return 0;
}
-/*
- * If list contains "user=peter" and we ask for "user=", return "peter"
- */
-static char *
-get_value(const char *list, const char *s) {
- const char *t;
- int n = strlen(s);
-
- while (list && *list) {
- if (strncmp(list, s, n) == 0) {
- s = t = list+n;
- while (*s && *s != ',')
- s++;
- return xstrndup(t, s-t);
- }
- while (*list && *list++ != ',') ;
- }
- return NULL;
-}
-
/* check if @mc contains a loop device which is associated
* with the @file in fs
*/
return 0;
/* check for offset option in fstab */
- p = get_value(fs->m.mnt_opts, "offset=");
+ p = get_option_value(fs->m.mnt_opts, "offset=");
if (p && strtosize(p, &offset)) {
if (verbose > 1)
printf(_("failed to parse 'offset=%s' options\n"), p);
char *uhelper = NULL;
if (mc->m.mnt_opts)
- uhelper = get_value(mc->m.mnt_opts, "uhelper=");
+ uhelper = get_option_value(mc->m.mnt_opts,
+ "uhelper=");
if (uhelper) {
int status = 0;
if (check_special_umountprog(arg, arg,
options = mc->m.mnt_opts;
if (!options)
options = "";
- mtab_user = get_value(options, "user=");
+ mtab_user = get_option_value(options, "user=");
if (user && mtab_user && streq (user, mtab_user))
ok = 1;