inode->i_rdev not initialized in 2.4 fs/inode.c, only in 2.6?
Hello,
I'm running 2.4.22 (with XFS and skas patch), but these patches do not affect the code in question. /proc/version = Linux version 2.4.22-xfs (root@saytrin) (gcc version 3.3.2 20030908 (Debian prerelease))
I get strange results (st.st_rdev != 0) in userspace after stat on some non-devices regular file/directory. On one computer, /etc gives 773 and /etc/init.d 0, while on another /etc gives 0 and /etc/init.d 13478.
After gdb and seeing it comes from kernel, I looked around and saw that in fs/inode.c, i_rdev is not zeroed. Nor does it *seem* that kmem_cache_alloc clears the memory, but I could be mistaken, it's complicated code (I think it only clears at cache creation). And r_dev is what gets transformed into st_rdev in fs/stat.c
2.6 fixes this behavior, by saying "inode->i_rdev = to_kdev_t(0);". Shouldn't this be also in 2.4?
Thanks,
Iustin Pop
Please CC me as I'm not on the list.
Quoted 9 lines · Iustin Pop
Hello,
I'm running 2.4.22 (with XFS and skas patch), but these patches do not affect the code in question.
/proc/version= Linux version 2.4.22-xfs (root@saytrin) (gcc version 3.3.2 20030908 (Debian prerelease))I get strange results (st.st_rdev != 0) in userspace after stat on some non-devices regular file/directory. On one computer, /etc gives 773 and
/etc/init.d0, while on another /etc gives 0 and/etc/init.d13478.
st_rdev is undefined for non-devices, so any userland code that relies on it being zero is broken. It wouldn't hurt to zero it out, but any application that has problems with that needs to be fixed anyway.