From mboxrd@z Thu Jan 1 00:00:00 1970 From: Pozsar Balazs Date: Fri, 23 Mar 2007 14:46:56 +0000 Subject: [PATCH] udevsettle should read udev not kernel seqnum first Message-Id: <20070323144655.GD30083@ojjektum.uhulinux.hu> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable To: linux-hotplug@vger.kernel.org Hi all, I think that the order of reading the kernel and udev seqnum files=20 should be: first udev, then kernel, because with the current code=20 there's a chance of exiting too early, for example in the following=20 scenario: 1. kernel seqnum is X, udevsettle reads it 2. udev finishes processing the event X, which generates new events (for example a modprobe), udev seqnum becomes X 3. udevsettle reads the udev seqnum which is X now, so it exits 4. at least another event comes which should have been waited for Attached patch changes the order to first read the udev seqnum. diff -Naurd a/udevsettle.c b/udevsettle.c --- a/udevsettle.c 2006-04-15 19:32:38.000000000 +0200 +++ b/udevsettle.c 2006-04-25 21:40:57.000000000 +0200 @@ -111,9 +111,9 @@ goto exit; } =20 - /* read current kernel seqnum */ - strlcpy(filename, sysfs_path, sizeof(filename)); - strlcat(filename, "/kernel/uevent_seqnum", sizeof(filename)); + /* read current udev seqnum */ + strlcpy(filename, udev_root, sizeof(filename)); + strlcat(filename, "/" EVENT_SEQNUM, sizeof(filename)); fd =3D open(filename, O_RDONLY); if (fd < 0) goto exit; @@ -122,12 +122,12 @@ if (len <=3D 0) goto exit; seqnum[len] =3D '\0'; - seq_kernel =3D strtoull(seqnum, NULL, 10); - info("kernel seqnum =3D %llu", seq_kernel); + seq_udev =3D strtoull(seqnum, NULL, 10); + info("udev seqnum =3D %llu", seq_udev); =20 - /* read current udev seqnum */ - strlcpy(filename, udev_root, sizeof(filename)); - strlcat(filename, "/" EVENT_SEQNUM, sizeof(filename)); + /* read current kernel seqnum */ + strlcpy(filename, sysfs_path, sizeof(filename)); + strlcat(filename, "/kernel/uevent_seqnum", sizeof(filename)); fd =3D open(filename, O_RDONLY); if (fd < 0) goto exit; @@ -136,8 +136,8 @@ if (len <=3D 0) goto exit; seqnum[len] =3D '\0'; - seq_udev =3D strtoull(seqnum, NULL, 10); - info("udev seqnum =3D %llu", seq_udev); + seq_kernel =3D strtoull(seqnum, NULL, 10); + info("kernel seqnum =3D %llu", seq_kernel); =20 /* make sure all kernel events have arrived in the queue */ if (seq_udev >=3D seq_kernel) { --=20 pozsy ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys-and earn cash http://www.techsay.com/default.php?page=3Djoin.php&p=3Dsourceforge&CID=DEVD= EV _______________________________________________ Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net Linux-hotplug-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel