Skip to content

Commit

Permalink
vfs: avoid creation of inode number 0 in get_next_ino
Browse files Browse the repository at this point in the history
currently, get_next_ino() is able to create inodes with inode number = 0.
This have a bad impact in the filesystems relying in this function to generate
inode numbers.

While there is no problem at all in having inodes with number 0, userspace tools
which handle file management tasks can have problems handling these files, like
for example, the impossiblity of users to delete these files, since glibc will
ignore them. So, I believe the best way is kernel to avoid creating them.

This problem has been raised previously, but the old thread didn't have any
other update for a year+, and I've seen too many users hitting the same issue
regarding the impossibility to delete files while using filesystems relying on
this function. So, I'm starting the thread again, with the same patch
that I believe is enough to address this problem.

Signed-off-by: Carlos Maiolino <cmaiolino@redhat.com>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
  • Loading branch information
Carlos Maiolino authored and Al Viro committed Jul 1, 2015
1 parent 06d7137 commit 2adc376
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion fs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -840,7 +840,11 @@ unsigned int get_next_ino(void)
}
#endif

*p = ++res;
res++;
/* get_next_ino should not provide a 0 inode number */
if (unlikely(!res))
res++;
*p = res;
put_cpu_var(last_ino);
return res;
}
Expand Down

0 comments on commit 2adc376

Please sign in to comment.