Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --- systemd-org/src/fstab-generator/fstab-generator.c 2013-01-03 14:07:16.729253290 +0000
- +++ systemd-pat/src/fstab-generator/fstab-generator.c 2013-01-03 14:01:01.532488521 +0000
- @@ -214,6 +214,8 @@
- int passno, bool wait, bool noauto, bool nofail, bool automount, bool isbind, bool isnetwork,
- const char *source) {
- char *name = NULL, *unit = NULL, *lnk = NULL, *device = NULL, *automount_name = NULL, *automount_unit = NULL;
- + char uniq_suffix[10] = ".mount";
- + int uniq_num = 0;
- FILE *f = NULL;
- int r;
- const char *post, *pre;
- @@ -244,27 +246,35 @@
- pre = SPECIAL_LOCAL_FS_PRE_TARGET;
- }
- - name = unit_name_from_path(where, ".mount");
- - if (!name) {
- - r = log_oom();
- - goto finish;
- - }
- -
- - unit = strjoin(arg_dest, "/", name, NULL);
- - if (!unit) {
- - r = log_oom();
- - goto finish;
- - }
- + do {
- - f = fopen(unit, "wxe");
- - if (!f) {
- - r = -errno;
- - if (errno == EEXIST)
- - log_error("Failed to create mount unit file %s, as it already exists. Duplicate entry in /etc/fstab?", unit);
- - else
- - log_error("Failed to create unit file %s: %m", unit);
- - goto finish;
- - }
- + name = unit_name_from_path(where, uniq_suffix);
- + if (!name) {
- + r = log_oom();
- + goto finish;
- + }
- +
- + unit = strjoin(arg_dest, "/", name, NULL);
- + if (!unit) {
- + r = log_oom();
- + goto finish;
- + }
- +
- + f = fopen(unit, "wxe");
- + if (!f) {
- + r = -errno;
- + if (errno == EEXIST)
- + {
- + snprintf(uniq_suffix, 10, "_%d.mount", uniq_num++);
- + log_warning("Failed to create mount unit file %s because it already exists (overmount entry in /etc/fstab?). Will retry with suffix %s", unit, uniq_suffix);
- + }
- + else
- + {
- + log_error("Failed to create unit file %s: %m", unit);
- + goto finish;
- + }
- + }
- + } while (!f);
- fprintf(f,
- "# Automatically generated by systemd-fstab-generator\n\n"
- --- systemd-org/src/core/mount.c 2012-10-23 00:53:02.708658801 +0100
- +++ systemd-pat/src/core/mount.c 2013-01-03 14:01:39.545830761 +0000
- @@ -506,6 +506,9 @@
- static int mount_verify(Mount *m) {
- bool b;
- char *e;
- + char *ext, *suf;
- + int name_len;
- + char cm[strlen(UNIT(m)->id)];
- assert(m);
- if (UNIT(m)->load_state != UNIT_LOADED)
- @@ -517,7 +520,15 @@
- if (!(e = unit_name_from_path(m->where, ".mount")))
- return -ENOMEM;
- - b = unit_has_name(UNIT(m), e);
- + /* clean mount file name with any overmount suffix removed */
- + ext = strrchr(UNIT(m)->id,'.');
- + suf = strrchr(UNIT(m)->id,'_');
- + name_len = (suf ? suf : ext ) - UNIT(m)->id;
- + strncpy(cm,UNIT(m)->id, name_len);
- + strcpy(cm + name_len, ext);
- + log_debug("clean mount file name (with any overmount suffix removed): %s", cm);
- +
- + b = unit_has_name(UNIT(m), e) || !strcmp(e,cm);
- free(e);
- if (!b) {
Advertisement
Add Comment
Please, Sign In to add comment