change log for rtems (2011-03-15)
rtems-vc at rtems.org
rtems-vc at rtems.org
Tue Mar 15 08:10:52 UTC 2011
*ccj*:
2011-03-15 Chris Johns <chrisj at rtems.org>
* libfs/src/rfs/rtems-rfs-rtems-file.c,
libfs/src/rfs/rtems-rfs-rtems.c, libfs/src/rfs/rtems-rfs-rtems.h:
The fix to the removal of file_info from iop was broken. The
node_access field must be the inode number in the RFS because the
file system ops provides no way to tell is a stat call is the
result of stat, fstat, or lstat. The solution is to move the file
handle to node_access_2 which is also shared with doff but these
do not overlap.
M 1.2776 cpukit/ChangeLog
M 1.11 cpukit/libfs/src/rfs/rtems-rfs-rtems-file.c
M 1.6 cpukit/libfs/src/rfs/rtems-rfs-rtems.h
M 1.17 cpukit/libfs/src/rfs/rtems-rfs-rtems.c
diff -u rtems/cpukit/ChangeLog:1.2775 rtems/cpukit/ChangeLog:1.2776
--- rtems/cpukit/ChangeLog:1.2775 Tue Mar 15 00:14:38 2011
+++ rtems/cpukit/ChangeLog Tue Mar 15 02:32:39 2011
@@ -1,5 +1,16 @@
2011-03-15 Chris Johns <chrisj at rtems.org>
+ * libfs/src/rfs/rtems-rfs-rtems-file.c,
+ libfs/src/rfs/rtems-rfs-rtems.c, libfs/src/rfs/rtems-rfs-rtems.h:
+ The fix to the removal of file_info from iop was broken. The
+ node_access field must be the inode number in the RFS because the
+ file system ops provides no way to tell is a stat call is the
+ result of stat, fstat, or lstat. The solution is to move the file
+ handle to node_access_2 which is also shared with doff but these
+ do not overlap.
+
+2011-03-15 Chris Johns <chrisj at rtems.org>
+
PR 1757/filesystem
* libfs/src/rfs/rtems-rfs-block-pos.h: Fix the bug in equal
compare.
diff -u rtems/cpukit/libfs/src/rfs/rtems-rfs-rtems-file.c:1.10 rtems/cpukit/libfs/src/rfs/rtems-rfs-rtems-file.c:1.11
--- rtems/cpukit/libfs/src/rfs/rtems-rfs-rtems-file.c:1.10 Tue Mar 15 00:02:34 2011
+++ rtems/cpukit/libfs/src/rfs/rtems-rfs-rtems-file.c Tue Mar 15 02:32:39 2011
@@ -71,7 +71,7 @@
printf("rtems-rfs: file-open: handle:%p\n", file);
iop->size = rtems_rfs_file_size (file);
- iop->pathinfo.node_access = file;
+ rtems_rfs_rtems_set_iop_file_handle (iop, file);
rtems_rfs_rtems_unlock (fs);
return 0;
@@ -87,7 +87,7 @@
static int
rtems_rfs_rtems_file_close (rtems_libio_t* iop)
{
- rtems_rfs_file_handle* file = iop->pathinfo.node_access;
+ rtems_rfs_file_handle* file = rtems_rfs_rtems_get_iop_file_handle (iop);
rtems_rfs_file_system* fs = rtems_rfs_file_fs (file);
int rc;
@@ -117,7 +117,7 @@
void* buffer,
size_t count)
{
- rtems_rfs_file_handle* file = iop->pathinfo.node_access;
+ rtems_rfs_file_handle* file = rtems_rfs_rtems_get_iop_file_handle (iop);
rtems_rfs_pos pos;
uint8_t* data = buffer;
ssize_t read = 0;
@@ -182,7 +182,7 @@
const void* buffer,
size_t count)
{
- rtems_rfs_file_handle* file = iop->pathinfo.node_access;
+ rtems_rfs_file_handle* file = rtems_rfs_rtems_get_iop_file_handle (iop);
rtems_rfs_pos pos;
const uint8_t* data = buffer;
ssize_t write = 0;
@@ -279,7 +279,7 @@
rtems_off64_t offset,
int whence)
{
- rtems_rfs_file_handle* file = iop->pathinfo.node_access;
+ rtems_rfs_file_handle* file = rtems_rfs_rtems_get_iop_file_handle (iop);
rtems_rfs_pos pos;
int rc;
@@ -303,62 +303,6 @@
}
/**
- * Stat the file.
- *
- * @param iop
- * @param buf
- * @return int
- */
-static int
-rtems_rfs_rtems_file_fstat (rtems_filesystem_location_info_t* pathloc,
- struct stat* buf)
-{
- rtems_rfs_file_handle* file = pathloc->node_access;
- int rc;
-
- if (rtems_rfs_rtems_trace (RTEMS_RFS_RTEMS_DEBUG_STAT))
- printf ("rtems-rfs: file-fstat: handle:%p\n", file);
-
- rtems_rfs_rtems_lock (rtems_rfs_file_fs (file));
-
- rc = rtems_rfs_rtems_stat_inode (rtems_rfs_file_fs (file),
- rtems_rfs_file_inode (file),
- buf);
-
- rtems_rfs_rtems_unlock (rtems_rfs_file_fs (file));
-
- return rc;
-}
-
-/**
- * File change mode routine.
- *
- * @param iop
- * @param mode
- * @return int
- */
-static int
-rtems_rfs_rtems_file_fchmod (rtems_filesystem_location_info_t* pathloc,
- mode_t mode)
-{
- rtems_rfs_file_handle* file = pathloc->node_access;
- int rc;
-
- if (rtems_rfs_rtems_trace (RTEMS_RFS_RTEMS_DEBUG_FCHMOD))
- printf ("rtems-rfs: file-fchmod: handle:%p\n", file);
-
- rtems_rfs_rtems_lock (rtems_rfs_file_fs (file));
-
- rc = rtems_rfs_rtems_fchmod_inode (rtems_rfs_file_fs (file),
- rtems_rfs_file_inode (file),
- mode);
-
- rtems_rfs_rtems_unlock (rtems_rfs_file_fs (file));
-
- return rc;
-}
-
-/**
* This routine processes the ftruncate() system call.
*
* @param iop
@@ -369,7 +313,7 @@
rtems_rfs_rtems_file_ftruncate (rtems_libio_t* iop,
rtems_off64_t length)
{
- rtems_rfs_file_handle* file = iop->pathinfo.node_access;
+ rtems_rfs_file_handle* file = rtems_rfs_rtems_get_iop_file_handle (iop);
int rc;
if (rtems_rfs_rtems_trace (RTEMS_RFS_RTEMS_DEBUG_FILE_FTRUNC))
@@ -399,8 +343,8 @@
.write_h = rtems_rfs_rtems_file_write,
.ioctl_h = rtems_rfs_rtems_file_ioctl,
.lseek_h = rtems_rfs_rtems_file_lseek,
- .fstat_h = rtems_rfs_rtems_file_fstat,
- .fchmod_h = rtems_rfs_rtems_file_fchmod,
+ .fstat_h = rtems_rfs_rtems_fstat,
+ .fchmod_h = rtems_rfs_rtems_fchmod,
.ftruncate_h = rtems_rfs_rtems_file_ftruncate,
.fpathconf_h = rtems_filesystem_default_fpathconf,
.fsync_h = rtems_rfs_rtems_fdatasync,
diff -u rtems/cpukit/libfs/src/rfs/rtems-rfs-rtems.h:1.5 rtems/cpukit/libfs/src/rfs/rtems-rfs-rtems.h:1.6
--- rtems/cpukit/libfs/src/rfs/rtems-rfs-rtems.h:1.5 Tue Mar 15 00:02:34 2011
+++ rtems/cpukit/libfs/src/rfs/rtems-rfs-rtems.h Tue Mar 15 02:32:39 2011
@@ -191,12 +191,30 @@
* Get the ino from the I/O pointer.
*
* @param _iop The I/O pointer.
- * @return
+ * @return ino
*/
#define rtems_rfs_rtems_get_iop_ino(_iop) \
((intptr_t)(_iop)->pathinfo.node_access)
/**
+ * Get the file handle from the I/O pointer.
+ *
+ * @param _iop The I/O pointer.
+ * @return filehandle The file handle
+ */
+#define rtems_rfs_rtems_get_iop_file_handle(_iop) \
+ ((rtems_rfs_file_handle*)(_iop)->pathinfo.node_access_2)
+
+/**
+ * Set the file handle in the I/O pointer.
+ *
+ * @param _iop The I/O pointer.
+ * @param _fh The file handle.
+ */
+#define rtems_rfs_rtems_set_iop_file_handle(_iop, _fh) \
+ (_iop)->pathinfo.node_access_2 = (_fh)
+
+/**
* Create the name of the handler's table given the type of handlers.
*
* @param _h The name of the handlers.
@@ -274,18 +292,6 @@
/**
* The following routine does a stat on a node.
*
- * @param fs The file system data.
- * @param inode The inode to stat held in memory.
- * @param buf The stat buffer to fill.
- * @return int The result code.
- */
-int rtems_rfs_rtems_stat_inode (rtems_rfs_file_system* fs,
- rtems_rfs_inode_handle* inode,
- struct stat* buf);
-
-/**
- * The following routine does a stat on a node.
- *
* @param iop
* @param buf
* @return int
@@ -294,18 +300,6 @@
struct stat* buf);
/**
- * File change mode routine changes an inode.
- *
- * @param fs The file system data.
- * @param inode The inode to change held in memory.
- * @param buf The new mode.
- * @return int The result code.
- */
-int rtems_rfs_rtems_fchmod_inode (rtems_rfs_file_system* fs,
- rtems_rfs_inode_handle* inode,
- mode_t mode);
-
-/**
* File change mode routine.
*
* @param iop
diff -u rtems/cpukit/libfs/src/rfs/rtems-rfs-rtems.c:1.16 rtems/cpukit/libfs/src/rfs/rtems-rfs-rtems.c:1.17
--- rtems/cpukit/libfs/src/rfs/rtems-rfs-rtems.c:1.16 Tue Mar 15 00:02:34 2011
+++ rtems/cpukit/libfs/src/rfs/rtems-rfs-rtems.c Tue Mar 15 02:32:39 2011
@@ -793,46 +793,16 @@
}
int
-rtems_rfs_rtems_fchmod_inode (rtems_rfs_file_system* fs,
- rtems_rfs_inode_handle* inode,
- mode_t mode)
-{
- uint16_t imode;
-#if defined (RTEMS_POSIX_API)
- uid_t uid;
-#endif
-
- if (rtems_rfs_rtems_trace (RTEMS_RFS_RTEMS_DEBUG_FCHMOD))
- printf ("rtems-rfs-rtems: fchmod indo: in: ino:%" PRId32 " mode:%06" PRIomode_t "\n",
- rtems_rfs_inode_ino (inode), mode);
-
- 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))
- return 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);
-
- return 0;
-}
-
-int
rtems_rfs_rtems_fchmod (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))
@@ -848,13 +818,26 @@
return rtems_rfs_rtems_error ("fchmod: opening inode", rc);
}
- rc = rtems_rfs_rtems_fchmod_inode (fs, &inode, mode);
- if (rc > 0)
+ 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);
rtems_rfs_rtems_unlock (fs);
- return rtems_rfs_rtems_error ("fchmod: fchmod inode", EPERM);
+ 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)
@@ -869,38 +852,49 @@
}
int
-rtems_rfs_rtems_stat_inode (rtems_rfs_file_system* fs,
- rtems_rfs_inode_handle* inode,
- struct stat* buf)
+rtems_rfs_rtems_fstat (rtems_filesystem_location_info_t* pathloc,
+ struct stat* buf)
{
+ 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;
rtems_rfs_file_shared* shared;
uint16_t mode;
+ int rc;
if (rtems_rfs_rtems_trace (RTEMS_RFS_RTEMS_DEBUG_STAT))
- printf ("rtems-rfs-rtems: stat-inode: in: ino:%" PRId32 "\n",
- rtems_rfs_inode_ino (inode));
+ printf ("rtems-rfs-rtems: stat: in: ino:%" PRId32 "\n", ino);
- mode = rtems_rfs_inode_get_mode (inode);
+ rtems_rfs_rtems_lock (fs);
+
+ rc = rtems_rfs_inode_open (fs, ino, &inode, true);
+ if (rc)
+ {
+ rtems_rfs_rtems_unlock (fs);
+ return rtems_rfs_rtems_error ("stat: opening inode", rc);
+ }
+
+ mode = rtems_rfs_inode_get_mode (&inode);
if (RTEMS_RFS_S_ISCHR (mode) || RTEMS_RFS_S_ISBLK (mode))
{
buf->st_rdev =
- rtems_filesystem_make_dev_t (rtems_rfs_inode_get_block (inode, 0),
- rtems_rfs_inode_get_block (inode, 1));
+ rtems_filesystem_make_dev_t (rtems_rfs_inode_get_block (&inode, 0),
+ rtems_rfs_inode_get_block (&inode, 1));
}
buf->st_dev = rtems_rfs_fs_device (fs);
- buf->st_ino = rtems_rfs_inode_ino (inode);
+ buf->st_ino = rtems_rfs_inode_ino (&inode);
buf->st_mode = rtems_rfs_rtems_mode (mode);
- buf->st_nlink = rtems_rfs_inode_get_links (inode);
- buf->st_uid = rtems_rfs_inode_get_uid (inode);
- buf->st_gid = rtems_rfs_inode_get_gid (inode);
+ buf->st_nlink = rtems_rfs_inode_get_links (&inode);
+ buf->st_uid = rtems_rfs_inode_get_uid (&inode);
+ buf->st_gid = rtems_rfs_inode_get_gid (&inode);
/*
* Need to check is the ino is an open file. If so we take the values from
* the open file rather than the inode.
*/
- shared = rtems_rfs_file_get_shared (fs, rtems_rfs_inode_ino (inode));
+ shared = rtems_rfs_file_get_shared (fs, rtems_rfs_inode_ino (&inode));
if (shared)
{
@@ -916,50 +910,19 @@
}
else
{
- buf->st_atime = rtems_rfs_inode_get_atime (inode);
- buf->st_mtime = rtems_rfs_inode_get_mtime (inode);
- buf->st_ctime = rtems_rfs_inode_get_ctime (inode);
- buf->st_blocks = rtems_rfs_inode_get_block_count (inode);
+ buf->st_atime = rtems_rfs_inode_get_atime (&inode);
+ buf->st_mtime = rtems_rfs_inode_get_mtime (&inode);
+ buf->st_ctime = rtems_rfs_inode_get_ctime (&inode);
+ buf->st_blocks = rtems_rfs_inode_get_block_count (&inode);
if (S_ISLNK (buf->st_mode))
- buf->st_size = rtems_rfs_inode_get_block_offset (inode);
+ buf->st_size = rtems_rfs_inode_get_block_offset (&inode);
else
- buf->st_size = rtems_rfs_inode_get_size (fs, inode);
+ buf->st_size = rtems_rfs_inode_get_size (fs, &inode);
}
buf->st_blksize = rtems_rfs_fs_block_size (fs);
- return 0;
-}
-
-int
-rtems_rfs_rtems_fstat (rtems_filesystem_location_info_t* pathloc,
- struct stat* buf)
-{
- 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_STAT))
- printf ("rtems-rfs-rtems: stat: in: ino:%" PRId32 "\n", ino);
-
- rtems_rfs_rtems_lock (fs);
-
- rc = rtems_rfs_inode_open (fs, ino, &inode, true);
- if (rc)
- {
- rtems_rfs_rtems_unlock (fs);
- return rtems_rfs_rtems_error ("stat: opening inode", rc);
- }
-
- rc = rtems_rfs_rtems_stat_inode (fs, &inode, buf);
- if (rc > 0)
- {
- rtems_rfs_rtems_unlock (fs);
- return rtems_rfs_rtems_error ("stat: stat'ing the inode", rc);
- }
-
rc = rtems_rfs_inode_close (fs, &inode);
if (rc > 0)
{
--
Generated by Deluxe Loginfo [http://www.codewiz.org/projects/index.html#loginfo] 2.122 by Bernardo Innocenti <bernie at develer.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rtems.org/pipermail/vc/attachments/20110315/00756127/attachment-0001.html>
More information about the vc
mailing list