Re: sysfs root link count broken in 2.6.22-git5

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 7/18/07, Jean Delvare <[email protected]> wrote:
Hi Greg,

On Tue, 17 Jul 2007 20:38:28 -0700, Greg KH wrote:
> On Tue, Jul 17, 2007 at 11:05:30PM +0200, Jean Delvare wrote:
> > This breaks libsensors. libsensors uses libsysfs, and libsysfs is not
> > very smart in that it will initialize successfully even if sysfs is not
> > mounted.
>
> libsysfs isn't smart at all, and isn't even supported anymore.  I'd
> really suggest droping it entirely, it isn't worth it.

Agreed, except that I do not have the time for this right now. I want
to get lm-sensors-3.0.0 ready for a release candidate first. What
really matters for this is to get the API ready. Implementation details
will come later.

> > So I added tests after the initialization, to make sure that
> > sysfs is really there. These tests are:
> > * The mount point exists.
> > * The mount point is really mounted.
>
> Do you know of a 2.6 based distro that does not mount sysfs at /sys?  We
> took that check out a long time ago in udev and no one has complained :)

I don't know of any 2.6-based distro not mounting sysfs at /sys, but I
know of 2.4-based distros not mounting sysfs at all ;) libsensors
supports both 2.4 and 2.6 kernels, so being able to tell whether sysfs
is mounted or not, matters.

debian has mounted the sysfs

/etc/rcS.d/S02mountkernfs.sh:

#
	# Mount sysfs on /sys
	#
	# Only mount sysfs if it is supported (kernel >= 2.6)
	if grep -E -qs "sysfs\$" /proc/filesystems
	then
		domount sysfs "" /sys sysfs -onodev,noexec,nosuid
	fi

	# Mount /var/run and /var/lock as tmpfs if enabled
	if [ yes = "$RAMRUN" ] ; then
		RUN_OPT=
		[ "${RUN_SIZE:=$TMPFS_SIZE}" ] && RUN_OPT=",size=$RUN_SIZE"
		domount tmpfs "" /var/run varrun -omode=0755,nosuid$RUN_OPT
		touch /var/run/.ramfs
	fi
	if [ yes = "$RAMLOCK" ] ; then
		LOCK_OPT=
		[ "${LOCK_SIZE:=$TMPFS_SIZE}" ] && LOCK_OPT=",size=$LOCK_SIZE"
		domount tmpfs "" /var/lock varlock -omode=1777,nodev,noexec,nosuid$LOCK_OPT
		touch /var/lock/.ramfs
	fi



> > The code looks like:
> >
> >        if (sysfs_get_mnt_path(sensors_sysfs_mount, NAME_MAX)
> >          || stat(sensors_sysfs_mount, &statbuf) < 0
> >          || statbuf.st_nlink <= 2)      /* Empty directory */
> >                 return 0;           /* Failure */
> >
> > This works OK with 2.6.22.1, but the last test fails with the current
> > git kernel even when sysfs is mounted.
>
> Yeah, but is checking the number of hard links in the directory a safe
> way to always verify that it isn't empty?

I think so, yes. To the best of my knowledge, it has worked on all
Unix-like systems for decades. There are other ways, but this is by far
the less expensive.

>                                            Isn't there some glibc
> function that can detect the mount point of a filesystem or directory?
> Something in glibc parses /proc/mounts for something, I can't remember
> what it is right now though, sorry.

Maybe getmntent(3)? Sure I could use this, but how expensive compared
to a single stat(2).

> Again, I recommend dropping libsysfs, it's gone from some distros
> already :)

Really? I'm curious how such distributions support libsensors and the
other tools which still rely on libsysfs. If they have already
converted libsensors for me, that would be good news :)

> And yes, the bug should be fixed, I agree.  Thanks for letting us know.

Tejun already fixed it, that was quick :)

--
Jean Delvare
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux