mirror of
https://github.com/sheumann/hush.git
synced 2024-10-12 01:24:10 +00:00
mount: fix "duplicate mount options in mtab" bug
This commit is contained in:
parent
c0975199be
commit
c889d2b786
@ -102,9 +102,27 @@ struct {
|
|||||||
static void append_mount_options(char **oldopts, char *newopts)
|
static void append_mount_options(char **oldopts, char *newopts)
|
||||||
{
|
{
|
||||||
if (*oldopts && **oldopts) {
|
if (*oldopts && **oldopts) {
|
||||||
char *temp = xasprintf("%s,%s",*oldopts,newopts);
|
/* do not insert options which are already there */
|
||||||
|
while (newopts[0]) {
|
||||||
|
char *p;
|
||||||
|
int len = strlen(newopts);
|
||||||
|
p = strchr(newopts, ',');
|
||||||
|
if (p) len = p - newopts;
|
||||||
|
p = *oldopts;
|
||||||
|
while (1) {
|
||||||
|
if (!strncmp(p,newopts,len) && (p[len]==',' || p[len]==0))
|
||||||
|
goto skip;
|
||||||
|
p = strchr(p,',');
|
||||||
|
if(!p) break;
|
||||||
|
p++;
|
||||||
|
}
|
||||||
|
p = xasprintf("%s,%.*s", *oldopts, len, newopts);
|
||||||
free(*oldopts);
|
free(*oldopts);
|
||||||
*oldopts = temp;
|
*oldopts = p;
|
||||||
|
skip:
|
||||||
|
newopts += len;
|
||||||
|
while (newopts[0] == ',') newopts++;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
if (ENABLE_FEATURE_CLEAN_UP) free(*oldopts);
|
if (ENABLE_FEATURE_CLEAN_UP) free(*oldopts);
|
||||||
*oldopts = xstrdup(newopts);
|
*oldopts = xstrdup(newopts);
|
||||||
|
Loading…
Reference in New Issue
Block a user