mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: blaisorblade_spam@yahoo.it
To: akpm@osdl.org
Cc: jdike@addtoit.com, linux-kernel@vger.kernel.org,
	user-mode-linux-devel@lists.sourceforge.net,
	blaisorblade_spam@yahoo.it
Subject: [patch 2/2] uml: fix major & minor handling in hostfs
Date: Thu, 07 Oct 2004 20:22:57 +0200	[thread overview]
Message-ID: <20041007182257.2D5B7D85E@zion.localdomain> (raw)


Currently hostfs passes the rdev value from stat() on the host as rdev value
to return to stat() on the guest; but we cannot pass rdev as is because glibc
and the kernel disagree about its definition. So we must decode it in a
major/minor couple with glibc macros and re-encode it in kernelspace code.

Signed-off-by: Paolo 'Blaisorblade' Giarrusso <blaisorblade_spam@yahoo.it>
---

 linux-2.6.9-current-paolo/fs/hostfs/hostfs.h      |    2 +-
 linux-2.6.9-current-paolo/fs/hostfs/hostfs_kern.c |   11 ++++++++---
 linux-2.6.9-current-paolo/fs/hostfs/hostfs_user.c |   10 +++++++---
 3 files changed, 16 insertions(+), 7 deletions(-)

diff -puN fs/hostfs/hostfs.h~uml-hostfs-fix-maj-min fs/hostfs/hostfs.h
--- linux-2.6.9-current/fs/hostfs/hostfs.h~uml-hostfs-fix-maj-min	2004-10-07 17:38:01.759274464 +0200
+++ linux-2.6.9-current-paolo/fs/hostfs/hostfs.h	2004-10-07 17:38:01.763273856 +0200
@@ -38,7 +38,7 @@ extern int stat_file(const char *path, u
 		     int *blksize_out, unsigned long long *blocks_out);
 extern int access_file(char *path, int r, int w, int x);
 extern int open_file(char *path, int r, int w, int append);
-extern int file_type(const char *path, int *rdev);
+extern int file_type(const char *path, int *maj, int *min);
 extern void *open_dir(char *path, int *err_out);
 extern char *read_dir(void *stream, unsigned long long *pos,
 		      unsigned long long *ino_out, int *len_out);
diff -puN fs/hostfs/hostfs_kern.c~uml-hostfs-fix-maj-min fs/hostfs/hostfs_kern.c
--- linux-2.6.9-current/fs/hostfs/hostfs_kern.c~uml-hostfs-fix-maj-min	2004-10-07 17:38:01.760274312 +0200
+++ linux-2.6.9-current-paolo/fs/hostfs/hostfs_kern.c	2004-10-07 17:38:01.764273704 +0200
@@ -18,6 +18,7 @@
 #include <linux/buffer_head.h>
 #include <linux/root_dev.h>
 #include <linux/statfs.h>
+#include <linux/kdev_t.h>
 #include <asm/uaccess.h>
 #include "hostfs.h"
 #include "kern_util.h"
@@ -230,7 +231,7 @@ static int read_inode(struct inode *ino)
 	if(name == NULL)
 		goto out;
 
-	if(file_type(name, NULL) == OS_TYPE_SYMLINK){
+	if(file_type(name, NULL, NULL) == OS_TYPE_SYMLINK){
 		name = follow_link(name);
 		if(IS_ERR(name)){
 			err = PTR_ERR(name);
@@ -523,13 +524,17 @@ static struct address_space_operations h
 static int init_inode(struct inode *inode, struct dentry *dentry)
 {
 	char *name;
-	int type, err = -ENOMEM, rdev;
+	int type, err = -ENOMEM;
+	int maj, min;
+	dev_t rdev = 0;
 
 	if(dentry){
 		name = dentry_name(dentry, 0);
 		if(name == NULL)
 			goto out;
-		type = file_type(name, &rdev);
+		type = file_type(name, &maj, &min);
+		/*Reencode maj and min with the kernel encoding.*/
+		rdev = MKDEV(maj, min);
 		kfree(name);
 	}
 	else type = OS_TYPE_DIR;
diff -puN fs/hostfs/hostfs_user.c~uml-hostfs-fix-maj-min fs/hostfs/hostfs_user.c
--- linux-2.6.9-current/fs/hostfs/hostfs_user.c~uml-hostfs-fix-maj-min	2004-10-07 17:38:01.761274160 +0200
+++ linux-2.6.9-current-paolo/fs/hostfs/hostfs_user.c	2004-10-07 17:38:01.764273704 +0200
@@ -54,14 +54,18 @@ int stat_file(const char *path, unsigned
 	return(0);
 }
 
-int file_type(const char *path, int *rdev)
+int file_type(const char *path, int *maj, int *min)
 {
  	struct stat64 buf;
 
 	if(lstat64(path, &buf) < 0)
 		return(-errno);
-	if(rdev != NULL)
-		*rdev = buf.st_rdev;
+	/*We cannot pass rdev as is because glibc and the kernel disagree
+	 *about its definition.*/
+	if(maj != NULL)
+		*maj = major(buf.st_rdev);
+	if(min != NULL)
+		*min = minor(buf.st_rdev);
 
 	if(S_ISDIR(buf.st_mode)) return(OS_TYPE_DIR);
 	else if(S_ISLNK(buf.st_mode)) return(OS_TYPE_SYMLINK);
_

                 reply	other threads:[~2004-10-07 18:28 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20041007182257.2D5B7D85E@zion.localdomain \
    --to=blaisorblade_spam@yahoo.it \
    --cc=akpm@osdl.org \
    --cc=jdike@addtoit.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=user-mode-linux-devel@lists.sourceforge.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®