This is the mail archive of the
ecos-patches@sources.redhat.com
mailing list for the eCos project.
Devfs stat fix
- From: Peter Korsgaard <jacmet at sunsite dot dk>
- To: ecos-patches at ecos dot sourceware dot org
- Date: Fri, 13 May 2005 23:23:29 +0200
- Subject: Devfs stat fix
Hi,
The following little patch fixes some minor issues with the stat
functions of devfs.
Index: packages/io/fileio/current/ChangeLog
===================================================================
RCS file: /cvs/ecos/ecos/packages/io/fileio/current/ChangeLog,v
retrieving revision 1.57
diff -u -u -r1.57 ChangeLog
--- packages/io/fileio/current/ChangeLog 27 Mar 2005 17:36:28 -0000 1.57
+++ packages/io/fileio/current/ChangeLog 13 May 2005 21:09:57 -0000
@@ -1,3 +1,9 @@
+2005-05-13 Peter Korsgaard <jacmet@sunsite.dk>
+
+ * src/devfs.cxx (dev_stat, dev_fo_fstat): Corrected mode for block
+ devices, made nlink 1.
+ * src/devfs.cxx (dev_fo_fstat): Set st_dev to zero to match dev_stat.
+
2005-03-27 Andrew Lunn <andrew.lunn@ascom.ch>
* tests/testfs.c: Fixed compiler warnigs for passing wrong types
Index: packages/io/fileio/current/src/devfs.cxx
===================================================================
RCS file: /cvs/ecos/ecos/packages/io/fileio/current/src/devfs.cxx,v
retrieving revision 1.8
diff -u -u -r1.8 devfs.cxx
--- packages/io/fileio/current/src/devfs.cxx 14 Nov 2004 14:03:45 -0000 1.8
+++ packages/io/fileio/current/src/devfs.cxx 13 May 2005 21:09:58 -0000
@@ -281,6 +281,7 @@
{
Cyg_ErrNo err;
cyg_io_handle_t handle;
+ cyg_devtab_entry_t *dev;
name -= 5; // See comment in dev_open()
@@ -290,13 +291,16 @@
return -err;
// Just fill in the stat buffer with some constant values.
+ dev = (cyg_devtab_entry_t *)handle;
- // FIXME: change this when block devices are available
- buf->st_mode = __stat_mode_CHR;
+ if (dev->status & CYG_DEVTAB_STATUS_BLOCK)
+ buf->st_mode = __stat_mode_BLK;
+ else
+ buf->st_mode = __stat_mode_CHR;
buf->st_ino = (ino_t)handle; // map dev handle to inode
buf->st_dev = 0; // (dev_t)handle; // same with dev id
- buf->st_nlink = 0;
+ buf->st_nlink = 1;
buf->st_uid = 0;
buf->st_gid = 0;
buf->st_size = 0;
@@ -444,14 +448,17 @@
static int dev_fo_fstat (struct CYG_FILE_TAG *fp, struct stat *buf )
{
- // Just fill in the stat buffer with some constant values.
+ cyg_devtab_entry_t *dev = (cyg_devtab_entry_t *)fp->f_data;
- // FIXME: change this when block devices are available
- buf->st_mode = __stat_mode_CHR;
+ // Just fill in the stat buffer with some constant values.
+ if (dev->status & CYG_DEVTAB_STATUS_BLOCK)
+ buf->st_mode = __stat_mode_BLK;
+ else
+ buf->st_mode = __stat_mode_CHR;
buf->st_ino = (ino_t)fp->f_data; // map dev handle to inode
- buf->st_dev = (dev_t)fp->f_data; // same with dev id
- buf->st_nlink = 0;
+ buf->st_dev = 0; //(dev_t)fp->f_data; // same with dev id
+ buf->st_nlink = 1;
buf->st_uid = 0;
buf->st_gid = 0;
buf->st_size = 0;
--
Bye, Peter Korsgaard