summaryrefslogtreecommitdiffstats
path: root/c/src/lib/libc
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@OARcorp.com>2000-08-11 20:04:27 +0000
committerJoel Sherrill <joel.sherrill@OARcorp.com>2000-08-11 20:04:27 +0000
commitdd19c0bb061af5595a970ed3c4f4af3824b65593 (patch)
treef946b796fc8e82900702a771e6f6c6b39cbe2297 /c/src/lib/libc
parente7de167c8ca5b48887e761f1686d305ba7b2bd70 (diff)
downloadrtems-dd19c0bb061af5595a970ed3c4f4af3824b65593.tar.bz2
2000-08-11 Chris Johns <ccj@acm.org>
* libc/chmod.c: Return ENOTSUP if filesystem does not have handler. * libc/eval.c: Ditto. * libc/fcntl.c: Ditto. * libc/fsync.c: Ditto. * libc/ioctl.c: Ditto. * libc/ioman.c: Ditto. * libc/link.c: Ditto. * libc/memfile.c: Ditto. * libc/mknod.c: Ditto. * libc/symlink.c: Ditto. * libc/libio.h(rtems_filesystem_dev_major_t): New macro. * libc/libio.h(rtems_filesystem_dev_minor_t): New macro.
Diffstat (limited to 'c/src/lib/libc')
-rw-r--r--c/src/lib/libc/chmod.c5
-rw-r--r--c/src/lib/libc/eval.c3
-rw-r--r--c/src/lib/libc/fcntl.c14
-rw-r--r--c/src/lib/libc/fsync.c3
-rw-r--r--c/src/lib/libc/ioctl.c3
-rw-r--r--c/src/lib/libc/ioman.c5
-rw-r--r--c/src/lib/libc/libio.h10
-rw-r--r--c/src/lib/libc/link.c8
-rw-r--r--c/src/lib/libc/memfile.c4
-rw-r--r--c/src/lib/libc/mknod.c5
-rw-r--r--c/src/lib/libc/symlink.c5
11 files changed, 58 insertions, 7 deletions
diff --git a/c/src/lib/libc/chmod.c b/c/src/lib/libc/chmod.c
index d88e80eeb7..f1042806b9 100644
--- a/c/src/lib/libc/chmod.c
+++ b/c/src/lib/libc/chmod.c
@@ -33,6 +33,11 @@ int chmod(
if ( status != 0 )
return -1;
+ if ( !loc.handlers ){
+ rtems_filesystem_freenode( &loc );
+ set_errno_and_return_minus_one( EBADF );
+ }
+
if ( !loc.handlers->fchmod ){
rtems_filesystem_freenode( &loc );
set_errno_and_return_minus_one( ENOTSUP );
diff --git a/c/src/lib/libc/eval.c b/c/src/lib/libc/eval.c
index 8fc27ca19c..8d839918a5 100644
--- a/c/src/lib/libc/eval.c
+++ b/c/src/lib/libc/eval.c
@@ -43,6 +43,9 @@ int rtems_filesystem_evaluate_path(
rtems_filesystem_get_start_loc( pathname, &i, pathloc );
+ if ( !pathloc->ops->evalpath )
+ set_errno_and_return_minus_one( ENOTSUP );
+
result = (*pathloc->ops->evalpath)( &pathname[i], flags, pathloc );
/*
diff --git a/c/src/lib/libc/fcntl.c b/c/src/lib/libc/fcntl.c
index 05410eaff6..587726f885 100644
--- a/c/src/lib/libc/fcntl.c
+++ b/c/src/lib/libc/fcntl.c
@@ -131,10 +131,16 @@ int fcntl(
ret = -1;
break;
}
- if ((ret >= 0) && iop->handlers->fcntl) {
- int err = (*iop->handlers->fcntl)( cmd, iop );
- if (err) {
- errno = err;
+ if (ret >= 0) {
+ if (iop->handlers->fcntl) {
+ int err = (*iop->handlers->fcntl)( cmd, iop );
+ if (err) {
+ errno = err;
+ ret = -1;
+ }
+ }
+ else {
+ errno = ENOTSUP;
ret = -1;
}
}
diff --git a/c/src/lib/libc/fsync.c b/c/src/lib/libc/fsync.c
index 64f05f341a..3dc9835d31 100644
--- a/c/src/lib/libc/fsync.c
+++ b/c/src/lib/libc/fsync.c
@@ -30,6 +30,9 @@ int fsync(
* Now process the fsync().
*/
+ if ( !iop->handlers )
+ set_errno_and_return_minus_one( EBADF );
+
if ( !iop->handlers->fsync )
set_errno_and_return_minus_one( ENOTSUP );
diff --git a/c/src/lib/libc/ioctl.c b/c/src/lib/libc/ioctl.c
index 8d84a26a15..ce74ba7cf4 100644
--- a/c/src/lib/libc/ioctl.c
+++ b/c/src/lib/libc/ioctl.c
@@ -41,6 +41,9 @@ int ioctl(
* Now process the ioctl().
*/
+ if ( !iop->handlers )
+ set_errno_and_return_minus_one( EBADF );
+
if ( !iop->handlers->ioctl )
set_errno_and_return_minus_one( ENOTSUP );
diff --git a/c/src/lib/libc/ioman.c b/c/src/lib/libc/ioman.c
index ee22791657..4f592a6094 100644
--- a/c/src/lib/libc/ioman.c
+++ b/c/src/lib/libc/ioman.c
@@ -80,6 +80,11 @@ rtems_status_code rtems_io_lookup_name(
result = rtems_filesystem_evaluate_path( name, 0x00, &loc, TRUE );
the_jnode = loc.node_access;
+ if ( !loc.ops->node_type ) {
+ rtems_filesystem_freenode( &loc );
+ set_errno_and_return_minus_one( ENOTSUP );
+ }
+
node_type = (*loc.ops->node_type)( &loc );
if ( (result != 0) || node_type != RTEMS_FILESYSTEM_DEVICE ) {
diff --git a/c/src/lib/libc/libio.h b/c/src/lib/libc/libio.h
index 5df9cccc24..7d832258ca 100644
--- a/c/src/lib/libc/libio.h
+++ b/c/src/lib/libc/libio.h
@@ -466,10 +466,16 @@ typedef int (*rtems_libio_lseek_t)(
#define rtems_filesystem_make_dev_t( _major, _minor ) \
((((dev_t)(_major)) << 32) | (dev_t)(_minor))
+#define rtems_filesystem_dev_major_t( _dev ) \
+ (rtems_device_major_number) ((_dev) >> 32)
+
+#define rtems_filesystem_dev_minor_t( _dev ) \
+ (rtems_device_minor_number) ((_dev) & 0xFFFFFFFF)
+
#define rtems_filesystem_split_dev_t( _dev, _major, _minor ) \
do { \
- (_major) = (rtems_device_major_number) ((_dev) >> 32); \
- (_minor) = (rtems_device_minor_number) ((_dev) & 0xFFFFFFFF); \
+ (_major) = rtems_filesystem_dev_major_t ( _dev ); \
+ (_minor) = rtems_filesystem_dev_minor_t( _dev ); \
} while(0)
/*
diff --git a/c/src/lib/libc/link.c b/c/src/lib/libc/link.c
index 5bf8f90353..03bdaee343 100644
--- a/c/src/lib/libc/link.c
+++ b/c/src/lib/libc/link.c
@@ -41,8 +41,16 @@ int link(
*/
rtems_filesystem_get_start_loc( new, &i, &parent_loc );
+
+ if ( !parent_loc.ops->evalformake ) {
+ rtems_filesystem_freenode( &existing_loc );
+ rtems_filesystem_freenode( &parent_loc );
+ set_errno_and_return_minus_one( ENOTSUP );
+ }
+
result = (*parent_loc.ops->evalformake)( &new[i], &parent_loc, &name_start );
if ( result != 0 ) {
+ rtems_filesystem_freenode( &existing_loc );
rtems_filesystem_freenode( &parent_loc );
set_errno_and_return_minus_one( result );
}
diff --git a/c/src/lib/libc/memfile.c b/c/src/lib/libc/memfile.c
index a2dc695044..9974a3d2d5 100644
--- a/c/src/lib/libc/memfile.c
+++ b/c/src/lib/libc/memfile.c
@@ -112,6 +112,9 @@ int memfile_close(
the_jnode = iop->file_info;
+ if (iop->flags & LIBIO_FLAGS_APPEND)
+ iop->offset = the_jnode->info.file.size;
+
return 0;
}
@@ -340,7 +343,6 @@ MEMFILE_STATIC int IMFS_memfile_addblock(
#endif
memory = memfile_alloc_block();
- assert( memory );
if ( !memory )
return 1;
*block_entry_ptr = memory;
diff --git a/c/src/lib/libc/mknod.c b/c/src/lib/libc/mknod.c
index 0a3a108f9a..30a3f548a2 100644
--- a/c/src/lib/libc/mknod.c
+++ b/c/src/lib/libc/mknod.c
@@ -43,6 +43,11 @@ int mknod(
rtems_filesystem_get_start_loc( pathname, &i, &temp_loc );
+ if ( !temp_loc.ops->evalformake ) {
+ rtems_filesystem_freenode( &temp_loc );
+ set_errno_and_return_minus_one( ENOTSUP );
+ }
+
result = (*temp_loc.ops->evalformake)(
&pathname[i],
&temp_loc,
diff --git a/c/src/lib/libc/symlink.c b/c/src/lib/libc/symlink.c
index 6a31a25bad..c63abf0a25 100644
--- a/c/src/lib/libc/symlink.c
+++ b/c/src/lib/libc/symlink.c
@@ -28,6 +28,11 @@ int symlink(
if ( result != 0 )
return -1;
+ if ( !loc.ops->symlink ) {
+ rtems_filesystem_freenode( &loc );
+ set_errno_and_return_minus_one( ENOTSUP );
+ }
+
result = (*loc.ops->symlink)( &loc, actualpath, name_start);
rtems_filesystem_freenode( &loc );