#1749 closed defect (fixed)

mknod allows more than one file type in the mode flags

Reported by: Chris Johns Owned by: Chris Johns
Priority: normal Milestone: 4.10
Component: fs Version: 4.10
Severity: normal Keywords:
Cc: joel.sherrill@… Blocked By:
Blocking:

Description

This is not allowed. The standard states:

The file type for path is OR'ed into the mode argument, and the application shall select one of the following symbolic constants:

Name Description

S_IFIFO FIFO-special
S_IFCHR Character-special (non-portable)
S_IFDIR Directory (non-portable)
S_IFBLK Block-special (non-portable)
S_IFREG Regular (non-portable)

The mknod code also has:

if ( !(mode & (S_IFREG|S_IFCHR|S_IFBLK|S_IFIFO) ) )

rtems_set_errno_and_return_minus_one( EINVAL );

and sys/stat.h has:

#define _IFMT 0170000 /* type of file */
#define _IFDIR 0040000 /* directory */
#define _IFCHR 0020000 /* character special */
#define _IFBLK 0060000 /* block special */
#define _IFREG 0100000 /* regular */
#define _IFLNK 0120000 /* symbolic link */
#define _IFSOCK 0140000 /* socket */
#define _IFIFO 0010000 /* fifo */

where:

#define S_IFMT _IFMT
#define S_IFDIR _IFDIR
#define S_IFCHR _IFCHR
#define S_IFBLK _IFBLK
#define S_IFREG _IFREG
#define S_IFLNK _IFLNK
#define S_IFSOCK _IFSOCK
#define S_IFIFO _IFIFO

Notice these values are not bit for masking together, that are values for the S_IFMT field in the mode. For example S_IFDIR and S_IFBLK share bits and this is why mkdir works.

Change History (1)

comment:1 Changed on Mar 4, 2011 at 1:16:26 PM by Joel Sherrill

Resolution: fixed
Status: newclosed, joel.sherrill@oarcorp.com

Patch committed. Closing.

Note: See TracTickets for help on using tickets.