Skip to contentSkip to conversation

fix d_type in readdir in isofs

PATCH In review Domen Puncer 3 participants 4 messages Dec 9, 2003 Isofs filesystem

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fix d_type in readdir in isofs

Hi!

Played with scandir, and noticed iso9660's files d_type is always 0, so here's a fix.

If there are no objections i'll try to fix some other filesystems too.

2.6.0-test11:

fs/isofs/dir.c +2 -1
@@ -230,7 +230,8 @@
 			}
 		}
 		if (len > 0) {
-			if (filldir(dirent, p, len, filp->f_pos, inode_number, DT_UNKNOWN) < 0)
+			if (filldir(dirent, p, len, filp->f_pos, inode_number,
+					(de->flags[0]&2)?DT_DIR:DT_REG) < 0)
 				break;
 		}
 		filp->f_pos += de_len;

2.4.23:

fs/isofs/dir.c +2 -1
@@ -230,7 +230,8 @@
 			}
 		}
 		if (len > 0) {
-			if (filldir(dirent, p, len, filp->f_pos, inode_number, DT_UNKNOWN) < 0)
+			if (filldir(dirent, p, len, filp->f_pos, inode_number,
+					(de->flags[0]&2)?DT_DIR:DT_REG) < 0)
 				break;
 		}
 		filp->f_pos += de_len;
#1 lore raw
Quoted 4 lines · Domen Puncer

Hi!

Played with scandir, and noticed iso9660's files d_type is always 0, so here's a fix.

No, it isn't. DT_UNKNOWN is "I don't know; make no assumptions". DT_REG is "regular file". Returning it when object in question is e.g. a symlink is wrong.

#2 lore raw
Quoted 9 lines · On Tuesday 09 of December 2003 11:09, [email protected]…
Quoted 4 lines · Domen Puncer

Hi!

Played with scandir, and noticed iso9660's files d_type is always 0, so here's a fix.

No, it isn't. DT_UNKNOWN is "I don't know; make no assumptions". DT_REG is "regular file". Returning it when object in question is e.g. a symlink is wrong.

Right, then how about this partial fix:

fs/isofs/dir.c +2 -1
@@ -230,7 +230,8 @@
 			}
 		}
 		if (len > 0) {
-			if (filldir(dirent, p, len, filp->f_pos, inode_number, DT_UNKNOWN) < 0)
+			if (filldir(dirent, p, len, filp->f_pos, inode_number,
+					(de->flags[0]&2)?DT_DIR:DT_UNKNOWN) < 0)
 				break;
 		}
 		filp->f_pos += de_len;

Or maybe we should read inode->i_mode, if it's not too time expensive?

#3 lore raw
In reply to Domen Puncer
Quoted 3 lines · Domen Puncer

Played with scandir, and noticed iso9660's files d_type is always 0, so here's a fix.

Looks ok, but I can't convince myself to apply this at this point:
there's just not way I can call this a major stability fix ;). Can somebody keep this around for later?

Linus