summaryrefslogtreecommitdiff
path: root/usr.sbin/pkg_add/OpenBSD/Vstat.pm
diff options
context:
space:
mode:
authorMarc Espie <espie@cvs.openbsd.org>2004-03-10 08:21:41 +0000
committerMarc Espie <espie@cvs.openbsd.org>2004-03-10 08:21:41 +0000
commit71c47358a5fe6e68f341e29685be5fc07b9dcf0b (patch)
tree0d4d65ec41dc289e648e6c794d5c375e89f05b4c /usr.sbin/pkg_add/OpenBSD/Vstat.pm
parent2fb94156576e1592b536bd554cb3ceb4583bcb93 (diff)
Help it cope with symlinks. Mostly from rd@thrush.com.
okay pvalchev@
Diffstat (limited to 'usr.sbin/pkg_add/OpenBSD/Vstat.pm')
-rw-r--r--usr.sbin/pkg_add/OpenBSD/Vstat.pm41
1 files changed, 31 insertions, 10 deletions
diff --git a/usr.sbin/pkg_add/OpenBSD/Vstat.pm b/usr.sbin/pkg_add/OpenBSD/Vstat.pm
index 0100558cd09..ee9c428032b 100644
--- a/usr.sbin/pkg_add/OpenBSD/Vstat.pm
+++ b/usr.sbin/pkg_add/OpenBSD/Vstat.pm
@@ -1,4 +1,4 @@
-# $OpenBSD: Vstat.pm,v 1.3 2003/12/26 16:34:05 espie Exp $
+# $OpenBSD: Vstat.pm,v 1.4 2004/03/10 08:21:40 espie Exp $
#
# Copyright (c) 2003 Marc Espie.
#
@@ -45,10 +45,12 @@ my $blocksize = 512;
sub create_mntpoint($)
{
my $mntpoint = shift;
- my $n = $dirinfo->{"$mntpoint"};
+ my $dev = (stat $mntpoint)[0];
+ my $n = $dirinfo->{"$dev"};
if (!defined $n) {
- $n = { mnt => $mntpoint, used => 0 };
+ $n = { mnt => $mntpoint, dev => $dev, used => 0 };
bless $n, "OpenBSD::Vstat::MountPoint";
+ $dirinfo->{"$dev"} = $n;
$dirinfo->{"$mntpoint"} = $n;
push(@$mnts, $n);
}
@@ -101,21 +103,40 @@ sub _dirstat($);
sub _dirstat($)
{
my $dname = shift;
-
- if (!defined $dirinfo->{"$dname"}) {
- return $dirinfo->{"$dname"} = _dirstat(dirname($dname));
+ my $dev = (stat $dname)[0];
+
+ if (!defined $dev) {
+ if (!defined $dirinfo->{"$dname"}) {
+ return $dirinfo->{"$dname"} = _dirstat(dirname($dname));
+ } else {
+ return $dirinfo->{"$dname"};
+ }
} else {
- return $dirinfo->{"$dname"};
+ if (!defined $dirinfo->{"$dev"}) {
+ return $dirinfo->{"$dev"} = _dirstat(dirname($dname));
+ } else {
+ return $dirinfo->{"$dev"};
+ }
}
}
sub filestat($)
{
my $fname = shift;
- if (!defined $dirinfo->{"$fname"}) {
- return _dirstat(dirname($fname));
+ my $dev = (stat $fname)[0];
+
+ if (!defined $dev) {
+ if (!defined $dirinfo->{"$fname"}) {
+ return _dirstat(dirname($fname));
+ } else {
+ return $dirinfo->{"$fname"};
+ }
} else {
- return $dirinfo->{"$fname"};
+ if (!defined $dirinfo->{"$dev"}) {
+ return _dirstat(dirname($fname));
+ } else {
+ return $dirinfo->{"$dev"};
+ }
}
}