linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Re: [PATCH] new system call mknod64
@ 2003-04-22  1:02 Andries.Brouwer
  2003-04-22  1:32 ` H. Peter Anvin
  0 siblings, 1 reply; 43+ messages in thread
From: Andries.Brouwer @ 2003-04-22  1:02 UTC (permalink / raw)
  To: hpa, linux-kernel

[You prefer sending to l-k only. But my mailbox is aeb@cwi.nl,
and l-k is read elsewhere. What you send there I may or may not see.
If you want me to see it, please cc.]

>> u64, or, if you prefer, as struct { u32 major, minor; }.

> Any reason why we don't just *make it* a struct?

Well, I have also done that of course. Both struct and u64 work well.
Since only kdev_t.h knows about the actual structure of kdev_t
it is very easy to switch.

--------------
typedef struct {
        u32 major;
        u32 minor;
} kdev_t;

#define major(dev)      ((dev).major)
#define minor(dev)      ((dev).minor)
#define mk_kdev(major, minor)   ((kdev_t) { major, minor } )

#define HASHDEV(dev)    (major(dev) ^ minor(dev))       /* arbitrary */
#define NODEV           (mk_kdev(0,0))
#define kdev_none(dev)  (major(dev) == 0 && minor(dev) == 0)

static inline int kdev_same(kdev_t dev1, kdev_t dev2)
{
        return (dev1.major == dev2.major) && (dev1.minor == dev2.minor);
}
--------------

(there are some defines in the tty code that have to be adapted,
that is all)


>> sys_mknod takes unsigned int (instead of dev_t)
>> sys_mknod64 takes two unsigned ints.

> Why unsigned int?  If we have a legacy call it should presumably use
> the legacy __u16 format.

That would become rather ugly. The present situation is not u16,
it depends on the architecture. But unsigned int covers the
present situation on all architectures.

Andries

^ permalink raw reply	[flat|nested] 43+ messages in thread
[parent not found: <20030421215009$2052@gated-at.bofh.it>]
* Re: [PATCH] new system call mknod64
@ 2003-04-21 21:48 Andries.Brouwer
  2003-04-21 22:07 ` Linus Torvalds
  0 siblings, 1 reply; 43+ messages in thread
From: Andries.Brouwer @ 2003-04-21 21:48 UTC (permalink / raw)
  To: Andries.Brouwer, davem, hch, linux-kernel, torvalds, viro, zippel

> Let's go for 32:32 internal and simply map upon mknod(2) and friends.
> On the syscall boundary.  End of problem.

Yes. I hope you don't mind that I called this 32:32 monster kdev_t.

^ permalink raw reply	[flat|nested] 43+ messages in thread
* Re: [PATCH] new system call mknod64
@ 2003-04-21 21:43 Andries.Brouwer
  2003-04-21 23:02 ` H. Peter Anvin
  0 siblings, 1 reply; 43+ messages in thread
From: Andries.Brouwer @ 2003-04-21 21:43 UTC (permalink / raw)
  To: torvalds, viro; +Cc: Andries.Brouwer, davem, hch, linux-kernel, zippel

Nice to see this discussion.

Linus says

> The question is only _where_ (not whether) we do the mapping. Right now we 
> keep "dev_t" in the same format as we give back to user space, and thus we 
> always map into that format internally. But we don't have to: we can have 
> an internal format that is different from the one we show users.

and in fact the patches I have been giving out use kdev_t
as internal format, where you can think of kdev_t as
u64, or, if you prefer, as struct { u32 major, minor; }.

As I wrote a month or two ago, my favourite version is to
have register_region work in the kdev_t space, rather than
the dev_t space, since intervals in kdev_t space have a
direct interpretation in terms of major, minor.

Andries

(Both versions do not differ very much;
as far as I am concerned the choice is not very important,
but the kdev_t version is slightly cleaner.)

(As Al already remarked, device numbers do not play much of a role
internally. I removed i_dev. We still have i_rdev.)


^ permalink raw reply	[flat|nested] 43+ messages in thread
* Re: [PATCH] new system call mknod64
@ 2003-04-20 22:12 Andries.Brouwer
  2003-04-21  6:31 ` H. Peter Anvin
  0 siblings, 1 reply; 43+ messages in thread
From: Andries.Brouwer @ 2003-04-20 22:12 UTC (permalink / raw)
  To: davem, torvalds; +Cc: Andries.Brouwer, hch, linux-kernel

> the _right_ interface is keeping the <major, minor> tuple explicit

Good! I debated with myself and changed three times between

	mknod64(path, mode, major, minor);

