Skip to contentSkip to conversation

fixup! detect_fs: use device instead of file

PATCH In review Peter Mamonov 3 participants 5 messages Oct 7, 2015 – Oct 9, 2015 VFS

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fixup! detect_fs: use device instead of file

---
 fs/fs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/fs.c +1 -1
index c041e41..6283cea 100644
@@ -1201,7 +1201,7 @@ EXPORT_SYMBOL(register_fs_driver);
 
 static const char *detect_fs(const char *filename)
 {
-	enum filetype type = cdev_detect_type(filename);
+	enum filetype type = cdev_detect_type(basename(filename));
 	struct driver_d *drv;
 	struct fs_driver_d *fdrv;
 
Signature · 7 lines
2.1.4


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#1 lore raw
Quoted 9 lines · Peter Mamonov
---
 fs/fs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/fs.c +0 -0
index c041e41..6283cea 100644

fs/fs.c EXPORT_SYMBOL(register_fs_driver); · line 1204

Quoted 5 lines
fs/fs.c +1 -1
@@ -1201,7 +1201,7 @@ EXPORT_SYMBOL(register_fs_driver);
 
 static const char *detect_fs(const char *filename)
 {
-	enum filetype type = cdev_detect_type(filename);
+	enum filetype type = cdev_detect_type(basename(filename));

basename is not so nice since we do not know whether the the part of the path we drop is really what we expect. Can we rather have a:

	if (!strncmp(filename, "/dev/", 5))
		filename += 5;

Sascha

Signature · 9 lines
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#2 lore raw
Quoted 19 lines · On Fri, 9 Oct 2015 08:31:49 +0200 Sascha Hauer <[email protected]> wrote:
Quoted 9 lines · Peter Mamonov
---
 fs/fs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/fs.c +0 -0
index c041e41..6283cea 100644

fs/fs.c EXPORT_SYMBOL(register_fs_driver); · line 1204

Quoted 5 lines
fs/fs.c +1 -1
@@ -1201,7 +1201,7 @@ EXPORT_SYMBOL(register_fs_driver);
 
 static const char *detect_fs(const char *filename)
 {
-	enum filetype type = cdev_detect_type(filename);
+	enum filetype type = cdev_detect_type(basename(filename));

basename is not so nice since we do not know whether the the part of the path we drop is really what we expect. Can we rather have a:

Quoted 2 lines
	if (!strncmp(filename, "/dev/", 5))
		filename += 5;

What if devfs is mounted somehere else (not on /dev)?

Let me clarify the situation. After applying "detect_fs: use device instead of file" the mount command becomes completely broken for me, since detect_fs() is supplied with the full path to the device file, while cdev_by_name() expects device file name rather than full path:

static const char *detect_fs(const char *filename)

{
	enum filetype type = cdev_detect_type(filename);
	...
	if (type == filetype_unknown)
		return NULL;
	...
}
struct cdev *cdev_by_name(const char *filename)
{
	struct cdev *cdev;

	list_for_each_entry(cdev, &cdev_list, list) {
		if (!strcmp(cdev->name, filename)) <<<<<<< NO MATCH
			return cdev;
	}
	return NULL;
}
struct cdev {
	...
	char *name; /* filename under /dev/ */
	...
}

Can you explain how could it work for Vicente:
http://lists.infradead.org/pipermail/barebox/2015-October/024832.html
?

Peter

Quoted 4 lines

Sascha

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox

#3 lore raw
Quoted 22 lines · Peter Mamonov
Quoted 19 lines · On Fri, 9 Oct 2015 08:31:49 +0200 Sascha Hauer <[email protected]> wrote:
Quoted 9 lines · Peter Mamonov
---
 fs/fs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/fs.c +0 -0
index c041e41..6283cea 100644

fs/fs.c EXPORT_SYMBOL(register_fs_driver); · line 1204

Quoted 5 lines
fs/fs.c +1 -1
@@ -1201,7 +1201,7 @@ EXPORT_SYMBOL(register_fs_driver);
 
 static const char *detect_fs(const char *filename)
 {
-	enum filetype type = cdev_detect_type(filename);
+	enum filetype type = cdev_detect_type(basename(filename));

basename is not so nice since we do not know whether the the part of the path we drop is really what we expect. Can we rather have a:

Quoted 4 lines
Quoted 2 lines
	if (!strncmp(filename, "/dev/", 5))
		filename += 5;

What if devfs is mounted somehere else (not on /dev)?

Hm, Let's erm, consider that not supported ;)
We already have some places where we expect devfs mounted to /dev/. Not particularly nice I must admit.

Quoted 30 lines

Let me clarify the situation. After applying "detect_fs: use device instead of file" the mount command becomes completely broken for me, since detect_fs() is supplied with the full path to the device file, while cdev_by_name() expects device file name rather than full path:

static const char *detect_fs(const char *filename)

{
	enum filetype type = cdev_detect_type(filename);
	...
	if (type == filetype_unknown)
		return NULL;
	...
}
struct cdev *cdev_by_name(const char *filename)
{
	struct cdev *cdev;

	list_for_each_entry(cdev, &cdev_list, list) {
		if (!strcmp(cdev->name, filename)) <<<<<<< NO MATCH
			return cdev;
	}
	return NULL;
}
struct cdev {
	...
	char *name; /* filename under /dev/ */
	...
}
Quoted 3 lines

Can you explain how could it work for Vicente:
http://lists.infradead.org/pipermail/barebox/2015-October/024832.html
?

Presumely He passes the device name (without /dev/) to mount.

Sascha

Signature · 9 lines
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#4 lore raw
Quoted 62 lines · Sascha Hauer
Quoted 22 lines · Peter Mamonov
Quoted 19 lines · On Fri, 9 Oct 2015 08:31:49 +0200 Sascha Hauer <[email protected]> wrote:
Quoted 9 lines · Peter Mamonov
---
 fs/fs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/fs.c +0 -0
index c041e41..6283cea 100644

fs/fs.c EXPORT_SYMBOL(register_fs_driver); · line 1204

Quoted 5 lines
fs/fs.c +1 -1
@@ -1201,7 +1201,7 @@ EXPORT_SYMBOL(register_fs_driver);
 
 static const char *detect_fs(const char *filename)
 {
- enum filetype type = cdev_detect_type(filename);
+ enum filetype type = cdev_detect_type(basename(filename));

basename is not so nice since we do not know whether the the part of the path we drop is really what we expect. Can we rather have a:

Quoted 4 lines
Quoted 2 lines
    if (!strncmp(filename, "/dev/", 5))
            filename += 5;

What if devfs is mounted somehere else (not on /dev)?

Hm, Let's erm, consider that not supported ;)
We already have some places where we expect devfs mounted to /dev/. Not particularly nice I must admit.

Quoted 30 lines

Let me clarify the situation. After applying "detect_fs: use device instead of file" the mount command becomes completely broken for me, since detect_fs() is supplied with the full path to the device file, while cdev_by_name() expects device file name rather than full path:

static const char *detect_fs(const char *filename)

{
      enum filetype type = cdev_detect_type(filename);
      ...
      if (type == filetype_unknown)
              return NULL;
      ...
}
struct cdev *cdev_by_name(const char *filename)
{
      struct cdev *cdev;

      list_for_each_entry(cdev, &cdev_list, list) {
              if (!strcmp(cdev->name, filename)) <<<<<<< NO MATCH
                      return cdev;
      }
      return NULL;
}
struct cdev {
      ...
      char *name; /* filename under /dev/ */
      ...
}
Quoted 5 lines
Quoted 3 lines

Can you explain how could it work for Vicente:
http://lists.infradead.org/pipermail/barebox/2015-October/024832.html
?

Presumely He passes the device name (without /dev/) to mount.

Yes, that is correct, from
http://git.pengutronix.de/?p=barebox.git;a=blob;f=arch/arm/mach-omap/xload.c#l104
what is mount is just the partition name.
The only thing is that it is not me, that was already there.

Regards,
Vicente.

Quoted 8 lines

Sascha

--

Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox