2000-08-25 Joel Sherrill <joel.sherrill@OARcorp.com>

* libc/isatty.c, libc/imfs_handlers_directory.c, libc/creat.c,
	libc/imfs_directory.c: Fixed style issues.
This commit is contained in:
Joel Sherrill
2000-08-25 13:13:57 +00:00
parent 02fe6aba39
commit 662678d1d9
15 changed files with 362 additions and 307 deletions

View File

@@ -1,3 +1,7 @@
/*
* $Id$
*/
/* creat() "system call" */ /* creat() "system call" */
/* This is needed by f2c and therefore the SPEC benchmarks. */ /* This is needed by f2c and therefore the SPEC benchmarks. */

View File

@@ -1,17 +1,27 @@
/* isatty.c */ /*
* COPYRIGHT (c) 1989-1999.
/* Dumb implementation so programs will at least run. */ * On-Line Applications Research Corporation (OAR).
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.OARcorp.com/rtems/license.html.
*
* $Id$
*/
#include <sys/stat.h> #include <sys/stat.h>
int int isatty(
isatty (int fd) int fd
)
{ {
struct stat buf; struct stat buf;
if (fstat (fd, &buf) < 0) if (fstat (fd, &buf) < 0)
return 0; return 0;
if (S_ISCHR (buf.st_mode)) if (S_ISCHR (buf.st_mode))
return 1; return 1;
return 0; return 0;
} }

View File

