← Commit list

c889d2b78

Denis Vlasenko
Denis Vlasenko
2006-09-17
SOURCE BUG Duration: 79s

Subject

mount: fix "duplicate mount options in mtab" bug

SOURCE BUG

This commit was genuinely broken at the time (not related to our build system): scripts/config/mkconfigs.c (2005-08-01 - 2006-10-05 arasi) uretilen bbconfigopts.h icine .config satirlarini kacissiz, ham newline'larla gömüyordu - gecerli C degildi, busybox'un kendi bb_mkdep araci bile parse edemiyordu (7d219aab7 ile duzeltildi, mkconfigs shell scripte cevrildi)

→ Bu hatanin tam hikayesini ve duzeltme diffini gor

Binary

No binary (build failed)

Architecture & Compiler Flags

Architecture: x86_64-linux-gnu Compiler: gcc (Ubuntu 11.4.0-1ubuntu1~22.04.3) 11.4.0

—

Build Log

(log yok)

Commit Diff GitHub →

util-linux/mount.c+21 -3
@@ -102,9 +102,27 @@ struct {
static void append_mount_options(char **oldopts, char *newopts)
{
if (*oldopts && **oldopts) {
- char *temp = xasprintf("%s,%s",*oldopts,newopts);
- free(*oldopts);
- *oldopts = temp;
+ /* 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);
+ *oldopts = p;
+skip:
+ newopts += len;
+ while (newopts[0] == ',') newopts++;
+ }
} else {
if (ENABLE_FEATURE_CLEAN_UP) free(*oldopts);
*oldopts = xstrdup(newopts);