mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* Re: [PATCH] NFS dev_t fixes
@ 2003-02-02 14:53 shaheed
  0 siblings, 0 replies; 3+ messages in thread
From: shaheed @ 2003-02-02 14:53 UTC (permalink / raw)
  To: Andries.Brouwer; +Cc: linux-kernel


Andries,

Just a thought...did you intend to use two slightly different types for 
major/minor? You say in nfs3xdr.c:

xdr_decode_fattr(u32 *p, struct nfs_fattr *fattr) 
 { 
...
	unsigned int type, major, minor; 
...
 	major = ntohl(*p++); 
	minor = ntohl(*p++); 

and later on in nfs4xdr.c:

	uint32_t major, minor; 
...
	READ32(major); 
	READ32(minor); 

I wonder if the real cause here is the different coding conventions of the two 
modules...

HTH, Shaheed

^ permalink raw reply	[flat|nested] 3+ messages in thread
* Re: [PATCH] NFS dev_t fixes
@ 2003-02-02 15:01 Andries.Brouwer
  0 siblings, 0 replies; 3+ messages in thread
From: Andries.Brouwer @ 2003-02-02 15:01 UTC (permalink / raw)
  To: Andries.Brouwer, srhaque; +Cc: linux-kernel

    Just a thought...did you intend to use two slightly different types for 
    major/minor?

Yes - principle of minimal change.

Andries

^ permalink raw reply	[flat|nested] 3+ messages in thread
* [PATCH] NFS dev_t fixes
@ 2003-02-02  0:38 Andries.Brouwer
  0 siblings, 0 replies; 3+ messages in thread
From: Andries.Brouwer @ 2003-02-02  0:38 UTC (permalink / raw)
  To: torvalds, trond.myklebust; +Cc: linux-kernel

The NFS code knows too much about the structure of a dev_t.
Below some equivalent code that will remain correct also
for a 32-bit dev_t.

Andries


diff -u --recursive --new-file -X /linux/dontdiff a/fs/nfs/nfs3xdr.c b/fs/nfs/nfs3xdr.c
--- a/fs/nfs/nfs3xdr.c	Wed Jan  1 23:54:24 2003
+++ b/fs/nfs/nfs3xdr.c	Sun Feb  2 00:57:47 2003
@@ -146,7 +146,7 @@
 static u32 *
 xdr_decode_fattr(u32 *p, struct nfs_fattr *fattr)
 {
-	unsigned int	type;
+	unsigned int	type, major, minor;
 	int		fmode;
 
 	type = ntohl(*p++);
@@ -160,9 +160,12 @@
 	fattr->gid = ntohl(*p++);
 	p = xdr_decode_hyper(p, &fattr->size);
 	p = xdr_decode_hyper(p, &fattr->du.nfs3.used);
+
 	/* Turn remote device info into Linux-specific dev_t */
-	fattr->rdev = ntohl(*p++) << MINORBITS;
-	fattr->rdev |= ntohl(*p++) & MINORMASK;
+	major = ntohl(*p++);
+	minor = ntohl(*p++);
+	fattr->rdev = MKDEV(major, minor);
+
 	p = xdr_decode_hyper(p, &fattr->fsid_u.nfs3);
 	p = xdr_decode_hyper(p, &fattr->fileid);
 	p = xdr_decode_time3(p, &fattr->atime);
@@ -412,8 +415,8 @@
 	*p++ = htonl(args->type);
 	p = xdr_encode_sattr(p, args->sattr);
 	if (args->type == NF3CHR || args->type == NF3BLK) {
-		*p++ = htonl(args->rdev >> MINORBITS);
-		*p++ = htonl(args->rdev & MINORMASK);
+		*p++ = htonl(MAJOR(args->rdev));
+		*p++ = htonl(MINOR(args->rdev));
 	}
 
 	req->rq_slen = xdr_adjust_iovec(req->rq_svec, p);
diff -u --recursive --new-file -X /linux/dontdiff a/fs/nfs/nfs4xdr.c b/fs/nfs/nfs4xdr.c
--- a/fs/nfs/nfs4xdr.c	Thu Jan  9 18:07:16 2003
+++ b/fs/nfs/nfs4xdr.c	Sun Feb  2 00:55:22 2003
@@ -1385,13 +1385,14 @@
                 dprintk("read_attrs: gid=%d\n", (int)nfp->gid);
         }
         if (bmval1 & FATTR4_WORD1_RAWDEV) {
-                READ_BUF(8);
-                len += 8;
-                READ32(dummy32);
-		nfp->rdev = (dummy32 << MINORBITS);
-                READ32(dummy32);
-		nfp->rdev |= (dummy32 & MINORMASK);
-                dprintk("read_attrs: rdev=%d\n", nfp->rdev);
+		uint32_t major, minor;
+
+		READ_BUF(8);
+		len += 8;
+		READ32(major);
+		READ32(minor);
+		nfp->rdev = MKDEV(major, minor);
+		dprintk("read_attrs: rdev=0x%x\n", nfp->rdev);
         }
         if (bmval1 & FATTR4_WORD1_SPACE_AVAIL) {
                 READ_BUF(8);

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2003-02-02 14:51 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-02-02 14:53 [PATCH] NFS dev_t fixes shaheed
  -- strict thread matches above, loose matches on Subject: below --
2003-02-02 15:01 Andries.Brouwer
2003-02-02  0:38 Andries.Brouwer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome