Example #1
0
static int
rtems_rfs_rtems_fchmod (const rtems_filesystem_location_info_t* pathloc,
                        mode_t                                  mode)
{
  rtems_rfs_file_system*  fs = rtems_rfs_rtems_pathloc_dev (pathloc);
  rtems_rfs_ino           ino = rtems_rfs_rtems_get_pathloc_ino (pathloc);
  rtems_rfs_inode_handle  inode;
  int                     rc;

  if (rtems_rfs_rtems_trace (RTEMS_RFS_RTEMS_DEBUG_FCHMOD))
    printf ("rtems-rfs-rtems: fchmod: in: ino:%" PRId32 " mode:%06" PRIomode_t "\n",
            ino, mode);

  rc = rtems_rfs_inode_open (fs, ino, &inode, true);
  if (rc)
  {
    return rtems_rfs_rtems_error ("fchmod: opening inode", rc);
  }

  rtems_rfs_inode_set_mode (&inode, mode);

  rc = rtems_rfs_inode_close (fs, &inode);
  if (rc > 0)
  {
    return rtems_rfs_rtems_error ("fchmod: closing inode", rc);
  }

  return 0;
}
Example #2
0
static int
rtems_rfs_rtems_fchmod (const rtems_filesystem_location_info_t* pathloc,
                        mode_t                                  mode)
{
  rtems_rfs_file_system*  fs = rtems_rfs_rtems_pathloc_dev (pathloc);
  rtems_rfs_ino           ino = rtems_rfs_rtems_get_pathloc_ino (pathloc);
  rtems_rfs_inode_handle  inode;
  uint16_t                imode;
#if defined (RTEMS_POSIX_API)
  uid_t                   uid;
#endif
  int                     rc;

  if (rtems_rfs_rtems_trace (RTEMS_RFS_RTEMS_DEBUG_FCHMOD))
    printf ("rtems-rfs-rtems: fchmod: in: ino:%" PRId32 " mode:%06" PRIomode_t "\n",
            ino, mode);

  rc = rtems_rfs_inode_open (fs, ino, &inode, true);
  if (rc)
  {
    return rtems_rfs_rtems_error ("fchmod: opening inode", rc);
  }

  imode = rtems_rfs_inode_get_mode (&inode);

  /*
   *  Verify I am the owner of the node or the super user.
   */
#if defined (RTEMS_POSIX_API)
  uid = geteuid();

  if ((uid != rtems_rfs_inode_get_uid (&inode)) && (uid != 0))
  {
    rtems_rfs_inode_close (fs, &inode);
    return rtems_rfs_rtems_error ("fchmod: checking uid", EPERM);
  }
#endif

  imode &= ~(S_IRWXU | S_IRWXG | S_IRWXO | S_ISUID | S_ISGID | S_ISVTX);
  imode |= mode & (S_IRWXU | S_IRWXG | S_IRWXO | S_ISUID | S_ISGID | S_ISVTX);

  rtems_rfs_inode_set_mode (&inode, imode);

  rc = rtems_rfs_inode_close (fs, &inode);
  if (rc > 0)
  {
    return rtems_rfs_rtems_error ("fchmod: closing inode", rc);
  }

  return 0;
}
Example #3
0
int
rtems_rfs_inode_initialise (rtems_rfs_inode_handle* handle,
                            uint16_t                links,
                            uint16_t                mode,
                            uid_t                   uid,
                            gid_t                   gid)
{
  int b;
  rtems_rfs_inode_set_links (handle, links);
  rtems_rfs_inode_set_flags (handle, 0);
  rtems_rfs_inode_set_mode (handle,  mode);
  rtems_rfs_inode_set_uid_gid (handle, uid, gid);
  rtems_rfs_inode_set_block_offset (handle, 0);
  rtems_rfs_inode_set_block_count (handle, 0);
  for (b = 0; b < RTEMS_RFS_INODE_BLOCKS; b++)
    rtems_rfs_inode_set_block (handle, b, 0);
  rtems_rfs_inode_set_last_map_block (handle, 0);
  rtems_rfs_inode_set_last_data_block (handle, 0);
  return rtems_rfs_inode_time_stamp_now (handle, true, true);
}