Skip to contentSkip to conversation

mode_t: linux/types.h vs. glibc's sys/types.h

DISCUSSION John Z. Bohach 1 participant 1 message Aug 23, 2007

lore
Share & tools
lore
#0 lore raw

Howdy,

I've tried googling for this, and searched the archives as well, but I haven't found a satisfactory answer. My apologies if this is covered somewhere...

The kernel's linux/types.h resolves mode_t to __kernel_mode_t which is then defined as:

typedef unsigned short __kernel_mode_t;

in linux/posix_types.h.

However, glibc's sys/types.h eventually (in bits/typesizes.h) resolves mode_t to:

#define __MODE_T_TYPE __U32_TYPE

So, when I try to pass a mode_t type from kernel space to user space, the kernel sends a short when the user space expects an int. I of course declare my variable as 'mode_t' both in my kernel module and in my user-space app., with the above inconsistency.

I can get around this easily enough by sending/receiving __u32, but I'm trying to be a little more type-safe...

Is this something that is intentional, or is this an inconsistency between linux and glibc? I've verified this both on 2.6.16.47 and 2.6.20.6. Any ideas?

Thanks,
John