Skip to contentSkip to conversation

avoid recursing into dotdirs

PATCH In review Robert Millan 2 participants 3 messages Sep 14, 2006

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 avoid recursing into dotdirs

grub-probefs used to recurse into /dev/.static, then come up with /dev/.static/dev/hda as my root disk, which later fails to pass the pathname-based checks that expect things like /dev/[hsf]d[0-9].

2006-09-14 Robert Millan <[email protected]>

* util/i386/pc/getroot.c: Don't recurse into dotdirs (e.g. ".static").

Signature · 4 lines
Robert Millan

My spam trap is [email protected].  Note: this address is only intended for
spam harvesters.  Writing to it will get you added to my black list.

2006-09-14 Robert Millan <[email protected]>

* util/i386/pc/getroot.c: Don't recurse into dotdirs (e.g. ".static").

Index: util/i386/pc/getroot.c
===================================================================
RCS file: /sources/grub/grub2/util/i386/pc/getroot.c,v retrieving revision 1.4

i386/pc/getroot.c +4 -2
diff -u -r1.4 getroot.c
@@ -160,9 +160,11 @@
 	/* Don't follow symbolic links.  */
 	continue;
       
-      if (S_ISDIR (st.st_mode))
+      if (S_ISDIR (st.st_mode) && ent->d_name[0] != '.')
 	{
-	  /* Find it recursively.  */
+	  /* Find it recursively, but avoid dotdirs (like ".static") since they
+          could contain duplicates, which would later break the pathname-based
+          check */
 	  char *res;
 
 	  res = find_root_device (ent->d_name, dev);
#1 lore raw
Quoted 7 lines · Robert Millan

grub-probefs used to recurse into /dev/.static, then come up with /dev/.static/dev/hda as my root disk, which later fails to pass the pathname-based checks that expect things like /dev/[hsf]d[0-9].

2006-09-14 Robert Millan <[email protected]>

* util/i386/pc/getroot.c: Don't recurse into dotdirs (e.g. ".static").

There is a double space before "Don't", it should be a single space.

i386/pc/getroot.c line 167

Quoted 7 lines
i386/pc/getroot.c +4 -2
-      if (S_ISDIR (st.st_mode))
+      if (S_ISDIR (st.st_mode) && ent->d_name[0] != '.')
 	{
-	  /* Find it recursively.  */
+	  /* Find it recursively, but avoid dotdirs (like ".static") since they
+          could contain duplicates, which would later break the pathname-based
+          check */

This looks fine, but funny. I assume you are using tabs where there should be spaces. Can you please check that before committing?

--
Marco

#2 lore raw
Quoted 11 lines · Marco Gerards
Quoted 7 lines · Robert Millan

grub-probefs used to recurse into /dev/.static, then come up with /dev/.static/dev/hda as my root disk, which later fails to pass the pathname-based checks that expect things like /dev/[hsf]d[0-9].

2006-09-14 Robert Millan <[email protected]>

* util/i386/pc/getroot.c: Don't recurse into dotdirs (e.g. ".static").

There is a double space before "Don't", it should be a single space.

Ok.

Quoted 10 lines

i386/pc/getroot.c line 167

Quoted 7 lines
i386/pc/getroot.c +4 -2
-      if (S_ISDIR (st.st_mode))
+      if (S_ISDIR (st.st_mode) && ent->d_name[0] != '.')
 	{
-	  /* Find it recursively.  */
+	  /* Find it recursively, but avoid dotdirs (like ".static") since they
+          could contain duplicates, which would later break the pathname-based
+          check */

This looks fine, but funny. I assume you are using tabs where there should be spaces. Can you please check that before committing?

Yep, I had it wrong. Fixed now.

Signature · 4 lines
Robert Millan

My spam trap is [email protected].  Note: this address is only intended for
spam harvesters.  Writing to it will get you added to my black list.