determing space in the / partition
Alex Zbyslaw
xfb52 at dial.pipex.com
Tue Oct 2 08:16:31 PDT 2007
Bill Vermillion wrote:
>Think about it a moment. You you mount you have 'mount point'
>that is typically directed to the fs that you have mounted there.
>If nothing is mounted the mount point will get all the data.
>
Zbigniew, it sounds like your script is just dumping to what it assumes
is a mounted USB drive. Ideally, you would get your script to check if
that drive is actually mounted, to avoid this happening in the future.
One way to do that is to check if the "device" associated with the /usb
(or whatever you called it) subdirectory is different from the "device"
for /. When the USB is mounted they will be different and you can see
the device using stat(1).
E.g. if I try on my system with / and /usr (separate mountpoints) I get:
(cartman)133% /usr/bin/stat -f "%d" /
1072
(cartman)134% /usr/bin/stat -f "%d" /usr
1075
But /boot (on same partition as /) gives the same answer as for /
(cartman)135% /usr/bin/stat -f "%d" /boot
1072
So compare your "device" for your backup directory with / and if they
are the same then cancel the backup with an error "USB disk not mounted"
(If it's a perl script use perl stat which does the same; most scripting
languages should give you access to this information).
--Alex
More information about the freebsd-questions
mailing list