Philip Guenther <[email protected]> writes:
> So I'll commit your diff; you wanna switch at doing the matching for
> -w/-W ?
Ok so hopefully, I think I get this right. With the following /etc/fstab:
8e26a31ab7f46c90.b none swap sw
bf16ae2b23dadbc7.a / ffs rw 1 1
swap /tmp tmpfs rw,noexec,nodev,nosuid,-s50m 0 0
bf16ae2b23dadbc7.f /home ffs rw,nodev,nosuid,softdep 1 2
bf16ae2b23dadbc7.e /usr ffs rw,nodev,softdep 1 2
bf16ae2b23dadbc7.d /var ffs rw,nodev,nosuid,softdep 1 2
bf16ae2b23dadbc7.g /usr/src ffs rw,softdep,noauto 0 0
/dev/sd0h /usr/xenocara ffs rw,softdep,noauto 1 0
and /etc/dumpdates:
/dev/sd0a 0 Wed Apr 1 10:50:27 2015
/var 0 Wed Apr 1 11:30:05 2015
bf16ae2b23dadbc7.e 0 Fri Apr 24 11:30:09 2015
bf16ae2b23dadbc7.f 0 Fri Apr 24 11:36:42 2015
bf16ae2b23dadbc7.e 1 Tue May 5 12:30:04 2015
bf16ae2b23dadbc7.f 1 Tue May 5 12:30:30 2015
bf16ae2b23dadbc7.h 0 Wed Apr 1 09:56:56 2015
"dump -w" gives:
Dump these file systems:
/dev/sd0a ( /) Last dump: Level 0, Date Wed Apr 1 10:50
/var ( /var) Last dump: Level 0, Date Wed Apr 1 11:30
bf16ae2b23dadbc7.h (/usr/xenocara) Last dump: Level 0, Date Wed Apr 1
09:56
and "dump -W" gives:
Last dump(s) done (Dump '>' file systems):
> /dev/sd0a ( /) Last dump: Level 0, Date Wed Apr 1 10:50
> /var ( /var) Last dump: Level 0, Date Wed Apr 1 11:30
bf16ae2b23dadbc7.e ( /usr) Last dump: Level 1, Date Tue May 5 12:30
bf16ae2b23dadbc7.f ( /home) Last dump: Level 1, Date Tue May 5 12:30
> bf16ae2b23dadbc7.h (/usr/xenocara) Last dump: Level 0, Date Wed Apr 1
> 09:56
Here is the patch:
Index: dump.h
===================================================================
RCS file: /cvs/src/sbin/dump/dump.h,v
retrieving revision 1.23
diff -u -p -r1.23 dump.h
--- dump.h 3 May 2015 01:44:34 -0000 1.23
+++ dump.h 6 May 2015 09:24:24 -0000
@@ -125,6 +125,7 @@ __dead void dumpabort(int signo);
void getfstab(void);
char *rawname(char *cp);
+char *getrealpath(char *path);
union dinode *getino(ino_t inum, int *mode);
/* rdump routines */
Index: main.c
===================================================================
RCS file: /cvs/src/sbin/dump/main.c,v
retrieving revision 1.55
diff -u -p -r1.55 main.c
--- main.c 3 May 2015 01:44:34 -0000 1.55
+++ main.c 6 May 2015 09:24:24 -0000
@@ -659,6 +659,23 @@ rawname(char *cp)
}
/*
+ * Wrapper around opendev(3) to get a realpath of a device.
+ */
+char *
+getrealpath(char *path)
+{
+ int fd;
+ char *realpath;
+
+ if ((fd = opendev(path, O_RDONLY | O_NOFOLLOW, 0,
+ &realpath)) >= 0) {
+ close(fd);
+ return (strdup(realpath));
+ }
+ return (NULL);
+}
+
+/*
* obsolete --
* Change set of key letters and ordered arguments into something
* getopt(3) will like.
Index: optr.c
===================================================================
RCS file: /cvs/src/sbin/dump/optr.c,v
retrieving revision 1.36
diff -u -p -r1.36 optr.c
--- optr.c 15 Mar 2015 00:41:27 -0000 1.36
+++ optr.c 6 May 2015 09:24:24 -0000
@@ -337,7 +337,7 @@ fstabsearch(char *key)
{
struct pfstab *pf;
struct fstab *fs;
- char *rn;
+ char *rn, *rp;
for (pf = table; pf != NULL; pf = pf->pf_next) {
fs = pf->pf_fstab;
@@ -346,6 +346,13 @@ fstabsearch(char *key)
return (fs);
rn = rawname(fs->fs_spec);
if (rn != NULL && strcmp(rn, key) == 0)
+ return (fs);
+ rp = getrealpath(key);
+ if (rn != NULL && rp != NULL && strcmp(rn, rp) == 0)
+ return (fs);
+ rp = getrealpath(fs->fs_spec);
+ rn = rawname(key);
+ if (rn != NULL && rp != NULL && strcmp(rn, rp) == 0)
return (fs);
if (key[0] != '/') {
if (*fs->fs_spec == '/' &&
--
Manuel Giraud