:: Re: [DNG] USB mount problem
トップ ページ
このメッセージを削除
このメッセージに返信
著者: Didier Kryn
日付:  
To: dng@lists.dyne.org
題目: Re: [DNG] USB mount problem
Le 23/06/2021 à 14:38, Dr. Nikolaus Klepp a écrit :
> Anno domini 2021 Wed, 23 Jun 13:34:39 +0200
> Didier Kryn scripsit:
>> Le 23/06/2021 à 12:49, Dr. Nikolaus Klepp a écrit :
>>> Anno domini 2021 Wed, 23 Jun 12:16:50 +0200
>>> Didier Kryn scripsit:
>>>> [...]
>>>>     There is no other way to know which partitions are mounted or not
>>>> than read /proc/self/mounts. inotify does not work on pseudo-filesystems
>>>> like /sys or /proc. Therefore, either this is done by the front-end or
>>>> by the back-end.
>>> Oh, inotifywatch perfectly works on /sys and /dev when you are root, in fact that's what I use as part of my automounter when I run fvwm:
>>     Of course it works on /dev; tmpfs and devtmpfs behave like real
>> filesystems. This is what Hopman is based on (~:
>>
>>     Hopman isn't root, doesn't need to be, and shouldn't be. And inotify
>> doesn't work on /proc (at least for non-root).
> Well, inotifywait does work on /dev /sys and /proc for non-root, too. At least it does here on chimaera. Just try these:
>
> $ inotifywait -rm /proc/
> $ inotifywait -rm /sys/devices/pci*
>
> What does not work is /sys/block, but that's a cosmetic problem, as you alway can watch for /sys and fiilter the output.

    I don't need to poll or watch /sys. I browse it when inotify tells
me something about /dev, to see if it is a partition and if it is removable.
>
> How does hopman differ from e.g. "inotifywait -rm /dev/disk" or "inotifywait -rm /dev/block" + some lines of shell magic to get a nice output?

    Because It does it all in just one single process and also browses
/sys to filter events as explained above and all the rest of the work:
display the status, collect mouse-clicks, launch helpers, wait() them,
display their error messages, all asynchrohously. It is easy to make a
toy script to play with it but really unpractical to do a complete job.
> If polling /proc/self/mounts is required, where is the point in not polling /sys/block/sd*/removable, too?


    1st because polling one file only is less load for the system; 2nd
because when there are no removable device in the system, then there is
no need to poll it, and this is most of the time. As long as there is no
removable device, Hopman is sleeping 100% the time, except briefly when
a file is created/deleted in /dev.

    Reading /proc/self/mounts is triggered by an alarm which is enabled
only when there is a removable device in the system.

--     Didier