Changeset 4af18b3 in rtems for cpukit


Ignore:
Timestamp:
Oct 11, 2018, 8:51:21 AM (10 months ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
master
Children:
35eab84
Parents:
68799dac
git-author:
Sebastian Huber <sebastian.huber@…> (10/11/18 08:51:21)
git-committer:
Sebastian Huber <sebastian.huber@…> (10/18/18 09:11:24)
Message:

Support O_DIRECTORY open() flag

Close #3545.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • cpukit/libcsupport/src/open.c

    r68799dac r4af18b3  
    7474  bool exclusive = (oflag & (O_CREAT | O_EXCL)) == (O_CREAT | O_EXCL);
    7575  bool truncate = (oflag & O_TRUNC) == O_TRUNC;
     76  bool open_dir;
    7677  int eval_flags = RTEMS_FS_FOLLOW_LINK
    7778    | (read_access ? RTEMS_FS_PERMS_READ : 0)
     
    8788  }
    8889
    89   if ( write_access ) {
     90#ifdef O_DIRECTORY
     91  open_dir = ( oflag & O_DIRECTORY ) == O_DIRECTORY;
     92#else
     93  open_dir = false;
     94#endif
     95
     96  if ( write_access || open_dir ) {
    9097    const rtems_filesystem_location_info_t *currentloc =
    9198      rtems_filesystem_eval_path_get_currentloc( &ctx );
    9299    mode_t type = rtems_filesystem_location_type( currentloc );
    93100
    94     if ( S_ISDIR( type ) ) {
     101    if ( write_access && S_ISDIR( type ) ) {
    95102      rtems_filesystem_eval_path_error( &ctx, EISDIR );
     103    }
     104
     105    if ( open_dir && !S_ISDIR( type ) ) {
     106      rtems_filesystem_eval_path_error( &ctx, ENOTDIR );
    96107    }
    97108  }
Note: See TracChangeset for help on using the changeset viewer.