@@ -1,5 +1,5 @@
/* /*
* XXX * IMFS Directory Access Routines
* *
* COPYRIGHT (c) 1989-1999. * COPYRIGHT (c) 1989-1999.
* On-Line Applications Research Corporation (OAR). * On-Line Applications Research Corporation (OAR).
@@ -25,10 +25,12 @@
#include "imfs.h" #include "imfs.h"
#include "libio_.h" #include "libio_.h"
/* ----------------------------------------------------------------------- /*
* This rountine will verify that the node being opened as a directory is * imfs_dir_open
* in fact a directory node. If it is then the offset into the directory *
* will be set to 0 to position to the first directory entry. * This rountine will verify that the node being opened as a directory is
* in fact a directory node. If it is then the offset into the directory
* will be set to 0 to position to the first directory entry.
*/ */
int imfs_dir_open( int imfs_dir_open(
@@ -44,25 +46,25 @@ int imfs_dir_open(
the_jnode = (IMFS_jnode_t *) iop->file_info; the_jnode = (IMFS_jnode_t *) iop->file_info;
if ( the_jnode->type != IMFS_DIRECTORY ) if ( the_jnode->type != IMFS_DIRECTORY )
return -1; /* It wasn't a directory --> return error */ return -1; /* It wasn't a directory --> return error */
iop->offset = 0; iop->offset = 0;
return 0; return 0;
} }
/*
* imfs_dir_read
/* ----------------------------------------------------------------------- *
* This routine will read the next directory entry based on the directory * This routine will read the next directory entry based on the directory
* offset. The offset should be equal to -n- time the size of an individual * offset. The offset should be equal to -n- time the size of an individual
* dirent structure. If n is not an integer multiple of the sizeof a * dirent structure. If n is not an integer multiple of the sizeof a
* dirent structure, an integer division will be performed to determine * dirent structure, an integer division will be performed to determine
* directory entry that will be returned in the buffer. Count should reflect * directory entry that will be returned in the buffer. Count should reflect
* -m- times the sizeof dirent bytes to be placed in the buffer. * -m- times the sizeof dirent bytes to be placed in the buffer.
* If there are not -m- dirent elements from the current directory position * If there are not -m- dirent elements from the current directory position
* to the end of the exisiting file, the remaining entries will be placed in * to the end of the exisiting file, the remaining entries will be placed in
* the buffer and the returned value will be equal to -m actual- times the * the buffer and the returned value will be equal to -m actual- times the
* size of a directory entry. * size of a directory entry.
*/ */
int imfs_dir_read( int imfs_dir_read(
@@ -79,9 +81,9 @@ int imfs_dir_read(
Chain_Control *the_chain; Chain_Control *the_chain;
IMFS_jnode_t *the_jnode; IMFS_jnode_t *the_jnode;
int bytes_transferred; int bytes_transferred;
int current_entry; int current_entry;
int first_entry; int first_entry;
int last_entry; int last_entry;
struct dirent tmp_dirent; struct dirent tmp_dirent;
the_jnode = (IMFS_jnode_t *)iop->file_info; the_jnode = (IMFS_jnode_t *)iop->file_info;
@@ -100,7 +102,7 @@ int imfs_dir_read(
last_entry = first_entry + (count/sizeof(struct dirent)) * sizeof(struct dirent); last_entry = first_entry + (count/sizeof(struct dirent)) * sizeof(struct dirent);
/* The directory was not empty so try to move to the desired entry in chain*/ /* The directory was not empty so try to move to the desired entry in chain*/
for( for (
current_entry = 0; current_entry = 0;
current_entry < last_entry; current_entry < last_entry;
current_entry = current_entry + sizeof(struct dirent) ){ current_entry = current_entry + sizeof(struct dirent) ){
@@ -138,35 +140,41 @@ int imfs_dir_read(
/* ----------------------------------------------------------------------- /*
* This routine will be called by the generic close routine to cleanup any * imfs_dir_close
* resources that have been allocated for the management of the file *
* This routine will be called by the generic close routine to cleanup any
* resources that have been allocated for the management of the file
*/ */
int imfs_dir_close( int imfs_dir_close(
rtems_libio_t *iop rtems_libio_t *iop
) )
{ {
/* The generic close routine handles the deallocation of the file control */ /*
/* and associated memory. At present the imfs_dir_close simply */ * The generic close routine handles the deallocation of the file control
/* returns a successful completion status */ * and associated memory. At present the imfs_dir_close simply
* returns a successful completion status.
*/
return 0; return 0;
} }
/* ----------------------------------------------------------------------- /*
* This routine will behave in one of three ways based on the state of * imfs_dir_lseek
* argument whence. Based on the state of its value the offset argument will
* be interpreted using one of the following methods:
* *
* SEEK_SET - offset is the absolute byte offset from the start of the * This routine will behave in one of three ways based on the state of
* logical start of the dirent sequence that represents the * argument whence. Based on the state of its value the offset argument will
* directory * be interpreted using one of the following methods:
* SEEK_CUR - offset is used as the relative byte offset from the current *
* directory position index held in the iop structure * SEEK_SET - offset is the absolute byte offset from the start of the
* SEEK_END - N/A --> This will cause an assert. * logical start of the dirent sequence that represents the
* directory
* SEEK_CUR - offset is used as the relative byte offset from the current
* directory position index held in the iop structure
* SEEK_END - N/A --> This will cause an assert.
*/ */
int imfs_dir_lseek( int imfs_dir_lseek(
@@ -180,18 +188,17 @@ int imfs_dir_lseek(
normal_offset = (offset/sizeof(struct dirent)) * sizeof(struct dirent); normal_offset = (offset/sizeof(struct dirent)) * sizeof(struct dirent);
switch( whence ) switch( whence ) {
{ case SEEK_SET: /* absolute move from the start of the file */
case SEEK_SET: /* absolute move from the start of the file */
iop->offset = normal_offset; iop->offset = normal_offset;
break; break;
case SEEK_CUR: /* relative move */ case SEEK_CUR: /* relative move */
iop->offset = iop->offset + normal_offset; iop->offset = iop->offset + normal_offset;
break; break;
case SEEK_END: /* Movement past the end of the directory via lseek */ case SEEK_END: /* Movement past the end of the directory via lseek */
/* is not a permitted operation */ /* is not a permitted operation */
default: default:
set_errno_and_return_minus_one( EINVAL ); set_errno_and_return_minus_one( EINVAL );
break; break;
@@ -203,28 +210,30 @@ int imfs_dir_lseek(
/* ----------------------------------------------------------------------- /*
* This routine will obtain the following information concerning the current * imfs_dir_fstat
* directory: *
* st_dev 0ll * This routine will obtain the following information concerning the current
* st_ino 1 * directory:
* st_mode mode extracted from the jnode * st_dev 0ll
* st_nlink number of links to this node * st_ino 1
* st_uid uid extracted from the jnode * st_mode mode extracted from the jnode
* st_gid gid extracted from the jnode * st_nlink number of links to this node
* st_rdev 0ll * st_uid uid extracted from the jnode
* st_size the number of bytes in the directory * st_gid gid extracted from the jnode
* This is calculated by taking the number of entries * st_rdev 0ll
* in the directory and multiplying by the size of a * st_size the number of bytes in the directory
* dirent structure * This is calculated by taking the number of entries
* st_blksize 0 * in the directory and multiplying by the size of a
* st_blocks 0 * dirent structure
* stat_atime time of last access * st_blksize 0
* stat_mtime time of last modification * st_blocks 0
* stat_ctime time of the last change * stat_atime time of last access
* stat_mtime time of last modification
* stat_ctime time of the last change
*
* This information will be returned to the calling function in a -stat- struct
* *
* This information will be returned to the calling function in a -stat- struct
*
*/ */
int imfs_dir_fstat( int imfs_dir_fstat(

View File

@@ -36,10 +36,3 @@ rtems_filesystem_file_handlers_r IMFS_directory_handlers = {
imfs_dir_rmnod imfs_dir_rmnod
}; };

View File

@@ -1,4 +1,9 @@
2000-08-25 Joel Sherrill <joel.sherrill@OARcorp.com>
* libc/isatty.c, libc/imfs_handlers_directory.c, libc/creat.c,
libc/imfs_directory.c: Fixed style issues.
2000-08-11 Chris Johns <ccj@acm.org> 2000-08-11 Chris Johns <ccj@acm.org>
* libc/chmod.c: Return ENOTSUP if filesystem does not have handler. * libc/chmod.c: Return ENOTSUP if filesystem does not have handler.

View File

@@ -1,3 +1,7 @@
/*
* $Id$
*/
/* creat() "system call" */ /* creat() "system call" */
/* This is needed by f2c and therefore the SPEC benchmarks. */ /* This is needed by f2c and therefore the SPEC benchmarks. */

View File

@@ -1,5 +1,5 @@
/* /*
* XXX * IMFS Directory Access Routines
* *
* COPYRIGHT (c) 1989-1999. * COPYRIGHT (c) 1989-1999.
* On-Line Applications Research Corporation (OAR). * On-Line Applications Research Corporation (OAR).
@@ -25,10 +25,12 @@
#include "imfs.h" #include "imfs.h"
#include "libio_.h" #include "libio_.h"
/* ----------------------------------------------------------------------- /*
* This rountine will verify that the node being opened as a directory is * imfs_dir_open
* in fact a directory node. If it is then the offset into the directory *
* will be set to 0 to position to the first directory entry. * This rountine will verify that the node being opened as a directory is
* in fact a directory node. If it is then the offset into the directory
* will be set to 0 to position to the first directory entry.
*/ */
int imfs_dir_open( int imfs_dir_open(
@@ -44,25 +46,25 @@ int imfs_dir_open(
the_jnode = (IMFS_jnode_t *) iop->file_info; the_jnode = (IMFS_jnode_t *) iop->file_info;
if ( the_jnode->type != IMFS_DIRECTORY ) if ( the_jnode->type != IMFS_DIRECTORY )
return -1; /* It wasn't a directory --> return error */ return -1; /* It wasn't a directory --> return error */
iop->offset = 0; iop->offset = 0;
return 0; return 0;
} }
/*
* imfs_dir_read
/* ----------------------------------------------------------------------- *
* This routine will read the next directory entry based on the directory * This routine will read the next directory entry based on the directory
* offset. The offset should be equal to -n- time the size of an individual * offset. The offset should be equal to -n- time the size of an individual
* dirent structure. If n is not an integer multiple of the sizeof a * dirent structure. If n is not an integer multiple of the sizeof a
* dirent structure, an integer division will be performed to determine * dirent structure, an integer division will be performed to determine
* directory entry that will be returned in the buffer. Count should reflect * directory entry that will be returned in the buffer. Count should reflect
* -m- times the sizeof dirent bytes to be placed in the buffer. * -m- times the sizeof dirent bytes to be placed in the buffer.
* If there are not -m- dirent elements from the current directory position * If there are not -m- dirent elements from the current directory position
* to the end of the exisiting file, the remaining entries will be placed in * to the end of the exisiting file, the remaining entries will be placed in
* the buffer and the returned value will be equal to -m actual- times the * the buffer and the returned value will be equal to -m actual- times the
* size of a directory entry. * size of a directory entry.
*/ */
int imfs_dir_read( int imfs_dir_read(
@@ -79,9 +81,9 @@ int imfs_dir_read(
Chain_Control *the_chain; Chain_Control *the_chain;
IMFS_jnode_t *the_jnode; IMFS_jnode_t *the_jnode;
int bytes_transferred; int bytes_transferred;
int current_entry; int current_entry;
int first_entry; int first_entry;
int last_entry; int last_entry;
struct dirent tmp_dirent; struct dirent tmp_dirent;
the_jnode = (IMFS_jnode_t *)iop->file_info; the_jnode = (IMFS_jnode_t *)iop->file_info;
@@ -100,7 +102,7 @@ int imfs_dir_read(
last_entry = first_entry + (count/sizeof(struct dirent)) * sizeof(struct dirent); last_entry = first_entry + (count/sizeof(struct dirent)) * sizeof(struct dirent);
/* The directory was not empty so try to move to the desired entry in chain*/ /* The directory was not empty so try to move to the desired entry in chain*/
for( for (
current_entry = 0; current_entry = 0;
current_entry < last_entry; current_entry < last_entry;
current_entry = current_entry + sizeof(struct dirent) ){ current_entry = current_entry + sizeof(struct dirent) ){
@@ -138,35 +140,41 @@ int imfs_dir_read(
/* ----------------------------------------------------------------------- /*
* This routine will be called by the generic close routine to cleanup any * imfs_dir_close
* resources that have been allocated for the management of the file *
* This routine will be called by the generic close routine to cleanup any
* resources that have been allocated for the management of the file
*/ */
int imfs_dir_close( int imfs_dir_close(
rtems_libio_t *iop rtems_libio_t *iop
) )
{ {
/* The generic close routine handles the deallocation of the file control */ /*
/* and associated memory. At present the imfs_dir_close simply */ * The generic close routine handles the deallocation of the file control
/* returns a successful completion status */ * and associated memory. At present the imfs_dir_close simply
* returns a successful completion status.
*/
return 0; return 0;
} }
/* ----------------------------------------------------------------------- /*
* This routine will behave in one of three ways based on the state of * imfs_dir_lseek
* argument whence. Based on the state of its value the offset argument will
* be interpreted using one of the following methods:
* *
* SEEK_SET - offset is the absolute byte offset from the start of the * This routine will behave in one of three ways based on the state of
* logical start of the dirent sequence that represents the * argument whence. Based on the state of its value the offset argument will
* directory * be interpreted using one of the following methods:
* SEEK_CUR - offset is used as the relative byte offset from the current *
* directory position index held in the iop structure * SEEK_SET - offset is the absolute byte offset from the start of the
* SEEK_END - N/A --> This will cause an assert. * logical start of the dirent sequence that represents the
* directory
* SEEK_CUR - offset is used as the relative byte offset from the current
* directory position index held in the iop structure
* SEEK_END - N/A --> This will cause an assert.
*/ */
int imfs_dir_lseek( int imfs_dir_lseek(
@@ -180,18 +188,17 @@ int imfs_dir_lseek(
normal_offset = (offset/sizeof(struct dirent)) * sizeof(struct dirent); normal_offset = (offset/sizeof(struct dirent)) * sizeof(struct dirent);
switch( whence ) switch( whence ) {
{ case SEEK_SET: /* absolute move from the start of the file */
case SEEK_SET: /* absolute move from the start of the file */
iop->offset = normal_offset; iop->offset = normal_offset;
break; break;
case SEEK_CUR: /* relative move */ case SEEK_CUR: /* relative move */
iop->offset = iop->offset + normal_offset; iop->offset = iop->offset + normal_offset;
break; break;
case SEEK_END: /* Movement past the end of the directory via lseek */ case SEEK_END: /* Movement past the end of the directory via lseek */
/* is not a permitted operation */ /* is not a permitted operation */
default: default:
set_errno_and_return_minus_one( EINVAL ); set_errno_and_return_minus_one( EINVAL );
break; break;
@@ -203,28 +210,30 @@ int imfs_dir_lseek(
/* ----------------------------------------------------------------------- /*
* This routine will obtain the following information concerning the current * imfs_dir_fstat
* directory: *
* st_dev 0ll * This routine will obtain the following information concerning the current
* st_ino 1 * directory:
* st_mode mode extracted from the jnode * st_dev 0ll
* st_nlink number of links to this node * st_ino 1
* st_uid uid extracted from the jnode * st_mode mode extracted from the jnode
* st_gid gid extracted from the jnode * st_nlink number of links to this node
* st_rdev 0ll * st_uid uid extracted from the jnode
* st_size the number of bytes in the directory * st_gid gid extracted from the jnode
* This is calculated by taking the number of entries * st_rdev 0ll
* in the directory and multiplying by the size of a * st_size the number of bytes in the directory
* dirent structure * This is calculated by taking the number of entries
* st_blksize 0 * in the directory and multiplying by the size of a
* st_blocks 0 * dirent structure
* stat_atime time of last access * st_blksize 0
* stat_mtime time of last modification * st_blocks 0
* stat_ctime time of the last change * stat_atime time of last access
* stat_mtime time of last modification
* stat_ctime time of the last change
*
* This information will be returned to the calling function in a -stat- struct
* *
* This information will be returned to the calling function in a -stat- struct
*
*/ */
int imfs_dir_fstat( int imfs_dir_fstat(

View File

@@ -36,10 +36,3 @@ rtems_filesystem_file_handlers_r IMFS_directory_handlers = {
imfs_dir_rmnod imfs_dir_rmnod
}; };

View File

@@ -1,17 +1,27 @@
/* isatty.c */ /*
* COPYRIGHT (c) 1989-1999.
/* Dumb implementation so programs will at least run. */ * On-Line Applications Research Corporation (OAR).
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.OARcorp.com/rtems/license.html.
*
* $Id$
*/
#include <sys/stat.h> #include <sys/stat.h>
int int isatty(
isatty (int fd) int fd
)
{ {
struct stat buf; struct stat buf;
if (fstat (fd, &buf) < 0) if (fstat (fd, &buf) < 0)
return 0; return 0;
if (S_ISCHR (buf.st_mode)) if (S_ISCHR (buf.st_mode))
return 1; return 1;
return 0; return 0;
} }

View File

@@ -1,5 +1,5 @@
/* /*
* XXX * IMFS Directory Access Routines
* *
* COPYRIGHT (c) 1989-1999. * COPYRIGHT (c) 1989-1999.
* On-Line Applications Research Corporation (OAR). * On-Line Applications Research Corporation (OAR).
@@ -25,10 +25,12 @@
#include "imfs.h" #include "imfs.h"
#include "libio_.h" #include "libio_.h"
/* ----------------------------------------------------------------------- /*
* This rountine will verify that the node being opened as a directory is * imfs_dir_open
* in fact a directory node. If it is then the offset into the directory *
* will be set to 0 to position to the first directory entry. * This rountine will verify that the node being opened as a directory is
* in fact a directory node. If it is then the offset into the directory
* will be set to 0 to position to the first directory entry.
*/ */
int imfs_dir_open( int imfs_dir_open(
@@ -44,25 +46,25 @@ int imfs_dir_open(
the_jnode = (IMFS_jnode_t *) iop->file_info; the_jnode = (IMFS_jnode_t *) iop->file_info;
if ( the_jnode->type != IMFS_DIRECTORY ) if ( the_jnode->type != IMFS_DIRECTORY )
return -1; /* It wasn't a directory --> return error */ return -1; /* It wasn't a directory --> return error */
iop->offset = 0; iop->offset = 0;
return 0; return 0;
} }
/*
* imfs_dir_read
/* ----------------------------------------------------------------------- *
* This routine will read the next directory entry based on the directory * This routine will read the next directory entry based on the directory
* offset. The offset should be equal to -n- time the size of an individual * offset. The offset should be equal to -n- time the size of an individual
* dirent structure. If n is not an integer multiple of the sizeof a * dirent structure. If n is not an integer multiple of the sizeof a
* dirent structure, an integer division will be performed to determine * dirent structure, an integer division will be performed to determine
* directory entry that will be returned in the buffer. Count should reflect * directory entry that will be returned in the buffer. Count should reflect
* -m- times the sizeof dirent bytes to be placed in the buffer. * -m- times the sizeof dirent bytes to be placed in the buffer.
* If there are not -m- dirent elements from the current directory position * If there are not -m- dirent elements from the current directory position
* to the end of the exisiting file, the remaining entries will be placed in * to the end of the exisiting file, the remaining entries will be placed in
* the buffer and the returned value will be equal to -m actual- times the * the buffer and the returned value will be equal to -m actual- times the
* size of a directory entry. * size of a directory entry.
*/ */
int imfs_dir_read( int imfs_dir_read(
@@ -79,9 +81,9 @@ int imfs_dir_read(
Chain_Control *the_chain; Chain_Control *the_chain;
IMFS_jnode_t *the_jnode; IMFS_jnode_t *the_jnode;
int bytes_transferred; int bytes_transferred;
int current_entry; int current_entry;
int first_entry; int first_entry;
int last_entry; int last_entry;
struct dirent tmp_dirent; struct dirent tmp_dirent;
the_jnode = (IMFS_jnode_t *)iop->file_info; the_jnode = (IMFS_jnode_t *)iop->file_info;
@@ -100,7 +102,7 @@ int imfs_dir_read(
last_entry = first_entry + (count/sizeof(struct dirent)) * sizeof(struct dirent); last_entry = first_entry + (count/sizeof(struct dirent)) * sizeof(struct dirent);
/* The directory was not empty so try to move to the desired entry in chain*/ /* The directory was not empty so try to move to the desired entry in chain*/
for( for (
current_entry = 0; current_entry = 0;
current_entry < last_entry; current_entry < last_entry;
current_entry = current_entry + sizeof(struct dirent) ){ current_entry = current_entry + sizeof(struct dirent) ){
@@ -138,35 +140,41 @@ int imfs_dir_read(
/* ----------------------------------------------------------------------- /*
* This routine will be called by the generic close routine to cleanup any * imfs_dir_close
* resources that have been allocated for the management of the file *
* This routine will be called by the generic close routine to cleanup any
* resources that have been allocated for the management of the file
*/ */
int imfs_dir_close( int imfs_dir_close(
rtems_libio_t *iop rtems_libio_t *iop
) )
{ {
/* The generic close routine handles the deallocation of the file control */ /*
/* and associated memory. At present the imfs_dir_close simply */ * The generic close routine handles the deallocation of the file control
/* returns a successful completion status */ * and associated memory. At present the imfs_dir_close simply
* returns a successful completion status.
*/
return 0; return 0;
} }
/* ----------------------------------------------------------------------- /*
* This routine will behave in one of three ways based on the state of * imfs_dir_lseek
* argument whence. Based on the state of its value the offset argument will
* be interpreted using one of the following methods:
* *
* SEEK_SET - offset is the absolute byte offset from the start of the * This routine will behave in one of three ways based on the state of
* logical start of the dirent sequence that represents the * argument whence. Based on the state of its value the offset argument will
* directory * be interpreted using one of the following methods:
* SEEK_CUR - offset is used as the relative byte offset from the current *
* directory position index held in the iop structure * SEEK_SET - offset is the absolute byte offset from the start of the
* SEEK_END - N/A --> This will cause an assert. * logical start of the dirent sequence that represents the
* directory
* SEEK_CUR - offset is used as the relative byte offset from the current
* directory position index held in the iop structure
* SEEK_END - N/A --> This will cause an assert.
*/ */
int imfs_dir_lseek( int imfs_dir_lseek(
@@ -180,18 +188,17 @@ int imfs_dir_lseek(
normal_offset = (offset/sizeof(struct dirent)) * sizeof(struct dirent); normal_offset = (offset/sizeof(struct dirent)) * sizeof(struct dirent);
switch( whence ) switch( whence ) {
{ case SEEK_SET: /* absolute move from the start of the file */
case SEEK_SET: /* absolute move from the start of the file */
iop->offset = normal_offset; iop->offset = normal_offset;
break; break;
case SEEK_CUR: /* relative move */ case SEEK_CUR: /* relative move */
iop->offset = iop->offset + normal_offset; iop->offset = iop->offset + normal_offset;
break; break;
case SEEK_END: /* Movement past the end of the directory via lseek */ case SEEK_END: /* Movement past the end of the directory via lseek */
/* is not a permitted operation */ /* is not a permitted operation */
default: default:
set_errno_and_return_minus_one( EINVAL ); set_errno_and_return_minus_one( EINVAL );
break; break;
@@ -203,28 +210,30 @@ int imfs_dir_lseek(
/* ----------------------------------------------------------------------- /*
* This routine will obtain the following information concerning the current * imfs_dir_fstat
* directory: *
* st_dev 0ll * This routine will obtain the following information concerning the current
* st_ino 1 * directory:
* st_mode mode extracted from the jnode * st_dev 0ll
* st_nlink number of links to this node * st_ino 1
* st_uid uid extracted from the jnode * st_mode mode extracted from the jnode
* st_gid gid extracted from the jnode * st_nlink number of links to this node
* st_rdev 0ll * st_uid uid extracted from the jnode
* st_size the number of bytes in the directory * st_gid gid extracted from the jnode
* This is calculated by taking the number of entries * st_rdev 0ll
* in the directory and multiplying by the size of a * st_size the number of bytes in the directory
* dirent structure * This is calculated by taking the number of entries
* st_blksize 0 * in the directory and multiplying by the size of a
* st_blocks 0 * dirent structure
* stat_atime time of last access * st_blksize 0
* stat_mtime time of last modification * st_blocks 0
* stat_ctime time of the last change * stat_atime time of last access
* stat_mtime time of last modification
* stat_ctime time of the last change
*
* This information will be returned to the calling function in a -stat- struct
* *
* This information will be returned to the calling function in a -stat- struct
*
*/ */
int imfs_dir_fstat( int imfs_dir_fstat(

View File

@@ -36,10 +36,3 @@ rtems_filesystem_file_handlers_r IMFS_directory_handlers = {
imfs_dir_rmnod imfs_dir_rmnod
}; };

View File

@@ -1,3 +1,7 @@
/*
* $Id$
*/
/* creat() "system call" */ /* creat() "system call" */
/* This is needed by f2c and therefore the SPEC benchmarks. */ /* This is needed by f2c and therefore the SPEC benchmarks. */

View File

@@ -1,17 +1,27 @@
/* isatty.c */ /*
* COPYRIGHT (c) 1989-1999.
/* Dumb implementation so programs will at least run. */ * On-Line Applications Research Corporation (OAR).
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.OARcorp.com/rtems/license.html.
*
* $Id$
*/
#include <sys/stat.h> #include <sys/stat.h>
int int isatty(
isatty (int fd) int fd
)
{ {
struct stat buf; struct stat buf;
if (fstat (fd, &buf) < 0) if (fstat (fd, &buf) < 0)
return 0; return 0;
if (S_ISCHR (buf.st_mode)) if (S_ISCHR (buf.st_mode))
return 1; return 1;
return 0; return 0;
} }

View File

@@ -1,5 +1,5 @@
/* /*
* XXX * IMFS Directory Access Routines
* *
* COPYRIGHT (c) 1989-1999. * COPYRIGHT (c) 1989-1999.
* On-Line Applications Research Corporation (OAR). * On-Line Applications Research Corporation (OAR).
@@ -25,10 +25,12 @@
#include "imfs.h" #include "imfs.h"
#include "libio_.h" #include "libio_.h"
/* ----------------------------------------------------------------------- /*
* This rountine will verify that the node being opened as a directory is * imfs_dir_open
* in fact a directory node. If it is then the offset into the directory *
* will be set to 0 to position to the first directory entry. * This rountine will verify that the node being opened as a directory is
* in fact a directory node. If it is then the offset into the directory
* will be set to 0 to position to the first directory entry.
*/ */
int imfs_dir_open( int imfs_dir_open(
@@ -44,25 +46,25 @@ int imfs_dir_open(
the_jnode = (IMFS_jnode_t *) iop->file_info; the_jnode = (IMFS_jnode_t *) iop->file_info;
if ( the_jnode->type != IMFS_DIRECTORY ) if ( the_jnode->type != IMFS_DIRECTORY )
return -1; /* It wasn't a directory --> return error */ return -1; /* It wasn't a directory --> return error */
iop->offset = 0; iop->offset = 0;
return 0; return 0;
} }
/*
* imfs_dir_read
/* ----------------------------------------------------------------------- *
* This routine will read the next directory entry based on the directory * This routine will read the next directory entry based on the directory
* offset. The offset should be equal to -n- time the size of an individual * offset. The offset should be equal to -n- time the size of an individual
* dirent structure. If n is not an integer multiple of the sizeof a * dirent structure. If n is not an integer multiple of the sizeof a
* dirent structure, an integer division will be performed to determine * dirent structure, an integer division will be performed to determine
* directory entry that will be returned in the buffer. Count should reflect * directory entry that will be returned in the buffer. Count should reflect
* -m- times the sizeof dirent bytes to be placed in the buffer. * -m- times the sizeof dirent bytes to be placed in the buffer.
* If there are not -m- dirent elements from the current directory position * If there are not -m- dirent elements from the current directory position
* to the end of the exisiting file, the remaining entries will be placed in * to the end of the exisiting file, the remaining entries will be placed in
* the buffer and the returned value will be equal to -m actual- times the * the buffer and the returned value will be equal to -m actual- times the
* size of a directory entry. * size of a directory entry.
*/ */
int imfs_dir_read( int imfs_dir_read(
@@ -79,9 +81,9 @@ int imfs_dir_read(
Chain_Control *the_chain; Chain_Control *the_chain;
IMFS_jnode_t *the_jnode; IMFS_jnode_t *the_jnode;
int bytes_transferred; int bytes_transferred;
int current_entry; int current_entry;
int first_entry; int first_entry;
int last_entry; int last_entry;
struct dirent tmp_dirent; struct dirent tmp_dirent;
the_jnode = (IMFS_jnode_t *)iop->file_info; the_jnode = (IMFS_jnode_t *)iop->file_info;
@@ -100,7 +102,7 @@ int imfs_dir_read(
last_entry = first_entry + (count/sizeof(struct dirent)) * sizeof(struct dirent); last_entry = first_entry + (count/sizeof(struct dirent)) * sizeof(struct dirent);
/* The directory was not empty so try to move to the desired entry in chain*/ /* The directory was not empty so try to move to the desired entry in chain*/
for( for (
current_entry = 0; current_entry = 0;
current_entry < last_entry; current_entry < last_entry;
current_entry = current_entry + sizeof(struct dirent) ){ current_entry = current_entry + sizeof(struct dirent) ){
@@ -138,35 +140,41 @@ int imfs_dir_read(
/* ----------------------------------------------------------------------- /*
* This routine will be called by the generic close routine to cleanup any * imfs_dir_close
* resources that have been allocated for the management of the file *
* This routine will be called by the generic close routine to cleanup any
* resources that have been allocated for the management of the file
*/ */
int imfs_dir_close( int imfs_dir_close(
rtems_libio_t *iop rtems_libio_t *iop
) )
{ {
/* The generic close routine handles the deallocation of the file control */ /*
/* and associated memory. At present the imfs_dir_close simply */ * The generic close routine handles the deallocation of the file control
/* returns a successful completion status */ * and associated memory. At present the imfs_dir_close simply
* returns a successful completion status.
*/
return 0; return 0;
} }
/* ----------------------------------------------------------------------- /*
* This routine will behave in one of three ways based on the state of * imfs_dir_lseek
* argument whence. Based on the state of its value the offset argument will
* be interpreted using one of the following methods:
* *
* SEEK_SET - offset is the absolute byte offset from the start of the * This routine will behave in one of three ways based on the state of
* logical start of the dirent sequence that represents the * argument whence. Based on the state of its value the offset argument will
* directory * be interpreted using one of the following methods:
* SEEK_CUR - offset is used as the relative byte offset from the current *
* directory position index held in the iop structure * SEEK_SET - offset is the absolute byte offset from the start of the
* SEEK_END - N/A --> This will cause an assert. * logical start of the dirent sequence that represents the
* directory
* SEEK_CUR - offset is used as the relative byte offset from the current
* directory position index held in the iop structure
* SEEK_END - N/A --> This will cause an assert.
*/ */
int imfs_dir_lseek( int imfs_dir_lseek(
@@ -180,18 +188,17 @@ int imfs_dir_lseek(
normal_offset = (offset/sizeof(struct dirent)) * sizeof(struct dirent); normal_offset = (offset/sizeof(struct dirent)) * sizeof(struct dirent);
switch( whence ) switch( whence ) {
{ case SEEK_SET: /* absolute move from the start of the file */
case SEEK_SET: /* absolute move from the start of the file */
iop->offset = normal_offset; iop->offset = normal_offset;
break; break;
case SEEK_CUR: /* relative move */ case SEEK_CUR: /* relative move */
iop->offset = iop->offset + normal_offset; iop->offset = iop->offset + normal_offset;
break; break;
case SEEK_END: /* Movement past the end of the directory via lseek */ case SEEK_END: /* Movement past the end of the directory via lseek */
/* is not a permitted operation */ /* is not a permitted operation */
default: default:
set_errno_and_return_minus_one( EINVAL ); set_errno_and_return_minus_one( EINVAL );
break; break;
@@ -203,28 +210,30 @@ int imfs_dir_lseek(
/* ----------------------------------------------------------------------- /*
* This routine will obtain the following information concerning the current * imfs_dir_fstat
* directory: *
* st_dev 0ll * This routine will obtain the following information concerning the current
* st_ino 1 * directory:
* st_mode mode extracted from the jnode * st_dev 0ll
* st_nlink number of links to this node * st_ino 1
* st_uid uid extracted from the jnode * st_mode mode extracted from the jnode
* st_gid gid extracted from the jnode * st_nlink number of links to this node
* st_rdev 0ll * st_uid uid extracted from the jnode
* st_size the number of bytes in the directory * st_gid gid extracted from the jnode
* This is calculated by taking the number of entries * st_rdev 0ll
* in the directory and multiplying by the size of a * st_size the number of bytes in the directory
* dirent structure * This is calculated by taking the number of entries
* st_blksize 0 * in the directory and multiplying by the size of a
* st_blocks 0 * dirent structure
* stat_atime time of last access * st_blksize 0
* stat_mtime time of last modification * st_blocks 0
* stat_ctime time of the last change * stat_atime time of last access
* stat_mtime time of last modification
* stat_ctime time of the last change
*
* This information will be returned to the calling function in a -stat- struct
* *
* This information will be returned to the calling function in a -stat- struct
*
*/ */
int imfs_dir_fstat( int imfs_dir_fstat(

View File

@@ -36,10 +36,3 @@ rtems_filesystem_file_handlers_r IMFS_directory_handlers = {
imfs_dir_rmnod imfs_dir_rmnod
}; };