Skip to contentSkip to conversation

new system call mknod64

PATCH [email protected] 4 participants 6 messages Apr 22, 2003

lore
Share & tools
lore
#0 lore raw

[You prefer sending to l-k only. But my mailbox is [email protected], 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.]

Quoted 3 lines
Quoted 1 line

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)

Quoted 5 lines
Quoted 2 lines

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

#1 lore raw
Followup to:  <[email protected]>
By author:    [email protected]
In newsgroup: linux.dev.kernel
Quoted 5 lines

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.

The main advantage with making it a struct is that it keep people from doing stupid stuff like (int)dev where dev is a kdev_t... There is all kinds of shit like that in the kernel...

-hpa

Signature · 3 lines
<[email protected]> at work, <[email protected]> in private!
"Unix gives you enough rope to shoot yourself in the foot."
Architectures needed: ia64 m68k mips64 ppc ppc64 s390 s390x sh v850 x86-64
#2 lore raw
Quoted 8 lines · H. Peter Anvin
Quoted 4 lines

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.

The main advantage with making it a struct is that it keep people from doing stupid stuff like (int)dev where dev is a kdev_t... There is all kinds of shit like that in the kernel...

If you want that good quality 64-bit code, try making it a struct containing just a u64 :)

-- Jamie

#3 lore raw
Quoted 8 lines · Jamie Lokier
Quoted 4 lines

The main advantage with making it a struct is that it keep people from doing stupid stuff like (int)dev where dev is a kdev_t... There is all kinds of shit like that in the kernel...

If you want that good quality 64-bit code, try making it a struct containing just a u64 :)

Perhaps:

#if BITS_PER_LONG == 64
typedef struct { u64 val; } kdev_t;

/* Macros for major minor mkdev */
#else
typedef struct { u32 major, minor; } kdev_t;

/* Macros... */
#endif

-hpa

#4 lore raw
Quoted 15 lines · H. Peter Anvin
Quoted 8 lines · Jamie Lokier
Quoted 4 lines

The main advantage with making it a struct is that it keep people from doing stupid stuff like (int)dev where dev is a kdev_t... There is all kinds of shit like that in the kernel...

If you want that good quality 64-bit code, try making it a struct containing just a u64 :)

Perhaps:

#if BITS_PER_LONG == 64
typedef struct { u64 val; } kdev_t;

Quoted 7 lines

/* Macros for major minor mkdev */
#else
typedef struct { u32 major, minor; } kdev_t;

/* Macros... */
#endif

or a union?
typedef union { u64 dev; struct { u32 major, minor; } d; } kdev_t;

<duck>

Signature · 5 lines
________________________________________________________________
	J.W. Schultz            Pegasystems Technologies
	email address:		[email protected]

		Remember Cernan and Schmitt
#5 lore raw
Followup to:  <[email protected]>
By author:    jw schultz <[email protected]>
In newsgroup: linux.dev.kernel
Quoted 21 lines · H. Peter Anvin
Quoted 19 lines
Quoted 8 lines · Jamie Lokier
Quoted 4 lines

The main advantage with making it a struct is that it keep people from doing stupid stuff like (int)dev where dev is a kdev_t... There is all kinds of shit like that in the kernel...

If you want that good quality 64-bit code, try making it a struct containing just a u64 :)

Perhaps:

#if BITS_PER_LONG == 64
typedef struct { u64 val; } kdev_t;

/* Macros for major minor mkdev */
#else
typedef struct { u32 major, minor; } kdev_t;

Quoted 7 lines
Quoted 3 lines

/* Macros... */
#endif

or a union?
typedef union { u64 dev; struct { u32 major, minor; } d; } kdev_t;

No... what I want to avoid, again, are idiots^Wpeople doing:

      foo = (int) dev->dev;

... or something like that.

-hpa

Signature · 3 lines
<[email protected]> at work, <[email protected]> in private!
"Unix gives you enough rope to shoot yourself in the foot."
Architectures needed: ia64 m68k mips64 ppc ppc64 s390 s390x sh v850 x86-64