reiserfs: fix handling of device names with /'s in them
PATCH 1/1 reiserfs: fix handling of device names with /'s in them
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On systems with block devices containing slashes (virtual dasd, cciss, etc), reiserfs will fail to initialize /proc/fs/reiserfs/<dev> due to it being interpreted as a subdirectory. The generic block device code changes the / to ! for use in the sysfs tree. This patch uses that convention.
Tested by making dm devices use dm/<number> rather than dm-<number>
- --
fs/reiserfs/procfs.c | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-)
diff -ruNp linux-2.6.17.orig/fs/reiserfs/procfs.c linux-2.6.17.orig.devel/fs/reiserfs/procfs.c
- --- linux-2.6.17.orig/fs/reiserfs/procfs.c 2006-07-12 11:58:56.000000000 -0400
+++ linux-2.6.17.orig.devel/fs/reiserfs/procfs.c 2006-07-12 12:39:17.000000000 -0400
@@ -493,9 +493,17 @@ static void add_file(struct super_block
int reiserfs_proc_info_init(struct super_block *sb)
{
+ char bdev[BDEVNAME_SIZE];
+ char *s;
+
+ /* Some block devices use /'s */
+ strlcpy(bdev, reiserfs_bdevname(sb), BDEVNAME_SIZE);
+ s = strchr(bdev, '/');
+ if (s)
+ *s = '!';
+
spin_lock_init(&__PINFO(sb).lock);
- - REISERFS_SB(sb)->procdir =
- - proc_mkdir(reiserfs_bdevname(sb), proc_info_root);
+ REISERFS_SB(sb)->procdir = proc_mkdir(bdev, proc_info_root);
if (REISERFS_SB(sb)->procdir) {
REISERFS_SB(sb)->procdir->owner = THIS_MODULE; REISERFS_SB(sb)->procdir->data = sb;
@@ -509,13 +517,22 @@ int reiserfs_proc_info_init(struct super
return 0;
}
reiserfs_warning(sb, "reiserfs: cannot create /proc/%s/%s",
- - proc_info_root_name, reiserfs_bdevname(sb));
+ proc_info_root_name, bdev);
return 1;
}
int reiserfs_proc_info_done(struct super_block *sb) {
struct proc_dir_entry *de = REISERFS_SB(sb)->procdir;
+ char bdev[BDEVNAME_SIZE];
+ char *s;
+
+ /* Some block devices use /'s */
+ strlcpy(bdev, reiserfs_bdevname(sb), BDEVNAME_SIZE);
+ s = strchr(bdev, '/');
+ if (s)
+ *s = '!';
+
if (de) {
remove_proc_entry("journal", de); remove_proc_entry("oidmap", de);
@@ -529,7 +546,7 @@ int reiserfs_proc_info_done(struct super
__PINFO(sb).exiting = 1; spin_unlock(&__PINFO(sb).lock);
if (proc_info_root) {
- - remove_proc_entry(reiserfs_bdevname(sb), proc_info_root);
+ remove_proc_entry(bdev, proc_info_root);
REISERFS_SB(sb)->procdir = NULL;
}
return 0;
- --
Jeff Mahoney
SUSE Labs
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2 (GNU/Linux)
Comment: Using GnuPG with SUSE - http://enigmail.mozdev.org
iD8DBQFEtSZ0LPWxlyuTD7IRAkfVAJoChixL9icBa5tpe+A9cqE4OdohywCfVW0f RgF2ffZyXik8NuDy/m0kXUc=
=X3VE
-----END PGP SIGNATURE-----
Quoted 7 lines · Jeff Mahoney
On systems with block devices containing slashes (virtual dasd, cciss, etc), reiserfs will fail to initialize /proc/fs/reiserfs/<dev> due to it being interpreted as a subdirectory. The generic block device code changes the / to ! for use in the sysfs tree. This patch uses that convention.
Tested by making dm devices use dm/<number> rather than dm-<number>
Your patch handles at most one slash. But the description mentions 'slashes' (ie several slashes)
Review
Quoted 2 lines
(quoted diff) +2
-0+ if (s) + *s = '!';
Maybe you need a loop
while (s) {
*s = '!';
s = strchr(s, '/');
}Eric
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Quoted 9 lines · Eric Dumazet
Quoted 7 lines · Jeff Mahoney
On systems with block devices containing slashes (virtual dasd, cciss, etc), reiserfs will fail to initialize /proc/fs/reiserfs/<dev> due to it being interpreted as a subdirectory. The generic block device code changes the / to ! for use in the sysfs tree. This patch uses that convention.
Tested by making dm devices use dm/<number> rather than dm-<number>
Quoted 7 lines
Your patch handles at most one slash. But the description mentions 'slashes' (ie several slashes)
Review
Quoted 2 lines
(quoted diff) +2
-0+ if (s) + *s = '!';Maybe you need a loop
I'd prefer to correct the grammar rather than the patch. This patch simply duplicates the logic in make_block_name().
- -Jeff
- --
Jeff Mahoney
SUSE Labs
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2 (GNU/Linux)
Comment: Using GnuPG with SUSE - http://enigmail.mozdev.org
iD8DBQFEtStALPWxlyuTD7IRAgl0AJ9Q25r0SIZpIZrX/m6ld69OLwvoxQCfdRj/ XIT1LYuQThoypHAx7ud96h8=
=0ZdG
-----END PGP SIGNATURE-----
Quoted 5 lines · On Wed, 12 Jul 2006 12:42:28 -0400 Jeff Mahoney <[email protected]> wrote:
On systems with block devices containing slashes (virtual dasd, cciss, etc), reiserfs will fail to initialize /proc/fs/reiserfs/<dev> due to it being interpreted as a subdirectory. The generic block device code changes the / to ! for use in the sysfs tree. This patch uses that convention.
Isn't it a bit dumb of us to be putting slashes in the device names anyway?
It would be better, if poss, to alter dasd/cciss/etc and stop all these
s@/@!@everywhere games.
Quoted 13 lines · Andrew Morton
Quoted 7 lines · On Wed, 12 Jul 2006 12:42:28 -0400 Jeff Mahoney <[email protected]> wrote:
On systems with block devices containing slashes (virtual dasd, cciss, etc), reiserfs will fail to initialize /proc/fs/reiserfs/<dev> due to it being interpreted as a subdirectory. The generic block device code changes the / to ! for use in the sysfs tree. This patch uses that convention.
Quoted 7 lines
Isn't it a bit dumb of us to be putting slashes in the device names anyway? It would be better, if poss, to alter dasd/cciss/etc and stop all these s@/@!@everywhere games.
Isn't better to ask why there is a problem with the /'s? It would be bad for Linux as a design to prevent passing arbitrary tail ends of filenames off to arbitrary plugins of some kind. In general, in namespace design, you want to allow delegating the job of resolving/interpreting the tail end of a file that the front end has identified as something that can interpret it.
Forgive me, I probably understand something wongly about procfs and this issue....
Hans
Quoted 29 lines · On Wed, 12 Jul 2006 20:51:47 -0700 Hans Reiser <[email protected]> wrote:
Quoted 13 lines · Andrew Morton
Quoted 7 lines · On Wed, 12 Jul 2006 12:42:28 -0400 Jeff Mahoney <[email protected]> wrote:
On systems with block devices containing slashes (virtual dasd, cciss, etc), reiserfs will fail to initialize /proc/fs/reiserfs/<dev> due to it being interpreted as a subdirectory. The generic block device code changes the / to ! for use in the sysfs tree. This patch uses that convention.
Quoted 7 lines
Isn't it a bit dumb of us to be putting slashes in the device names anyway? It would be better, if poss, to alter dasd/cciss/etc and stop all these s@/@!@everywhere games.
Isn't better to ask why there is a problem with the /'s? It would be bad for Linux as a design to prevent passing arbitrary tail ends of filenames off to arbitrary plugins of some kind. In general, in namespace design, you want to allow delegating the job of resolving/interpreting the tail end of a file that the front end has identified as something that can interpret it.
Quoted 3 lines
Forgive me, I probably understand something wongly about procfs and this issue....
It's a question of being *practical*. Your observations are in the realm of the theoretical.
Software sucks, and we get along better by not provoking it. So don't put spaces, let alone slashes into strings which we offer to userspace.
Who exactly is failing to handle the slashes, forgive me for my confusion in asking?
Hans
Quoted 7 lines · Andrew Morton
Software sucks, and we get along better by not provoking it. So don't put
spaces, let alone slashes into strings which we offer to userspace.
Followup to: <[email protected]> By author: Andrew Morton <[email protected]> In newsgroup: linux.dev.kernel
Quoted 10 lines
Quoted 5 lines · On Wed, 12 Jul 2006 12:42:28 -0400 Jeff Mahoney <[email protected]> wrote:
On systems with block devices containing slashes (virtual dasd, cciss, etc), reiserfs will fail to initialize /proc/fs/reiserfs/<dev> due to it being interpreted as a subdirectory. The generic block device code changes the / to ! for use in the sysfs tree. This patch uses that convention.
Quoted 3 lines
Isn't it a bit dumb of us to be putting slashes in the device names anyway?
It would be better, if poss, to alter dasd/cciss/etc and stop all these
s@/@!@everywhere games.
A *lot* of people have been requesting more, not less, hierarchy in the filenames in /dev, and by now there is plenty of history there, too. The convention needs to be consistent and stable, though.
-hpa