and

	mknod64(path, mode, devhi, devlo);

This becomes the fourth time.

Andries


[My choice is still unsigned int major, minor.
Do you prefer __u32?]

^ permalink raw reply	[flat|nested] 43+ messages in thread
* Re: [PATCH] new system call mknod64
@ 2003-04-20 21:26 Andries.Brouwer
  2003-04-20 21:43 ` David S. Miller
  0 siblings, 1 reply; 43+ messages in thread
From: Andries.Brouwer @ 2003-04-20 21:26 UTC (permalink / raw)
  To: Andries.Brouwer, davem; +Cc: hch, linux-kernel, torvalds

    From davem@redhat.com  Sun Apr 20 23:12:17 2003

    > Yesterday or the day before Linus preferred __u32 etc for this
    > loopinfo64 ioctl, so I did it that way. Here, since mknod is a
    > traditional Unix system call, I am still inclined to prefer
    > (unsigned) int above __u32.  Of course it doesn't matter much.

    To 64-bit platforms implementing 32-bit compatability layers,
    it can matter a ton to use portable vs. non-portable types.

Such an abstract statement nobody can disagree with.
Do you have an opinion in the mknod case?

(For example, I do not suppose anybody would argue that
open() should return an __u32 instead of an int.)

Andries

^ permalink raw reply	[flat|nested] 43+ messages in thread
* Re: [PATCH] new system call mknod64
@ 2003-04-20 20:34 Andries.Brouwer
  2003-04-20 21:12 ` David S. Miller
  0 siblings, 1 reply; 43+ messages in thread
From: Andries.Brouwer @ 2003-04-20 20:34 UTC (permalink / raw)
  To: Andries.Brouwer, hch; +Cc: linux-kernel, torvalds

    From: Christoph Hellwig <hch@infradead.org>

    On Sun, Apr 20, 2003 at 08:39:32PM +0200, Andries.Brouwer@cwi.nl wrote:
    > Change the type of the mknod arg from dev_t to unsigned int.
    > Add (for i386) mknod64.

    Please make the argument for mknod/mknod64 __u32/__u64.  And I
    don't think adding the syscall makes sense before the internal
    dev_t representation has changed.

Yes, there is a dozen rather uninteresting patches that can
be applied any moment. But a new system call is more important,
so I show it in public at some earlier stage, so that Linus and
others, like you, can comment.

Yesterday or the day before Linus preferred __u32 etc for this
loopinfo64 ioctl, so I did it that way. Here, since mknod is a
traditional Unix system call, I am still inclined to prefer
(unsigned) int above __u32.  Of course it doesn't matter much.

Andries

