X-Authentication-Warning: delorie.com: mail set sender to djgpp-workers-bounces using -f X-Recipient: djgpp-workers AT delorie DOT com X-Authenticated: #27081556 X-Provags-ID: V01U2FsdGVkX18DxU5mCigDVdJROQLe/lYZXEIbrUVs92qoEEu1oV IWfV7uCQjuzML/ Message-ID: <5182B57E.10301@gmx.de> Date: Thu, 02 May 2013 20:50:38 +0200 From: Juan Manuel Guerrero User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:16.0) Gecko/20121025 Thunderbird/16.0.2 MIME-Version: 1.0 To: djgpp-workers AT delorie DOT com Subject: Re: The encoding of S_IFREG References: <201305011954 DOT r41JsMnW006530 AT dexter DOT ludd DOT ltu DOT se> In-Reply-To: <201305011954.r41JsMnW006530@dexter.ludd.ltu.se> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Y-GMX-Trusted: 0 Reply-To: djgpp-workers AT delorie DOT com Am 01.05.2013 21:54, schrieb Martin Str|mberg: > According to Juan Manuel Guerrero: [snip] > I'd think the thinking was, set a bit to indicate some special thing > about this "file". So if no bit is set then it must be a regular file. Yes, I assumed something like that. I could accept this if it would be necessary to save bits or place. > 1. Why would 0 not be a valid indication? Does a/the spec say so? I > think this is a bug in the code your trying to port. I do not know if some spec say so but I have looked at sys/stat.h of linux, bsd and cygwin. No one of those set any one of those bits stored in st_mode to zero. This seems to be a djgpp choice. May be the intention was to be compatible to some old borland compiler. But keeping that compatibility with a compiler that has stopped to be sold 20 years ago should not be a reason nowadays. In the code to port, the file type is identified by setting certain flag to the appropriate S_IF* bit. If this flag becomes zero it is assumed that some thing has gone wrong. This way of coding may be considered a bug because the spec does not say that all S_IF* bits must be different from zero. But the systems I have inspected set no one of this bits to zero so that the code works almost everywhere except for djgpp. > 2. Is st_mode 16 bits in DJGPP? Otherwise why not use 0x10000? I do not thing so because some file mode bits like S_ISUID is set to 0x80000000. Neitherless I do not think the value should be set to 0x10000. S_IFMT has been chosen to be 0xf000 and the file type bits go from 0x0000 to 0x8000. So if the 0x0000 value should be replaced it should be replaced by a value in this range if possible. In this case 0x6000 or 0x7000 would be a good choice. #define S_IFREG 0x0000 #define S_IFBLK 0x1000 #define S_IFCHR 0x2000 #define S_IFDIR 0x3000 #define S_IFIFO 0x4000 #define S_IFLABEL 0x5000 #define S_IFLNK 0x8000 Regards, Juan M. Guerrero