n->mtab = o->utab;
mnt_ref_table(n->utab);
- if (o->tgt_prefix && !(n->tgt_prefix = strdup(o->tgt_prefix)))
+ if (strdup_between_structs(n, o, tgt_prefix))
goto failed;
- if (o->helper && !(n->helper = strdup(o->helper)))
+ if (strdup_between_structs(n, o, helper))
goto failed;
- if (o->orig_user && !(n->orig_user = strdup(o->orig_user)))
+ if (strdup_between_structs(n, o, orig_user))
goto failed;
n->mountflags = o->mountflags;
return 0;
}
+/* This function do NOT overwrite (replace) the string in @new, the string in
+ * the @new has to be NULL otherwise this is no-op */
static inline int cpy_str_at_offset(void *new, const void *old, size_t offset)
{
char **o = (char **) ((char *) old + offset);
if (!n)
return NULL;
- if (cpy_str_at_offset(n, fs, offsetof(struct libmnt_fs, source)))
+ if (strdup_between_structs(n, fs, source))
goto err;
- if (cpy_str_at_offset(n, fs, offsetof(struct libmnt_fs, target)))
+ if (strdup_between_structs(n, fs, target))
goto err;
- if (cpy_str_at_offset(n, fs, offsetof(struct libmnt_fs, fstype)))
+ if (strdup_between_structs(n, fs, fstype))
goto err;
if (fs->vfs_optstr) {
n->user_optstr = p;
}
- if (cpy_str_at_offset(n, fs, offsetof(struct libmnt_fs, fs_optstr)))
+ if (strdup_between_structs(n, fs, fs_optstr))
goto err;
/* we cannot copy original optstr, the new optstr has to be without