summaryrefslogtreecommitdiffstats
path: root/usr.sbin/snapinfo
diff options
context:
space:
mode:
authorpjd <pjd@FreeBSD.org>2007-03-16 03:23:32 +0000
committerpjd <pjd@FreeBSD.org>2007-03-16 03:23:32 +0000
commit545f9291a9b9889a5ef02ff1fcd596b96c3fea3b (patch)
treebe6e7c4c8c13702f1e5db1b6d654894f6af85ab6 /usr.sbin/snapinfo
parent781b031d076abdcb10119f221a82fd7cb5fc9d88 (diff)
downloadFreeBSD-src-545f9291a9b9889a5ef02ff1fcd596b96c3fea3b.zip
FreeBSD-src-545f9291a9b9889a5ef02ff1fcd596b96c3fea3b.tar.gz
Pass special device to the ufs_disk_fillout() function, instead of mount
point path. This way we properly handle the case when file system listed in /etc/fstab was unmounted and another file system was mounted on the same mount point.
Diffstat (limited to 'usr.sbin/snapinfo')
-rw-r--r--usr.sbin/snapinfo/snapinfo.c21
1 files changed, 9 insertions, 12 deletions
diff --git a/usr.sbin/snapinfo/snapinfo.c b/usr.sbin/snapinfo/snapinfo.c
index d0f3f2b..a4b1a13 100644
--- a/usr.sbin/snapinfo/snapinfo.c
+++ b/usr.sbin/snapinfo/snapinfo.c
@@ -42,7 +42,7 @@
void find_inum(char *path);
void usage(void);
int compare_function(const char *, const struct stat *, int, struct FTW *);
-int find_snapshot(char *path);
+int find_snapshot(struct statfs *sfs);
int verbose;
int cont_search;
@@ -92,29 +92,26 @@ main(int argc, char **argv)
fscount = getmntinfo(&mntbuf, MNT_WAIT);
for (n = 0; n < fscount; n++) {
if (!strncmp(mntbuf[n].f_fstypename, "ufs", 3)) {
- if (all)
- path = mntbuf[n].f_mntonname;
- else if (strcmp(path, mntbuf[n].f_mntonname))
- continue;
-
- find_snapshot(path);
- done++;
+ if (all || strcmp(path, mntbuf[n].f_mntonname) == 0) {
+ find_snapshot(&mntbuf[n]);
+ done++;
+ }
}
}
- if (!done)
+ if (done == 0)
usage();
return (0);
}
int
-find_snapshot(char *path)
+find_snapshot(struct statfs *sfs)
{
struct uufsd disk;
int j, snapcount = 0;
- if (ufs_disk_fillout(&disk, path) == -1)
+ if (ufs_disk_fillout(&disk, sfs->f_mntfromname) == -1)
perror("ufs_disk_fillout");
if (verbose)
@@ -123,7 +120,7 @@ find_snapshot(char *path)
for (j = 0; j < FSMAXSNAP; j++) {
if (disk.d_fs.fs_snapinum[j]) {
inode = disk.d_fs.fs_snapinum[j];
- find_inum(path);
+ find_inum(sfs->f_mntonname);
snapcount++;
}
}
OpenPOWER on IntegriCloud