changeset 1977:21507ef41413

* 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.
author asl
date Tue, 07 Jun 2005 10:07:04 +0000
parents 8438b097ea3b
children bba45c57325d
files packages/io/fileio/current/ChangeLog packages/io/fileio/current/src/devfs.cxx
diffstat 2 files changed, 21 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/packages/io/fileio/current/ChangeLog
+++ b/packages/io/fileio/current/ChangeLog
@@ -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-05-26  Gary Thomas  <gary@mlbassoc.com>
 
 	* tests/socket.c: Fix config test (CYGPKG_POSIX_SIGNALS)
--- a/packages/io/fileio/current/src/devfs.cxx
+++ b/packages/io/fileio/current/src/devfs.cxx
@@ -281,6 +281,7 @@ static int dev_stat     ( cyg_mtab_entry
 {
     Cyg_ErrNo err;
     cyg_io_handle_t handle;
+    cyg_devtab_entry_t *dev;
 
     name -= 5;          // See comment in dev_open()
     
@@ -290,13 +291,16 @@ static int dev_stat     ( cyg_mtab_entry
         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_close     (struct CYG_
 
 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;