[comp.sys.nsc.32k] How to define mode_t

sverre@lev.Seri.GOV (Sverre Froyen) (02/07/91)

In Minix 1.5.10 mode_t is used inconsistently.  In sys/types.h
it is defined as unsigned short whereas in the prototypes in
fcntl.h it is (implicitly) assumed to be both int and unsigned int.
This causes, among other things, the compiler to choke on estdio.
It is of course easy to fix once I find out what mode_t should
_really_ be.  Anyone knows?

Sverre
-- 
Sverre Froyen
sverre@seri.gov, sunpeaks!seri!sverre

news@bungi.com.YorkU.CA (02/08/91)

[ Sverre writes ]

> In Minix 1.5.10 mode_t is used inconsistently.  In sys/types.h
> it is defined as unsigned short whereas in the prototypes in
> fcntl.h it is (implicitly) assumed to be both int and unsigned int.
> This causes, among other things, the compiler to choke on estdio.
> It is of course easy to fix once I find out what mode_t should
> _really_ be.  Anyone knows?

Well looking at POSIX 1003.1 it appears that:

1) per section 2.6 primitive data types appearing in /usr/include/sys/types.h
   are implementation dependent.  Further it indicateds that mode_t should
   be of arithmetic type -- which I assume means unsigned.

2) section B.2.6 also indicates that for historical reasons only the lower
   order 16-bits are significant.  Further it indicates BSD4.3 and SVID
   define it as unsigned short.

Therefore, it would appear that you can define it as either unsigned short
or unsigned int, as long as you are consistent.  Since Minix sys/types.h
definition is unsigned short, my quess is that AST's intention is to be 
consistent with historical definitions -- unsigned short.

-- 
John Connin: manatee Orlando, Florida
         UUCP: {uunet,ge-dab,ucf-cs}!tarpit!tous!manatee!johnc