Message ID | 20231107120017.515892-1-lukas.funke-oss@weidmueller.com |
---|---|
State | Accepted, archived |
Commit | 695e0a41e3c1cb47484605934a57e7df591bd19f |
Headers | show |
Series | udev-extraconf: mount.sh: check if filesystem is supported before mounting | expand |
On Tue, 2023-11-07 at 13:00 +0100, Lukas Funke wrote: > From: Lukas Funke <lukas.funke@weidmueller.com> > > Check if the filesystem is supported by the kernel before trying to > mount it. Systemd-mount will mount the directories asynchronously > resulting in stale directories if the devices filesystem is not > supported. > > Signed-off-by: Lukas Funke <lukas.funke@weidmueller.com> > --- > meta/recipes-core/udev/udev-extraconf/mount.sh | 16 ++++++++++++++++ > 1 file changed, 16 insertions(+) > > diff --git a/meta/recipes-core/udev/udev-extraconf/mount.sh b/meta/recipes-core/udev/udev-extraconf/mount.sh > index 989fabc194..59563b7511 100644 > --- a/meta/recipes-core/udev/udev-extraconf/mount.sh > +++ b/meta/recipes-core/udev/udev-extraconf/mount.sh > @@ -36,6 +36,17 @@ do > fi > done > > +is_filesystem_supported() { > + list_fs=$(cat /proc/filesystems | cut -f 2 | tr '\n' ' ') > + for fs in ${list_fs}; do > + if [ "$fs" == "$ID_FS_TYPE" ] > + then > + return 0 > + fi > + done > + return 1 > +} > + We once went through the init scripts and carefully minimised all the fork() calls in them, since all that process execution overhead does mount up and delay boot times. I really don't know what to do, whether I should continue to care or not. It is easy to say systems have plenty of memory/cpu and therefore, "who cares?". Equally, systems working efficiently is nice to have... Cheers, Richard
Lukas Funke <lukas.funke-oss@weidmueller.com> escreveu no dia terça, 7/11/2023 à(s) 12:00: > From: Lukas Funke <lukas.funke@weidmueller.com> > > Check if the filesystem is supported by the kernel before trying to > mount it. Systemd-mount will mount the directories asynchronously > resulting in stale directories if the devices filesystem is not > supported. > > Signed-off-by: Lukas Funke <lukas.funke@weidmueller.com> > --- > meta/recipes-core/udev/udev-extraconf/mount.sh | 16 ++++++++++++++++ > 1 file changed, 16 insertions(+) > > diff --git a/meta/recipes-core/udev/udev-extraconf/mount.sh > b/meta/recipes-core/udev/udev-extraconf/mount.sh > index 989fabc194..59563b7511 100644 > --- a/meta/recipes-core/udev/udev-extraconf/mount.sh > +++ b/meta/recipes-core/udev/udev-extraconf/mount.sh > @@ -36,6 +36,17 @@ do > fi > done > > +is_filesystem_supported() { > + list_fs=$(cat /proc/filesystems | cut -f 2 | tr '\n' ' ') > + for fs in ${list_fs}; do > + if [ "$fs" == "$ID_FS_TYPE" ] > + then > + return 0 > + fi > + done > + return 1 > +} > + > automount_systemd() { > name="`basename "$DEVNAME"`" > > @@ -64,6 +75,11 @@ automount_systemd() { > grep "^[[:space:]]*$tmp" /etc/fstab && return > done > > + if ! is_filesystem_supported; then > I think the same can done with grep avoid string manipulations and the loop + if grep -q -w "$ID_FS_TYPE" /proc/filesystems; then Jose + logger "mount.sh/automount" "Filesystem '$ID_FS_TYPE' on > '${DEVNAME}' is unsupported" > + return > + fi > + > [ -d "$MOUNT_BASE/$name" ] || mkdir -p "$MOUNT_BASE/$name" > > MOUNT="$MOUNT -o silent" > -- > 2.30.2 > > > -=-=-=-=-=-=-=-=-=-=-=- > Links: You receive all messages sent to this group. > View/Reply Online (#190272): > https://lists.openembedded.org/g/openembedded-core/message/190272 > Mute This Topic: https://lists.openembedded.org/mt/102440934/5052612 > Group Owner: openembedded-core+owner@lists.openembedded.org > Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [ > quaresma.jose@gmail.com] > -=-=-=-=-=-=-=-=-=-=-=- > >
Hi Richard, On 07.11.2023 13:15, Richard Purdie wrote: > On Tue, 2023-11-07 at 13:00 +0100, Lukas Funke wrote: >> From: Lukas Funke <lukas.funke@weidmueller.com> >> >> Check if the filesystem is supported by the kernel before trying to >> mount it. Systemd-mount will mount the directories asynchronously >> resulting in stale directories if the devices filesystem is not >> supported. >> >> Signed-off-by: Lukas Funke <lukas.funke@weidmueller.com> >> --- >> meta/recipes-core/udev/udev-extraconf/mount.sh | 16 ++++++++++++++++ >> 1 file changed, 16 insertions(+) >> >> diff --git a/meta/recipes-core/udev/udev-extraconf/mount.sh b/meta/recipes-core/udev/udev-extraconf/mount.sh >> index 989fabc194..59563b7511 100644 >> --- a/meta/recipes-core/udev/udev-extraconf/mount.sh >> +++ b/meta/recipes-core/udev/udev-extraconf/mount.sh >> @@ -36,6 +36,17 @@ do >> fi >> done >> >> +is_filesystem_supported() { >> + list_fs=$(cat /proc/filesystems | cut -f 2 | tr '\n' ' ') >> + for fs in ${list_fs}; do >> + if [ "$fs" == "$ID_FS_TYPE" ] >> + then >> + return 0 >> + fi >> + done >> + return 1 >> +} >> + > > We once went through the init scripts and carefully minimised all the > fork() calls in them, since all that process execution overhead does > mount up and delay boot times. > > I really don't know what to do, whether I should continue to care or > not. It is easy to say systems have plenty of memory/cpu and therefore, > "who cares?". Equally, systems working efficiently is nice to have... Not sure if correctly interpreted, but it seems that there are some "frustration" vibes in your reply :) I was not aware of the discussion but understand what you are trying to achieve. We can replace the 'cat' with a 'read', which should avoid the fork() since it's a shell-builtin (correct me if I'm wrong). Best regards Lukas > > Cheers, > > Richard > >
diff --git a/meta/recipes-core/udev/udev-extraconf/mount.sh b/meta/recipes-core/udev/udev-extraconf/mount.sh index 989fabc194..59563b7511 100644 --- a/meta/recipes-core/udev/udev-extraconf/mount.sh +++ b/meta/recipes-core/udev/udev-extraconf/mount.sh @@ -36,6 +36,17 @@ do fi done +is_filesystem_supported() { + list_fs=$(cat /proc/filesystems | cut -f 2 | tr '\n' ' ') + for fs in ${list_fs}; do + if [ "$fs" == "$ID_FS_TYPE" ] + then + return 0 + fi + done + return 1 +} + automount_systemd() { name="`basename "$DEVNAME"`" @@ -64,6 +75,11 @@ automount_systemd() { grep "^[[:space:]]*$tmp" /etc/fstab && return done + if ! is_filesystem_supported; then + logger "mount.sh/automount" "Filesystem '$ID_FS_TYPE' on '${DEVNAME}' is unsupported" + return + fi + [ -d "$MOUNT_BASE/$name" ] || mkdir -p "$MOUNT_BASE/$name" MOUNT="$MOUNT -o silent"