Changeset 662678d1 in rtems
- Timestamp:
- 08/25/00 13:13:57 (23 years ago)
- Branches:
- 4.10, 4.11, 4.8, 4.9, 5, master
- Children:
- 1a3b281
- Parents:
- 02fe6ab
- Files:
-
- 15 edited
Legend:
- Unmodified
- Added
- Removed
-
c/src/exec/libcsupport/src/creat.c
r02fe6ab r662678d1 1 /* 2 * $Id$ 3 */ 4 1 5 /* creat() "system call" */ 2 6 -
c/src/exec/libcsupport/src/isatty.c
r02fe6ab r662678d1 1 /* isatty.c */ 2 3 /* Dumb implementation so programs will at least run. */ 1 /* 2 * COPYRIGHT (c) 1989-1999. 3 * On-Line Applications Research Corporation (OAR). 4 * 5 * The license and distribution terms for this file may be 6 * found in the file LICENSE in this distribution or at 7 * http://www.OARcorp.com/rtems/license.html. 8 * 9 * $Id$ 10 */ 4 11 5 12 #include <sys/stat.h> 6 13 7 int 8 isatty (int fd) 14 int isatty( 15 int fd 16 ) 9 17 { 10 18 struct stat buf; … … 12 20 if (fstat (fd, &buf) < 0) 13 21 return 0; 22 14 23 if (S_ISCHR (buf.st_mode)) 15 24 return 1; 25 16 26 return 0; 17 27 } -
c/src/exec/libfs/src/imfs/imfs_directory.c
r02fe6ab r662678d1 1 1 /* 2 * XXX2 * IMFS Directory Access Routines 3 3 * 4 4 * COPYRIGHT (c) 1989-1999. … … 26 26 #include "libio_.h" 27 27 28 /* ----------------------------------------------------------------------- 29 * This rountine will verify that the node being opened as a directory is 30 * in fact a directory node. If it is then the offset into the directory 31 * will be set to 0 to position to the first directory entry. 28 /* 29 * imfs_dir_open 30 * 31 * This rountine will verify that the node being opened as a directory is 32 * in fact a directory node. If it is then the offset into the directory 33 * will be set to 0 to position to the first directory entry. 32 34 */ 33 35 … … 45 47 46 48 if ( the_jnode->type != IMFS_DIRECTORY ) 47 return -1; 49 return -1; /* It wasn't a directory --> return error */ 48 50 49 51 iop->offset = 0; … … 51 53 } 52 54 53 54 55 /* ----------------------------------------------------------------------- 56 * This routine will read the next directory entry based on the directory57 * offset. The offset should be equal to -n- time the size of an individual58 * dirent structure. If n is not an integer multiple of the sizeof a59 * dirent structure, an integer division will be performed to determine60 * directory entry that will be returned in the buffer. Count should reflect61 * -m- times the sizeof dirent bytes to be placed in the buffer.62 * If there are not -m- dirent elements from the current directory position63 * to the end of the exisiting file, the remaining entries will be placed in64 * the buffer and the returned value will be equal to -m actual- times the65 * size of a directory entry.55 /* 56 * imfs_dir_read 57 * 58 * This routine will read the next directory entry based on the directory 59 * offset. The offset should be equal to -n- time the size of an individual 60 * dirent structure. If n is not an integer multiple of the sizeof a 61 * dirent structure, an integer division will be performed to determine 62 * directory entry that will be returned in the buffer. Count should reflect 63 * -m- times the sizeof dirent bytes to be placed in the buffer. 64 * If there are not -m- dirent elements from the current directory position 65 * to the end of the exisiting file, the remaining entries will be placed in 66 * the buffer and the returned value will be equal to -m actual- times the 67 * size of a directory entry. 66 68 */ 67 69 … … 80 82 IMFS_jnode_t *the_jnode; 81 83 int bytes_transferred; 82 int 83 int 84 int 84 int current_entry; 85 int first_entry; 86 int last_entry; 85 87 struct dirent tmp_dirent; 86 88 … … 101 103 102 104 /* The directory was not empty so try to move to the desired entry in chain*/ 103 for (105 for ( 104 106 current_entry = 0; 105 107 current_entry < last_entry; … … 139 141 140 142 141 /* ----------------------------------------------------------------------- 142 * This routine will be called by the generic close routine to cleanup any 143 * resources that have been allocated for the management of the file 143 /* 144 * imfs_dir_close 145 * 146 * This routine will be called by the generic close routine to cleanup any 147 * resources that have been allocated for the management of the file 144 148 */ 145 149 … … 148 152 ) 149 153 { 150 /* The generic close routine handles the deallocation of the file control */ 151 /* and associated memory. At present the imfs_dir_close simply */ 152 /* returns a successful completion status */ 154 /* 155 * The generic close routine handles the deallocation of the file control 156 * and associated memory. At present the imfs_dir_close simply 157 * returns a successful completion status. 158 */ 153 159 154 160 return 0; … … 157 163 158 164 159 /* ----------------------------------------------------------------------- 160 * This routine will behave in one of three ways based on the state of 161 * argument whence. Based on the state of its value the offset argument will 162 * be interpreted using one of the following methods: 163 * 164 * SEEK_SET - offset is the absolute byte offset from the start of the 165 * logical start of the dirent sequence that represents the 166 * directory 167 * SEEK_CUR - offset is used as the relative byte offset from the current 168 * directory position index held in the iop structure 169 * SEEK_END - N/A --> This will cause an assert. 165 /* 166 * imfs_dir_lseek 167 * 168 * This routine will behave in one of three ways based on the state of 169 * argument whence. Based on the state of its value the offset argument will 170 * be interpreted using one of the following methods: 171 * 172 * SEEK_SET - offset is the absolute byte offset from the start of the 173 * logical start of the dirent sequence that represents the 174 * directory 175 * SEEK_CUR - offset is used as the relative byte offset from the current 176 * directory position index held in the iop structure 177 * SEEK_END - N/A --> This will cause an assert. 170 178 */ 171 179 … … 181 189 182 190 183 switch( whence ) 184 { 185 case SEEK_SET: /* absolute move from the start of the file */ 191 switch( whence ) { 192 case SEEK_SET: /* absolute move from the start of the file */ 186 193 iop->offset = normal_offset; 187 194 break; 188 195 189 case SEEK_CUR: 196 case SEEK_CUR: /* relative move */ 190 197 iop->offset = iop->offset + normal_offset; 191 198 break; 192 199 193 case SEEK_END: 194 200 case SEEK_END: /* Movement past the end of the directory via lseek */ 201 /* is not a permitted operation */ 195 202 default: 196 203 set_errno_and_return_minus_one( EINVAL ); … … 204 211 205 212 206 /* ----------------------------------------------------------------------- 207 * This routine will obtain the following information concerning the current 208 * directory: 209 * st_dev 0ll 210 * st_ino 1 211 * st_mode mode extracted from the jnode 212 * st_nlink number of links to this node 213 * st_uid uid extracted from the jnode 214 * st_gid gid extracted from the jnode 215 * st_rdev 0ll 216 * st_size the number of bytes in the directory 217 * This is calculated by taking the number of entries 218 * in the directory and multiplying by the size of a 219 * dirent structure 220 * st_blksize 0 221 * st_blocks 0 222 * stat_atime time of last access 223 * stat_mtime time of last modification 224 * stat_ctime time of the last change 225 * 226 * This information will be returned to the calling function in a -stat- struct 227 * 213 /* 214 * imfs_dir_fstat 215 * 216 * This routine will obtain the following information concerning the current 217 * directory: 218 * st_dev 0ll 219 * st_ino 1 220 * st_mode mode extracted from the jnode 221 * st_nlink number of links to this node 222 * st_uid uid extracted from the jnode 223 * st_gid gid extracted from the jnode 224 * st_rdev 0ll 225 * st_size the number of bytes in the directory 226 * This is calculated by taking the number of entries 227 * in the directory and multiplying by the size of a 228 * dirent structure 229 * st_blksize 0 230 * st_blocks 0 231 * stat_atime time of last access 232 * stat_mtime time of last modification 233 * stat_ctime time of the last change 234 * 235 * This information will be returned to the calling function in a -stat- struct 236 * 228 237 */ 229 238 -
c/src/exec/libfs/src/imfs/imfs_handlers_directory.c
r02fe6ab r662678d1 37 37 }; 38 38 39 40 41 42 43 44 45 -
c/src/lib/ChangeLog
r02fe6ab r662678d1 1 2 2000-08-25 Joel Sherrill <joel.sherrill@OARcorp.com> 3 4 * libc/isatty.c, libc/imfs_handlers_directory.c, libc/creat.c, 5 libc/imfs_directory.c: Fixed style issues. 1 6 2 7 2000-08-11 Chris Johns <ccj@acm.org> -
c/src/lib/libc/creat.c
r02fe6ab r662678d1 1 /* 2 * $Id$ 3 */ 4 1 5 /* creat() "system call" */ 2 6 -
c/src/lib/libc/imfs_directory.c
r02fe6ab r662678d1 1 1 /* 2 * XXX2 * IMFS Directory Access Routines 3 3 * 4 4 * COPYRIGHT (c) 1989-1999. … … 26 26 #include "libio_.h" 27 27 28 /* ----------------------------------------------------------------------- 29 * This rountine will verify that the node being opened as a directory is 30 * in fact a directory node. If it is then the offset into the directory 31 * will be set to 0 to position to the first directory entry. 28 /* 29 * imfs_dir_open 30 * 31 * This rountine will verify that the node being opened as a directory is 32 * in fact a directory node. If it is then the offset into the directory 33 * will be set to 0 to position to the first directory entry. 32 34 */ 33 35 … … 45 47 46 48 if ( the_jnode->type != IMFS_DIRECTORY ) 47 return -1; 49 return -1; /* It wasn't a directory --> return error */ 48 50 49 51 iop->offset = 0; … … 51 53 } 52 54 53 54 55 /* ----------------------------------------------------------------------- 56 * This routine will read the next directory entry based on the directory57 * offset. The offset should be equal to -n- time the size of an individual58 * dirent structure. If n is not an integer multiple of the sizeof a59 * dirent structure, an integer division will be performed to determine60 * directory entry that will be returned in the buffer. Count should reflect61 * -m- times the sizeof dirent bytes to be placed in the buffer.62 * If there are not -m- dirent elements from the current directory position63 * to the end of the exisiting file, the remaining entries will be placed in64 * the buffer and the returned value will be equal to -m actual- times the65 * size of a directory entry.55 /* 56 * imfs_dir_read 57 * 58 * This routine will read the next directory entry based on the directory 59 * offset. The offset should be equal to -n- time the size of an individual 60 * dirent structure. If n is not an integer multiple of the sizeof a 61 * dirent structure, an integer division will be performed to determine 62 * directory entry that will be returned in the buffer. Count should reflect 63 * -m- times the sizeof dirent bytes to be placed in the buffer. 64 * If there are not -m- dirent elements from the current directory position 65 * to the end of the exisiting file, the remaining entries will be placed in 66 * the buffer and the returned value will be equal to -m actual- times the 67 * size of a directory entry. 66 68 */ 67 69 … … 80 82 IMFS_jnode_t *the_jnode; 81 83 int bytes_transferred; 82 int 83 int 84 int 84 int current_entry; 85 int first_entry; 86 int last_entry; 85 87 struct dirent tmp_dirent; 86 88 … … 101 103 102 104 /* The directory was not empty so try to move to the desired entry in chain*/ 103 for (105 for ( 104 106 current_entry = 0; 105 107 current_entry < last_entry; … … 139 141 140 142 141 /* ----------------------------------------------------------------------- 142 * This routine will be called by the generic close routine to cleanup any 143 * resources that have been allocated for the management of the file 143 /* 144 * imfs_dir_close 145 * 146 * This routine will be called by the generic close routine to cleanup any 147 * resources that have been allocated for the management of the file 144 148 */ 145 149 … … 148 152 ) 149 153 { 150 /* The generic close routine handles the deallocation of the file control */ 151 /* and associated memory. At present the imfs_dir_close simply */ 152 /* returns a successful completion status */ 154 /* 155 * The generic close routine handles the deallocation of the file control 156 * and associated memory. At present the imfs_dir_close simply 157 * returns a successful completion status. 158 */ 153 159 154 160 return 0; … … 157 163 158 164 159 /* ----------------------------------------------------------------------- 160 * This routine will behave in one of three ways based on the state of 161 * argument whence. Based on the state of its value the offset argument will 162 * be interpreted using one of the following methods: 163 * 164 * SEEK_SET - offset is the absolute byte offset from the start of the 165 * logical start of the dirent sequence that represents the 166 * directory 167 * SEEK_CUR - offset is used as the relative byte offset from the current 168 * directory position index held in the iop structure 169 * SEEK_END - N/A --> This will cause an assert. 165 /* 166 * imfs_dir_lseek 167 * 168 * This routine will behave in one of three ways based on the state of 169 * argument whence. Based on the state of its value the offset argument will 170 * be interpreted using one of the following methods: 171 * 172 * SEEK_SET - offset is the absolute byte offset from the start of the 173 * logical start of the dirent sequence that represents the 174 * directory 175 * SEEK_CUR - offset is used as the relative byte offset from the current 176 * directory position index held in the iop structure 177 * SEEK_END - N/A --> This will cause an assert. 170 178 */ 171 179 … … 181 189 182 190 183 switch( whence ) 184 { 185 case SEEK_SET: /* absolute move from the start of the file */ 191 switch( whence ) { 192 case SEEK_SET: /* absolute move from the start of the file */ 186 193 iop->offset = normal_offset; 187 194 break; 188 195 189 case SEEK_CUR: 196 case SEEK_CUR: /* relative move */ 190 197 iop->offset = iop->offset + normal_offset; 191 198 break; 192 199 193 case SEEK_END: 194 200 case SEEK_END: /* Movement past the end of the directory via lseek */ 201 /* is not a permitted operation */ 195 202 default: 196 203 set_errno_and_return_minus_one( EINVAL ); … … 204 211 205 212 206 /* ----------------------------------------------------------------------- 207 * This routine will obtain the following information concerning the current 208 * directory: 209 * st_dev 0ll 210 * st_ino 1 211 * st_mode mode extracted from the jnode 212 * st_nlink number of links to this node 213 * st_uid uid extracted from the jnode 214 * st_gid gid extracted from the jnode 215 * st_rdev 0ll 216 * st_size the number of bytes in the directory 217 * This is calculated by taking the number of entries 218 * in the directory and multiplying by the size of a 219 * dirent structure 220 * st_blksize 0 221 * st_blocks 0 222 * stat_atime time of last access 223 * stat_mtime time of last modification 224 * stat_ctime time of the last change 225 * 226 * This information will be returned to the calling function in a -stat- struct 227 * 213 /* 214 * imfs_dir_fstat 215 * 216 * This routine will obtain the following information concerning the current 217 * directory: 218 * st_dev 0ll 219 * st_ino 1 220 * st_mode mode extracted from the jnode 221 * st_nlink number of links to this node 222 * st_uid uid extracted from the jnode 223 * st_gid gid extracted from the jnode 224 * st_rdev 0ll 225 * st_size the number of bytes in the directory 226 * This is calculated by taking the number of entries 227 * in the directory and multiplying by the size of a 228 * dirent structure 229 * st_blksize 0 230 * st_blocks 0 231 * stat_atime time of last access 232 * stat_mtime time of last modification 233 * stat_ctime time of the last change 234 * 235 * This information will be returned to the calling function in a -stat- struct 236 * 228 237 */ 229 238 -
c/src/lib/libc/imfs_handlers_directory.c
r02fe6ab r662678d1 37 37 }; 38 38 39 40 41 42 43 44 45 -
c/src/lib/libc/isatty.c
r02fe6ab r662678d1 1 /* isatty.c */ 2 3 /* Dumb implementation so programs will at least run. */ 1 /* 2 * COPYRIGHT (c) 1989-1999. 3 * On-Line Applications Research Corporation (OAR). 4 * 5 * The license and distribution terms for this file may be 6 * found in the file LICENSE in this distribution or at 7 * http://www.OARcorp.com/rtems/license.html. 8 * 9 * $Id$ 10 */ 4 11 5 12 #include <sys/stat.h> 6 13 7 int 8 isatty (int fd) 14 int isatty( 15 int fd 16 ) 9 17 { 10 18 struct stat buf; … … 12 20 if (fstat (fd, &buf) < 0) 13 21 return 0; 22 14 23 if (S_ISCHR (buf.st_mode)) 15 24 return 1; 25 16 26 return 0; 17 27 } -
c/src/libfs/src/imfs/imfs_directory.c
r02fe6ab r662678d1 1 1 /* 2 * XXX2 * IMFS Directory Access Routines 3 3 * 4 4 * COPYRIGHT (c) 1989-1999. … … 26 26 #include "libio_.h" 27 27 28 /* ----------------------------------------------------------------------- 29 * This rountine will verify that the node being opened as a directory is 30 * in fact a directory node. If it is then the offset into the directory 31 * will be set to 0 to position to the first directory entry. 28 /* 29 * imfs_dir_open 30 * 31 * This rountine will verify that the node being opened as a directory is 32 * in fact a directory node. If it is then the offset into the directory 33 * will be set to 0 to position to the first directory entry. 32 34 */ 33 35 … … 45 47 46 48 if ( the_jnode->type != IMFS_DIRECTORY ) 47 return -1; 49 return -1; /* It wasn't a directory --> return error */ 48 50 49 51 iop->offset = 0; … … 51 53 } 52 54 53 54 55 /* ----------------------------------------------------------------------- 56 * This routine will read the next directory entry based on the directory57 * offset. The offset should be equal to -n- time the size of an individual58 * dirent structure. If n is not an integer multiple of the sizeof a59 * dirent structure, an integer division will be performed to determine60 * directory entry that will be returned in the buffer. Count should reflect61 * -m- times the sizeof dirent bytes to be placed in the buffer.62 * If there are not -m- dirent elements from the current directory position63 * to the end of the exisiting file, the remaining entries will be placed in64 * the buffer and the returned value will be equal to -m actual- times the65 * size of a directory entry.55 /* 56 * imfs_dir_read 57 * 58 * This routine will read the next directory entry based on the directory 59 * offset. The offset should be equal to -n- time the size of an individual 60 * dirent structure. If n is not an integer multiple of the sizeof a 61 * dirent structure, an integer division will be performed to determine 62 * directory entry that will be returned in the buffer. Count should reflect 63 * -m- times the sizeof dirent bytes to be placed in the buffer. 64 * If there are not -m- dirent elements from the current directory position 65 * to the end of the exisiting file, the remaining entries will be placed in 66 * the buffer and the returned value will be equal to -m actual- times the 67 * size of a directory entry. 66 68 */ 67 69 … … 80 82 IMFS_jnode_t *the_jnode; 81 83 int bytes_transferred; 82 int 83 int 84 int 84 int current_entry; 85 int first_entry; 86 int last_entry; 85 87 struct dirent tmp_dirent; 86 88 … … 101 103 102 104 /* The directory was not empty so try to move to the desired entry in chain*/ 103 for (105 for ( 104 106 current_entry = 0; 105 107 current_entry < last_entry; … … 139 141 140 142 141 /* ----------------------------------------------------------------------- 142 * This routine will be called by the generic close routine to cleanup any 143 * resources that have been allocated for the management of the file 143 /* 144 * imfs_dir_close 145 * 146 * This routine will be called by the generic close routine to cleanup any 147 * resources that have been allocated for the management of the file 144 148 */ 145 149 … … 148 152 ) 149 153 { 150 /* The generic close routine handles the deallocation of the file control */ 151 /* and associated memory. At present the imfs_dir_close simply */ 152 /* returns a successful completion status */ 154 /* 155 * The generic close routine handles the deallocation of the file control 156 * and associated memory. At present the imfs_dir_close simply 157 * returns a successful completion status. 158 */ 153 159 154 160 return 0; … … 157 163 158 164 159 /* ----------------------------------------------------------------------- 160 * This routine will behave in one of three ways based on the state of 161 * argument whence. Based on the state of its value the offset argument will 162 * be interpreted using one of the following methods: 163 * 164 * SEEK_SET - offset is the absolute byte offset from the start of the 165 * logical start of the dirent sequence that represents the 166 * directory 167 * SEEK_CUR - offset is used as the relative byte offset from the current 168 * directory position index held in the iop structure 169 * SEEK_END - N/A --> This will cause an assert. 165 /* 166 * imfs_dir_lseek 167 * 168 * This routine will behave in one of three ways based on the state of 169 * argument whence. Based on the state of its value the offset argument will 170 * be interpreted using one of the following methods: 171 * 172 * SEEK_SET - offset is the absolute byte offset from the start of the 173 * logical start of the dirent sequence that represents the 174 * directory 175 * SEEK_CUR - offset is used as the relative byte offset from the current 176 * directory position index held in the iop structure 177 * SEEK_END - N/A --> This will cause an assert. 170 178 */ 171 179 … … 181 189 182 190 183 switch( whence ) 184 { 185 case SEEK_SET: /* absolute move from the start of the file */ 191 switch( whence ) { 192 case SEEK_SET: /* absolute move from the start of the file */ 186 193 iop->offset = normal_offset; 187 194 break; 188 195 189 case SEEK_CUR: 196 case SEEK_CUR: /* relative move */ 190 197 iop->offset = iop->offset + normal_offset; 191 198 break; 192 199 193 case SEEK_END: 194 200 case SEEK_END: /* Movement past the end of the directory via lseek */ 201 /* is not a permitted operation */ 195 202 default: 196 203 set_errno_and_return_minus_one( EINVAL ); … … 204 211 205 212 206 /* ----------------------------------------------------------------------- 207 * This routine will obtain the following information concerning the current 208 * directory: 209 * st_dev 0ll 210 * st_ino 1 211 * st_mode mode extracted from the jnode 212 * st_nlink number of links to this node 213 * st_uid uid extracted from the jnode 214 * st_gid gid extracted from the jnode 215 * st_rdev 0ll 216 * st_size the number of bytes in the directory 217 * This is calculated by taking the number of entries 218 * in the directory and multiplying by the size of a 219 * dirent structure 220 * st_blksize 0 221 * st_blocks 0 222 * stat_atime time of last access 223 * stat_mtime time of last modification 224 * stat_ctime time of the last change 225 * 226 * This information will be returned to the calling function in a -stat- struct 227 * 213 /* 214 * imfs_dir_fstat 215 * 216 * This routine will obtain the following information concerning the current 217 * directory: 218 * st_dev 0ll 219 * st_ino 1 220 * st_mode mode extracted from the jnode 221 * st_nlink number of links to this node 222 * st_uid uid extracted from the jnode 223 * st_gid gid extracted from the jnode 224 * st_rdev 0ll 225 * st_size the number of bytes in the directory 226 * This is calculated by taking the number of entries 227 * in the directory and multiplying by the size of a 228 * dirent structure 229 * st_blksize 0 230 * st_blocks 0 231 * stat_atime time of last access 232 * stat_mtime time of last modification 233 * stat_ctime time of the last change 234 * 235 * This information will be returned to the calling function in a -stat- struct 236 * 228 237 */ 229 238 -
c/src/libfs/src/imfs/imfs_handlers_directory.c
r02fe6ab r662678d1 37 37 }; 38 38 39 40 41 42 43 44 45 -
cpukit/libcsupport/src/creat.c
r02fe6ab r662678d1 1 /* 2 * $Id$ 3 */ 4 1 5 /* creat() "system call" */ 2 6 -
cpukit/libcsupport/src/isatty.c
r02fe6ab r662678d1 1 /* isatty.c */ 2 3 /* Dumb implementation so programs will at least run. */ 1 /* 2 * COPYRIGHT (c) 1989-1999. 3 * On-Line Applications Research Corporation (OAR). 4 * 5 * The license and distribution terms for this file may be 6 * found in the file LICENSE in this distribution or at 7 * http://www.OARcorp.com/rtems/license.html. 8 * 9 * $Id$ 10 */ 4 11 5 12 #include <sys/stat.h> 6 13 7 int 8 isatty (int fd) 14 int isatty( 15 int fd 16 ) 9 17 { 10 18 struct stat buf; … … 12 20 if (fstat (fd, &buf) < 0) 13 21 return 0; 22 14 23 if (S_ISCHR (buf.st_mode)) 15 24 return 1; 25 16 26 return 0; 17 27 } -
cpukit/libfs/src/imfs/imfs_directory.c
r02fe6ab r662678d1 1 1 /* 2 * XXX2 * IMFS Directory Access Routines 3 3 * 4 4 * COPYRIGHT (c) 1989-1999. … … 26 26 #include "libio_.h" 27 27 28 /* ----------------------------------------------------------------------- 29 * This rountine will verify that the node being opened as a directory is 30 * in fact a directory node. If it is then the offset into the directory 31 * will be set to 0 to position to the first directory entry. 28 /* 29 * imfs_dir_open 30 * 31 * This rountine will verify that the node being opened as a directory is 32 * in fact a directory node. If it is then the offset into the directory 33 * will be set to 0 to position to the first directory entry. 32 34 */ 33 35 … … 45 47 46 48 if ( the_jnode->type != IMFS_DIRECTORY ) 47 return -1; 49 return -1; /* It wasn't a directory --> return error */ 48 50 49 51 iop->offset = 0; … … 51 53 } 52 54 53 54 55 /* ----------------------------------------------------------------------- 56 * This routine will read the next directory entry based on the directory57 * offset. The offset should be equal to -n- time the size of an individual58 * dirent structure. If n is not an integer multiple of the sizeof a59 * dirent structure, an integer division will be performed to determine60 * directory entry that will be returned in the buffer. Count should reflect61 * -m- times the sizeof dirent bytes to be placed in the buffer.62 * If there are not -m- dirent elements from the current directory position63 * to the end of the exisiting file, the remaining entries will be placed in64 * the buffer and the returned value will be equal to -m actual- times the65 * size of a directory entry.55 /* 56 * imfs_dir_read 57 * 58 * This routine will read the next directory entry based on the directory 59 * offset. The offset should be equal to -n- time the size of an individual 60 * dirent structure. If n is not an integer multiple of the sizeof a 61 * dirent structure, an integer division will be performed to determine 62 * directory entry that will be returned in the buffer. Count should reflect 63 * -m- times the sizeof dirent bytes to be placed in the buffer. 64 * If there are not -m- dirent elements from the current directory position 65 * to the end of the exisiting file, the remaining entries will be placed in 66 * the buffer and the returned value will be equal to -m actual- times the 67 * size of a directory entry. 66 68 */ 67 69 … … 80 82 IMFS_jnode_t *the_jnode; 81 83 int bytes_transferred; 82 int 83 int 84 int 84 int current_entry; 85 int first_entry; 86 int last_entry; 85 87 struct dirent tmp_dirent; 86 88 … … 101 103 102 104 /* The directory was not empty so try to move to the desired entry in chain*/ 103 for (105 for ( 104 106 current_entry = 0; 105 107 current_entry < last_entry; … … 139 141 140 142 141 /* ----------------------------------------------------------------------- 142 * This routine will be called by the generic close routine to cleanup any 143 * resources that have been allocated for the management of the file 143 /* 144 * imfs_dir_close 145 * 146 * This routine will be called by the generic close routine to cleanup any 147 * resources that have been allocated for the management of the file 144 148 */ 145 149 … … 148 152 ) 149 153 { 150 /* The generic close routine handles the deallocation of the file control */ 151 /* and associated memory. At present the imfs_dir_close simply */ 152 /* returns a successful completion status */ 154 /* 155 * The generic close routine handles the deallocation of the file control 156 * and associated memory. At present the imfs_dir_close simply 157 * returns a successful completion status. 158 */ 153 159 154 160 return 0; … … 157 163 158 164 159 /* ----------------------------------------------------------------------- 160 * This routine will behave in one of three ways based on the state of 161 * argument whence. Based on the state of its value the offset argument will 162 * be interpreted using one of the following methods: 163 * 164 * SEEK_SET - offset is the absolute byte offset from the start of the 165 * logical start of the dirent sequence that represents the 166 * directory 167 * SEEK_CUR - offset is used as the relative byte offset from the current 168 * directory position index held in the iop structure 169 * SEEK_END - N/A --> This will cause an assert. 165 /* 166 * imfs_dir_lseek 167 * 168 * This routine will behave in one of three ways based on the state of 169 * argument whence. Based on the state of its value the offset argument will 170 * be interpreted using one of the following methods: 171 * 172 * SEEK_SET - offset is the absolute byte offset from the start of the 173 * logical start of the dirent sequence that represents the 174 * directory 175 * SEEK_CUR - offset is used as the relative byte offset from the current 176 * directory position index held in the iop structure 177 * SEEK_END - N/A --> This will cause an assert. 170 178 */ 171 179 … … 181 189 182 190 183 switch( whence ) 184 { 185 case SEEK_SET: /* absolute move from the start of the file */ 191 switch( whence ) { 192 case SEEK_SET: /* absolute move from the start of the file */ 186 193 iop->offset = normal_offset; 187 194 break; 188 195 189 case SEEK_CUR: 196 case SEEK_CUR: /* relative move */ 190 197 iop->offset = iop->offset + normal_offset; 191 198 break; 192 199 193 case SEEK_END: 194 200 case SEEK_END: /* Movement past the end of the directory via lseek */ 201 /* is not a permitted operation */ 195 202 default: 196 203 set_errno_and_return_minus_one( EINVAL ); … … 204 211 205 212 206 /* ----------------------------------------------------------------------- 207 * This routine will obtain the following information concerning the current 208 * directory: 209 * st_dev 0ll 210 * st_ino 1 211 * st_mode mode extracted from the jnode 212 * st_nlink number of links to this node 213 * st_uid uid extracted from the jnode 214 * st_gid gid extracted from the jnode 215 * st_rdev 0ll 216 * st_size the number of bytes in the directory 217 * This is calculated by taking the number of entries 218 * in the directory and multiplying by the size of a 219 * dirent structure 220 * st_blksize 0 221 * st_blocks 0 222 * stat_atime time of last access 223 * stat_mtime time of last modification 224 * stat_ctime time of the last change 225 * 226 * This information will be returned to the calling function in a -stat- struct 227 * 213 /* 214 * imfs_dir_fstat 215 * 216 * This routine will obtain the following information concerning the current 217 * directory: 218 * st_dev 0ll 219 * st_ino 1 220 * st_mode mode extracted from the jnode 221 * st_nlink number of links to this node 222 * st_uid uid extracted from the jnode 223 * st_gid gid extracted from the jnode 224 * st_rdev 0ll 225 * st_size the number of bytes in the directory 226 * This is calculated by taking the number of entries 227 * in the directory and multiplying by the size of a 228 * dirent structure 229 * st_blksize 0 230 * st_blocks 0 231 * stat_atime time of last access 232 * stat_mtime time of last modification 233 * stat_ctime time of the last change 234 * 235 * This information will be returned to the calling function in a -stat- struct 236 * 228 237 */ 229 238 -
cpukit/libfs/src/imfs/imfs_handlers_directory.c
r02fe6ab r662678d1 37 37 }; 38 38 39 40 41 42 43 44 45
Note: See TracChangeset
for help on using the changeset viewer.