On Tue, Apr 08, 2025 at 08:14:34AM +0200, Jan Stary wrote:
> On Apr 08 06:56:53, [email protected] wrote:
> > TSS <[email protected]> writes:
> >
> > > Greetings,
> > >
> > > I've been using this gimmick for backing up some OpenBSD 7.6 systems:
> > > https://github.com/thexhr/openbsd-timemachine
> > > For the purposes of this discussion, it:
> > >
> > > 1. uses hotplugd to run a script when you plug in a USB backup drive
> > > 2. this script mounts the backup drive
> > > 3. it then uses rsnapshot (rsync basically) to back up the data
> > > 4. the script unmounts the backup drive
> > >
> > > Everything is just fine until step 4, when the backup drive refuses to
> > > unmount. If you try to do it yourself, you see:
> > >
> > > umount: /my_backup_mount_point: Device busy
> > >
> > > This doesn't seem to be a temporary issue: after an hour's wait, the drive
> > > still can't be unmounted.
> > >
> > > I'm not sure how to debug the problem since fstat shows no open file on
> > > the
> > > drive, nor any process using any directory on the drive as a working
> > > directory.
> >
> > how did you use fstat ? I don't remember well, but using
> > 'fstat /my_backup_mount_point' might not be enough.
> >
> > but you could use:
> >
> > $ fstat -f /my_backup_mount_point
> >
> > with -f, fstat will list all opened files in the /my_backup_mount_point
> > mount point (at any depth).
>
> For example, as I'm writing this in mutt/vim (paused):
>
> $ fstat /tmp
> USER CMD PID FD MOUNT INUM MODE R/W SZ|DV NAME
>
> $ fstat -f/tmp
> USER CMD PID FD MOUNT INUM MODE R/W SZ|DV
> hans fstat 6559 1 /tmp 25 -rw-r--r-- w 0
> hans nvi 16311 4 /tmp 32897* -rw------- r 1474
> hans nvi 16311 5 /tmp 32901 -rw------- re 1940
> hans nvi 16311 6 /tmp 16449 -rw------- rwe 5120
> hans nvi 16311 7 /tmp 4* -rw------- rwe 0
> hans nvi 16311 8 /tmp 5 -rw------- re 0
> hans nvi 16311 9 /tmp 16450 -rw------- rw 610
> hans nvi 16311 10 /tmp 16451 -rwx------ rwe 0
> hans nvi 16311 11 /tmp 6* -rw------- rwe 0
> hans sh 48868 4 /tmp 32897* -rw------- r 1474
> hans mutt 5793 4 /tmp 32897* -rw------- rp 1474
> hans ksh 12342 1 /tmp 25 -rw-r--r-- wp 0
>
> > (it should be the same than
> > 'fstat | grep /my_backup_mount_point')
>
> Apparently not:
>
> $ fstat /home
> USER CMD PID FD MOUNT INUM MODE R/W SZ|DV NAME
>
> $ fstat -f /home
> USER CMD PID FD MOUNT INUM MODE R/W SZ|DV
> hans fstat 77656 wd /home 466560 drwxr-xr-x r 17408
> hans nvi 16311 wd /home 466560 drwxr-xr-x r 17408
> hans nvi 16311 3 /home 466929 -rw------- r 34821589
> hans sh 48868 wd /home 466560 drwxr-xr-x r 17408
> hans sh 48868 3 /home 466929 -rw------- r 34821589
> hans mutt 5793 wd /home 466560 drwxr-xr-x r 17408
> hans mutt 5793 3 /home 466929 -rw------- rp 34821589
> hans ksh 12342 wd /home 466560 drwxr-xr-x r 17408
> hans ksh 12342 11 /home 466785 -rw------- rwep 9047
>
> Which is strange, because -f is supposed to
>
> _restrict_ examination to files open in
> the same file systems as the named file arguments
>
> Jan
>
fstat != fstat /home
The no argment case lists all files open in the whole system.
I suppose the descripton of -f says "restrict" because it compares
agains the no arg case.
-Otto