^ permalink raw reply	[flat|nested] 43+ messages in thread
* [PATCH] new system call mknod64
@ 2003-04-20 18:39 Andries.Brouwer
  2003-04-20 18:52 ` Christoph Hellwig
  0 siblings, 1 reply; 43+ messages in thread
From: Andries.Brouwer @ 2003-04-20 18:39 UTC (permalink / raw)
  To: torvalds; +Cc: linux-kernel

Change the type of the mknod arg from dev_t to unsigned int.
Add (for i386) mknod64.

diff -u --recursive --new-file -X /linux/dontdiff a/arch/i386/kernel/entry.S b/arch/i386/kernel/entry.S
--- a/arch/i386/kernel/entry.S	Tue Mar 25 04:54:29 2003
+++ b/arch/i386/kernel/entry.S	Sun Apr 20 19:13:34 2003
@@ -852,6 +852,7 @@
  	.long sys_clock_gettime		/* 265 */
  	.long sys_clock_getres
  	.long sys_clock_nanosleep
+	.long sys_mknod64
  
  
 nr_syscalls=(.-sys_call_table)/4
diff -u --recursive --new-file -X /linux/dontdiff a/fs/namei.c b/fs/namei.c
--- a/fs/namei.c	Sun Apr 20 12:59:32 2003
+++ b/fs/namei.c	Sun Apr 20 19:13:34 2003
@@ -1403,11 +1403,12 @@
 	return error;
 }
 
-asmlinkage long sys_mknod(const char __user * filename, int mode, dev_t dev)
+static long
+do_mknod(const char __user *filename, int mode, dev_t dev)
 {
 	int error = 0;
-	char * tmp;
-	struct dentry * dentry;
+	char *tmp;
+	struct dentry *dentry;
 	struct nameidata nd;
 
 	if (S_ISDIR(mode))
@@ -1448,6 +1449,19 @@
 	return error;
 }
 
+asmlinkage long
+sys_mknod(const char __user *filename, int mode, unsigned int dev)
+{
+	return do_mknod(filename, mode, dev);
+}
+
+asmlinkage long
+sys_mknod64(const char __user *filename, int mode,
+	    unsigned int devhi, unsigned int devlo)
+{
+	return do_mknod(filename, mode, ((u64) devhi << 32) + devlo);
+}
+
 int vfs_mkdir(struct inode *dir, struct dentry *dentry, int mode)
 {
 	int error = may_create(dir, dentry);
@@ -2140,8 +2154,8 @@
 {
 	struct page * page;
 	struct address_space *mapping = dentry->d_inode->i_mapping;
-	page = read_cache_page(mapping, 0, (filler_t *)mapping->a_ops->readpage,
-				NULL);
+	page = read_cache_page(mapping, 0,
+			       (filler_t *)mapping->a_ops->readpage, NULL);
 	if (IS_ERR(page))
 		goto sync_fail;
 	wait_on_page_locked(page);
diff -u --recursive --new-file -X /linux/dontdiff a/include/asm-i386/unistd.h b/include/asm-i386/unistd.h
--- a/include/asm-i386/unistd.h	Mon Feb 24 23:02:56 2003
+++ b/include/asm-i386/unistd.h	Sun Apr 20 19:13:34 2003
@@ -273,8 +273,9 @@
 #define __NR_clock_gettime	(__NR_timer_create+6)
 #define __NR_clock_getres	(__NR_timer_create+7)
 #define __NR_clock_nanosleep	(__NR_timer_create+8)
+#define __NR_sys_mknod64	268
 
-#define NR_syscalls 268
+#define NR_syscalls 269
 
 /* user-visible error numbers are in the range -1 - -124: see <asm-i386/errno.h> */
 

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

end of thread, other threads:[~2003-04-22 19:52 UTC | newest]

Thread overview: 43+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-04-22  1:02 [PATCH] new system call mknod64 Andries.Brouwer
2003-04-22  1:32 ` H. Peter Anvin
2003-04-22  2:01   ` Jamie Lokier
2003-04-22  2:52     ` H. Peter Anvin
2003-04-22  6:00       ` jw schultz
2003-04-22 17:17         ` H. Peter Anvin
     [not found] <20030421215009$2052@gated-at.bofh.it>
     [not found] ` <20030421231010$7ee3@gated-at.bofh.it>
     [not found]   ` <20030422000016$17e3@gated-at.bofh.it>
     [not found]     ` <20030422083014$0fe2@gated-at.bofh.it>
2003-04-22 20:02       ` Arnd Bergmann
  -- strict thread matches above, loose matches on Subject: below --
2003-04-21 21:48 Andries.Brouwer
2003-04-21 22:07 ` Linus Torvalds
2003-04-21 21:43 Andries.Brouwer
2003-04-21 23:02 ` H. Peter Anvin
2003-04-21 23:50   ` Jamie Lokier
2003-04-22  8:24     ` Shachar Shemesh
2003-04-20 22:12 Andries.Brouwer
2003-04-21  6:31 ` H. Peter Anvin
2003-04-20 21:26 Andries.Brouwer
2003-04-20 21:43 ` David S. Miller
2003-04-20 21:56   ` Linus Torvalds
2003-04-21 11:59     ` Roman Zippel
2003-04-21 18:01       ` Linus Torvalds
2003-04-21 18:10         ` Christoph Hellwig
2003-04-21 18:21           ` viro
2003-04-21 18:22           ` Linus Torvalds
2003-04-21 18:27             ` viro
2003-04-21 18:35               ` Linus Torvalds
2003-04-21 18:54                 ` viro
2003-04-21 19:16                   ` Jörn Engel
2003-04-21 18:35             ` Christoph Hellwig
2003-04-21 18:42               ` H. Peter Anvin
2003-04-21 18:44               ` Linus Torvalds
2003-04-21 18:47                 ` Christoph Hellwig
2003-04-21 18:58                   ` viro
2003-04-21 19:05                     ` Linus Torvalds
2003-04-21 19:35                       ` viro
2003-04-21 20:02                         ` Linus Torvalds
2003-04-21 19:04                   ` Linus Torvalds
2003-04-21 19:59                     ` H. Peter Anvin
2003-04-21 18:51                 ` H. Peter Anvin
2003-04-21 23:49             ` Roman Zippel
2003-04-20 20:34 Andries.Brouwer
2003-04-20 21:12 ` David S. Miller
2003-04-20 18:39 Andries.Brouwer
2003-04-20 18:52 ` Christoph Hellwig

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).