1 | @c |
---|
2 | @c COPYRIGHT (c) 1988-1998. |
---|
3 | @c On-Line Applications Research Corporation (OAR). |
---|
4 | @c All rights reserved. |
---|
5 | @c |
---|
6 | @c $Id$ |
---|
7 | @c |
---|
8 | |
---|
9 | @chapter Files and Directories Manager |
---|
10 | |
---|
11 | @section Introduction |
---|
12 | |
---|
13 | The files and directories manager is ... |
---|
14 | |
---|
15 | The directives provided by the files and directories manager are: |
---|
16 | |
---|
17 | @itemize @bullet |
---|
18 | @item @code{opendir} - Open a Directory |
---|
19 | @item @code{readdir} - Reads a directory |
---|
20 | @item @code{readdir_r} - |
---|
21 | @item @code{rewinddir} - |
---|
22 | @item @code{scandir} - |
---|
23 | @item @code{telldir} - |
---|
24 | @item @code{closedir} - |
---|
25 | @item @code{chdir} - Changes the current working directory |
---|
26 | @item @code{getcwd} - Gets current working directory |
---|
27 | @item @code{open} - Opens a file |
---|
28 | @item @code{creat} - |
---|
29 | @item @code{umask} - Sets a file creation mask |
---|
30 | @item @code{link} - Creates a link to a file |
---|
31 | @item @code{mkdir} - Makes a directory |
---|
32 | @item @code{mkfifo} - |
---|
33 | @item @code{unlink} - Removes a directory entry |
---|
34 | @item @code{rmdir} - |
---|
35 | @item @code{rename} - Renames a file |
---|
36 | @item @code{stat} - Gets information about a file. |
---|
37 | @item @code{fstat} - |
---|
38 | @item @code{access} - |
---|
39 | @item @code{chmod} - Changes file mode |
---|
40 | @item @code{fchmod} - |
---|
41 | @item @code{chown} - Changes the owner and/ or group of a file |
---|
42 | @item @code{utime} - |
---|
43 | @item @code{ftrunctate} - |
---|
44 | @item @code{pathconf} - |
---|
45 | @item @code{fpathconf} - |
---|
46 | @end itemize |
---|
47 | |
---|
48 | @section Background |
---|
49 | |
---|
50 | @section Operations |
---|
51 | |
---|
52 | @section Directives |
---|
53 | |
---|
54 | This section details the files and directories manager's directives. |
---|
55 | A subsection is dedicated to each of this manager's directives |
---|
56 | and describes the calling sequence, related constants, usage, |
---|
57 | and status codes. |
---|
58 | |
---|
59 | @page |
---|
60 | @subsection opendir - Open a Directory |
---|
61 | |
---|
62 | @subheading CALLING SEQUENCE: |
---|
63 | |
---|
64 | @ifset is-C |
---|
65 | @example |
---|
66 | #include <sys/types.h> |
---|
67 | #include <dirent.h> |
---|
68 | |
---|
69 | int opendir( |
---|
70 | const char *dirname |
---|
71 | ); |
---|
72 | @end example |
---|
73 | @end ifset |
---|
74 | |
---|
75 | @ifset is-Ada |
---|
76 | @end ifset |
---|
77 | |
---|
78 | @subheading STATUS CODES: |
---|
79 | |
---|
80 | @table @b |
---|
81 | @item EACCES |
---|
82 | Search permission was denied on a component of the path |
---|
83 | prefix of @code{dirname}, or read permission is denied |
---|
84 | for the directory itself. |
---|
85 | |
---|
86 | @item E |
---|
87 | The |
---|
88 | |
---|
89 | @end table |
---|
90 | |
---|
91 | @subheading DESCRIPTION: |
---|
92 | |
---|
93 | This routine opens a directory stream corresponding to the |
---|
94 | directory specified by the @code{dirname} argument. The |
---|
95 | directory stream is positioned at the first entry. |
---|
96 | |
---|
97 | @subheading NOTES: |
---|
98 | |
---|
99 | The routine is implemented in Cygnus newlib. |
---|
100 | |
---|
101 | @page |
---|
102 | @subsection readdir - Reads a directory |
---|
103 | |
---|
104 | @subheading CALLING SEQUENCE: |
---|
105 | |
---|
106 | @ifset is-C |
---|
107 | @example |
---|
108 | #include <sys/types.h> |
---|
109 | #include <dirent.h> |
---|
110 | |
---|
111 | int readdir( |
---|
112 | DIR *dirp |
---|
113 | ); |
---|
114 | @end example |
---|
115 | @end ifset |
---|
116 | |
---|
117 | @ifset is-Ada |
---|
118 | @end ifset |
---|
119 | |
---|
120 | @subheading STATUS CODES: |
---|
121 | |
---|
122 | @table @b |
---|
123 | @item EBADF |
---|
124 | Invalid file descriptor |
---|
125 | |
---|
126 | @end table |
---|
127 | |
---|
128 | @subheading DESCRIPTION: |
---|
129 | |
---|
130 | The @code{readdir()} function returns a pointer to a structure @code{dirent} |
---|
131 | representing the next directory entry from the directory stream pointed to |
---|
132 | by @code{dirp}. On end-of-file, NULL is returned. |
---|
133 | |
---|
134 | The @code{readdir()} function may (or may not) return entries for . or .. Your |
---|
135 | program should tolerate reading dot and dot-dot but not require them. |
---|
136 | |
---|
137 | The data pointed to be @code{readdir()} may be overwritten by another call to |
---|
138 | @code{readdir()} for the same directory stream. It will not be overwritten by |
---|
139 | a call for another directory. |
---|
140 | |
---|
141 | @subheading NOTES: |
---|
142 | |
---|
143 | If @code{ptr} is not a pointer returned by @code{malloc()}, @code{calloc()}, or |
---|
144 | @code{realloc()} or has been deallocated with @code{free()} or @code{realloc()}, |
---|
145 | the results are not portable and are probably disastrous. |
---|
146 | |
---|
147 | The routine is implemented in Cygnus newlib. |
---|
148 | |
---|
149 | @page |
---|
150 | @subsection readdir_r - |
---|
151 | |
---|
152 | @subheading CALLING SEQUENCE: |
---|
153 | |
---|
154 | @ifset is-C |
---|
155 | @example |
---|
156 | int readdir_r( |
---|
157 | ); |
---|
158 | @end example |
---|
159 | @end ifset |
---|
160 | |
---|
161 | @ifset is-Ada |
---|
162 | @end ifset |
---|
163 | |
---|
164 | @subheading STATUS CODES: |
---|
165 | |
---|
166 | @table @b |
---|
167 | @item E |
---|
168 | The |
---|
169 | |
---|
170 | @end table |
---|
171 | |
---|
172 | @subheading DESCRIPTION: |
---|
173 | |
---|
174 | @subheading NOTES: |
---|
175 | |
---|
176 | XXX must be implemented in RTEMS. |
---|
177 | |
---|
178 | @page |
---|
179 | @subsection rewinddir - |
---|
180 | |
---|
181 | @subheading CALLING SEQUENCE: |
---|
182 | |
---|
183 | @ifset is-C |
---|
184 | @example |
---|
185 | int rewinddir( |
---|
186 | ); |
---|
187 | @end example |
---|
188 | @end ifset |
---|
189 | |
---|
190 | @ifset is-Ada |
---|
191 | @end ifset |
---|
192 | |
---|
193 | @subheading STATUS CODES: |
---|
194 | |
---|
195 | @table @b |
---|
196 | @item E |
---|
197 | The |
---|
198 | |
---|
199 | @end table |
---|
200 | |
---|
201 | @subheading DESCRIPTION: |
---|
202 | |
---|
203 | @subheading NOTES: |
---|
204 | |
---|
205 | The routine is implemented in Cygnus newlib. |
---|
206 | |
---|
207 | @page |
---|
208 | @subsection scandir - |
---|
209 | |
---|
210 | @subheading CALLING SEQUENCE: |
---|
211 | |
---|
212 | @ifset is-C |
---|
213 | @example |
---|
214 | int scandir( |
---|
215 | ); |
---|
216 | @end example |
---|
217 | @end ifset |
---|
218 | |
---|
219 | @ifset is-Ada |
---|
220 | @end ifset |
---|
221 | |
---|
222 | @subheading STATUS CODES: |
---|
223 | |
---|
224 | @table @b |
---|
225 | @item E |
---|
226 | The |
---|
227 | |
---|
228 | @end table |
---|
229 | |
---|
230 | @subheading DESCRIPTION: |
---|
231 | |
---|
232 | @subheading NOTES: |
---|
233 | |
---|
234 | The routine is implemented in Cygnus newlib. |
---|
235 | |
---|
236 | @page |
---|
237 | @subsection telldir - |
---|
238 | |
---|
239 | @subheading CALLING SEQUENCE: |
---|
240 | |
---|
241 | @ifset is-C |
---|
242 | @example |
---|
243 | int telldir( |
---|
244 | ); |
---|
245 | @end example |
---|
246 | @end ifset |
---|
247 | |
---|
248 | @ifset is-Ada |
---|
249 | @end ifset |
---|
250 | |
---|
251 | @subheading STATUS CODES: |
---|
252 | |
---|
253 | @table @b |
---|
254 | @item E |
---|
255 | The |
---|
256 | |
---|
257 | @end table |
---|
258 | |
---|
259 | @subheading DESCRIPTION: |
---|
260 | |
---|
261 | @subheading NOTES: |
---|
262 | |
---|
263 | The routine is implemented in Cygnus newlib. |
---|
264 | |
---|
265 | |
---|
266 | @page |
---|
267 | @subsection closedir - |
---|
268 | |
---|
269 | @subheading CALLING SEQUENCE: |
---|
270 | |
---|
271 | @ifset is-C |
---|
272 | @example |
---|
273 | int closedir( |
---|
274 | ); |
---|
275 | @end example |
---|
276 | @end ifset |
---|
277 | |
---|
278 | @ifset is-Ada |
---|
279 | @end ifset |
---|
280 | |
---|
281 | @subheading STATUS CODES: |
---|
282 | |
---|
283 | @table @b |
---|
284 | @item E |
---|
285 | The |
---|
286 | |
---|
287 | @end table |
---|
288 | |
---|
289 | @subheading DESCRIPTION: |
---|
290 | |
---|
291 | @subheading NOTES: |
---|
292 | |
---|
293 | The routine is implemented in Cygnus newlib. |
---|
294 | |
---|
295 | @page |
---|
296 | @subsection chdir - Changes the current working directory |
---|
297 | |
---|
298 | @subheading CALLING SEQUENCE: |
---|
299 | |
---|
300 | @ifset is-C |
---|
301 | @example |
---|
302 | #include <unistd.h> |
---|
303 | |
---|
304 | int chdir( const char *path |
---|
305 | ); |
---|
306 | @end example |
---|
307 | @end ifset |
---|
308 | |
---|
309 | @ifset is-Ada |
---|
310 | @end ifset |
---|
311 | |
---|
312 | @subheading STATUS CODES: |
---|
313 | |
---|
314 | @table @b |
---|
315 | @item EACCES |
---|
316 | Search permission is denied for a directory in a file's path prefix. |
---|
317 | |
---|
318 | @item ENAMETOOLONG |
---|
319 | Length of a filename string exceeds PATH_MAX and _POSIX_NO_TRUNC is |
---|
320 | in effect. |
---|
321 | |
---|
322 | @item ENOENT |
---|
323 | A file or directory does not exist. |
---|
324 | |
---|
325 | @item ENOTDIR |
---|
326 | A component of the specified pathname was not a directory when directory |
---|
327 | was expected. |
---|
328 | |
---|
329 | @end table |
---|
330 | |
---|
331 | @subheading DESCRIPTION: |
---|
332 | |
---|
333 | The @code{chdir()} function causes the directory named by @code{path} to |
---|
334 | become the current working directory; that is, the starting point for |
---|
335 | searches of pathnames not beginning with a slash. |
---|
336 | |
---|
337 | If @code{chdir()} detects an error, the current working directory is not |
---|
338 | changed. |
---|
339 | |
---|
340 | @subheading NOTES: None |
---|
341 | |
---|
342 | @page |
---|
343 | @subsection getcwd - Gets current working directory |
---|
344 | |
---|
345 | @subheading CALLING SEQUENCE: |
---|
346 | |
---|
347 | @ifset is-C |
---|
348 | @example |
---|
349 | #include <unistd.h> |
---|
350 | |
---|
351 | int getcwd( |
---|
352 | ); |
---|
353 | @end example |
---|
354 | @end ifset |
---|
355 | |
---|
356 | @ifset is-Ada |
---|
357 | @end ifset |
---|
358 | |
---|
359 | @subheading STATUS CODES: |
---|
360 | |
---|
361 | @table @b |
---|
362 | @item EINVAL |
---|
363 | Invalid argument |
---|
364 | |
---|
365 | @item ERANGE |
---|
366 | Result is too large |
---|
367 | |
---|
368 | @item EACCES |
---|
369 | Search permission is denied for a directory in a file's path prefix. |
---|
370 | |
---|
371 | @end table |
---|
372 | |
---|
373 | @subheading DESCRIPTION: |
---|
374 | |
---|
375 | The @code{getcwd()} function copies the absolute pathname of the current |
---|
376 | working directory to the character array pointed to by @code{buf}. The |
---|
377 | @code{size} argument is the number of bytes available in @cdoe{buf} |
---|
378 | |
---|
379 | @subheading NOTES: |
---|
380 | |
---|
381 | There is no way to determine the maximum string length that @code{fetcwd()} |
---|
382 | may need to return. Applications should tolerate getting @code{ERANGE} |
---|
383 | and allocate a larger buffer. |
---|
384 | |
---|
385 | It is possible for @code{getcwd()} to return EACCES if, say, @code{login} |
---|
386 | puts the process into a directory without read access. |
---|
387 | |
---|
388 | The 1988 standard uses @code{int} instead of @code{size_t} for the second |
---|
389 | parameter. |
---|
390 | |
---|
391 | @page |
---|
392 | @subsection open - Opens a file |
---|
393 | |
---|
394 | @subheading CALLING SEQUENCE: |
---|
395 | |
---|
396 | @ifset is-C |
---|
397 | @example |
---|
398 | #include <sys/types.h> |
---|
399 | #include <sys/stat.h> |
---|
400 | #include <fcntl.h> |
---|
401 | |
---|
402 | int open( |
---|
403 | const char *path, |
---|
404 | int oflag, |
---|
405 | mode_t mode |
---|
406 | ); |
---|
407 | @end example |
---|
408 | @end ifset |
---|
409 | |
---|
410 | @ifset is-Ada |
---|
411 | @end ifset |
---|
412 | |
---|
413 | @subheading STATUS CODES: |
---|
414 | |
---|
415 | @table @b |
---|
416 | @item EACCES |
---|
417 | Search permission is denied for a directory in a file's path prefix. |
---|
418 | @item EEXIST |
---|
419 | The named file already exists. |
---|
420 | @item EINTR |
---|
421 | Function was interrupted by a signal. |
---|
422 | @item EISDIR |
---|
423 | Attempt to open a directory for writing or to rename a file to be a |
---|
424 | directory. |
---|
425 | @item EMFILE |
---|
426 | Too many file descriptors are in use by this process. |
---|
427 | @item ENAMETOOLONG |
---|
428 | Length of a filename string exceeds PATH_MAX and _POSIX_NO_TRUNC is in |
---|
429 | effect. |
---|
430 | @item ENFILE |
---|
431 | Too many files are currently open in the system. |
---|
432 | @item ENOENT |
---|
433 | A file or directory does not exist. |
---|
434 | @item ENOSPC |
---|
435 | No space left on disk. |
---|
436 | @item ENOTDIR |
---|
437 | A component of the specified pathname was not a directory when a directory |
---|
438 | was expected. |
---|
439 | @item ENXIO |
---|
440 | No such device. This error may also occur when a device is not ready, for |
---|
441 | example, a tape drive is off-line. |
---|
442 | @item EROFS |
---|
443 | Read-only file system. |
---|
444 | @end table |
---|
445 | |
---|
446 | @subheading DESCRIPTION: |
---|
447 | |
---|
448 | The @code{open} function establishes a connection between a file and a file |
---|
449 | descriptor. The file descriptor is a small integer that is used by I/O |
---|
450 | functions to reference the file. The @code{path} argument points to the |
---|
451 | pathname for the file. |
---|
452 | |
---|
453 | The @code{oflag} argument is the bitwise inclusive OR of the values of |
---|
454 | symbolic constants. The programmer must specify exactly one of the following |
---|
455 | three symbols: |
---|
456 | |
---|
457 | @table @b |
---|
458 | @item O_RDONLY |
---|
459 | Open for reading only. |
---|
460 | |
---|
461 | @item O_WRONLY |
---|
462 | Open for writing only. |
---|
463 | |
---|
464 | @item O_RDWR |
---|
465 | Open for reading and writing. |
---|
466 | |
---|
467 | @end table |
---|
468 | |
---|
469 | Any combination of the following symbols may also be used. |
---|
470 | |
---|
471 | @table @b |
---|
472 | @item O_APPEND |
---|
473 | Set the file offset to the end-of-file prior to each write. |
---|
474 | |
---|
475 | @item O_CREAT |
---|
476 | If the file does not exist, allow it to be created. This flag indicates |
---|
477 | that the @code{mode} argument is present in the call to @code{open}. |
---|
478 | |
---|
479 | @item O_EXCL |
---|
480 | This flag may be used only if O_CREAT is also set. It causes the call |
---|
481 | to @code{open} to fail if the file already exists. |
---|
482 | |
---|
483 | @item O_NOCTTY |
---|
484 | If @code{path} identifies a terminal, this flag prevents that teminal from |
---|
485 | becoming the controlling terminal for thi9s process. See Chapter 8 for a |
---|
486 | description of terminal I/O. |
---|
487 | |
---|
488 | @item O_NONBLOCK |
---|
489 | Do no wait for the device or file to be ready or available. After the file |
---|
490 | is open, the @code{read} and @code{write} calls return immediately. If the |
---|
491 | process would be delayed in the read or write opermation, -1 is returned and |
---|
492 | @code{errno} is set to @code{EAGAIN} instead of blocking the caller. |
---|
493 | |
---|
494 | @item O_TRUNC |
---|
495 | This flag should be used only on ordinary files opened for writing. It |
---|
496 | causes the file to be tuncated to zero length.. |
---|
497 | |
---|
498 | @end table |
---|
499 | |
---|
500 | Upon successful completion, @code{open} returns a non-negative file |
---|
501 | descriptor. |
---|
502 | |
---|
503 | @subheading NOTES: |
---|
504 | |
---|
505 | |
---|
506 | @page |
---|
507 | @subsection creat - |
---|
508 | |
---|
509 | @subheading CALLING SEQUENCE: |
---|
510 | |
---|
511 | @ifset is-C |
---|
512 | @example |
---|
513 | int creat( |
---|
514 | ); |
---|
515 | @end example |
---|
516 | @end ifset |
---|
517 | |
---|
518 | @ifset is-Ada |
---|
519 | @end ifset |
---|
520 | |
---|
521 | @subheading STATUS CODES: |
---|
522 | |
---|
523 | @table @b |
---|
524 | @item E |
---|
525 | The |
---|
526 | |
---|
527 | @end table |
---|
528 | |
---|
529 | @subheading DESCRIPTION: |
---|
530 | |
---|
531 | @subheading NOTES: |
---|
532 | |
---|
533 | The routine is implemented in Cygnus newlib. |
---|
534 | |
---|
535 | @page |
---|
536 | @subsection umask - Sets a file creation mask. |
---|
537 | |
---|
538 | @subheading CALLING SEQUENCE: |
---|
539 | |
---|
540 | @ifset is-C |
---|
541 | @example |
---|
542 | #include <sys/types.h> |
---|
543 | #include <sys/stat.h> |
---|
544 | |
---|
545 | mode_t umask( |
---|
546 | mode_t cmask |
---|
547 | ); |
---|
548 | @end example |
---|
549 | @end ifset |
---|
550 | |
---|
551 | @ifset is-Ada |
---|
552 | @end ifset |
---|
553 | |
---|
554 | @subheading STATUS CODES: |
---|
555 | |
---|
556 | @subheading DESCRIPTION: |
---|
557 | |
---|
558 | The @code{umask()} function sets the process file creation mask to @code{cmask}. |
---|
559 | The file creation mask is used during @code{open()}, @code{creat()}, @code{mkdir()}, |
---|
560 | @code{mkfifo()} calls to turn off permission bits in the @code{mode} argument. |
---|
561 | Bit positions that are set in @code{cmask} are cleared in the mode of the |
---|
562 | created file. |
---|
563 | |
---|
564 | @subheading NOTES: None |
---|
565 | |
---|
566 | The @code{cmask} argument should have only permission bits set. All other |
---|
567 | bits should be zero. |
---|
568 | |
---|
569 | In a system which supports multiple processes, the file creation mask is inherited |
---|
570 | across @code{fork()} and @code{exec()} calls. This makes it possible to alter the |
---|
571 | default permission bits of created files. RTEMS does not support multiple processes |
---|
572 | so this behavior is not possible. |
---|
573 | |
---|
574 | @page |
---|
575 | @subsection link - Creates a link to a file |
---|
576 | |
---|
577 | @subheading CALLING SEQUENCE: |
---|
578 | |
---|
579 | @ifset is-C |
---|
580 | @example |
---|
581 | #include <unistd.h> |
---|
582 | |
---|
583 | int link( |
---|
584 | const char *existing, |
---|
585 | const char *new |
---|
586 | ); |
---|
587 | @end example |
---|
588 | @end ifset |
---|
589 | |
---|
590 | @ifset is-Ada |
---|
591 | @end ifset |
---|
592 | |
---|
593 | @subheading STATUS CODES: |
---|
594 | |
---|
595 | @table @b |
---|
596 | @item EACCES |
---|
597 | Search permission is denied for a directory in a file's path prefix |
---|
598 | @item EEXIST |
---|
599 | The named file already exists. |
---|
600 | @item EMLINK |
---|
601 | The number of links would exceed @code{LINK_MAX}. |
---|
602 | @item ENAMETOOLONG |
---|
603 | Length of a filename string exceeds PATH_MAX and _POSIX_NO_TRUNC is in |
---|
604 | effect. |
---|
605 | @item ENOENT |
---|
606 | A file or directory does not exist. |
---|
607 | @item ENOSPC |
---|
608 | No space left on disk. |
---|
609 | @item ENOTDIR |
---|
610 | A component of the specified pathname was not a directory when a directory |
---|
611 | was expected. |
---|
612 | @item EPERM |
---|
613 | Operation is not permitted. Process does not have the appropriate priviledges |
---|
614 | or permissions to perform the requested operations. |
---|
615 | @item EROFS |
---|
616 | Read-only file system. |
---|
617 | @item EXDEV |
---|
618 | Attempt to link a file to another file system. |
---|
619 | |
---|
620 | @end table |
---|
621 | |
---|
622 | @subheading DESCRIPTION: |
---|
623 | |
---|
624 | The @code{link} function atomically creates a new link for an existing file |
---|
625 | and increments the link count for the file. |
---|
626 | |
---|
627 | If the @code{link} function fails, no directories are modified. |
---|
628 | |
---|
629 | The @code{existing} argument should not be a directory. |
---|
630 | |
---|
631 | The callder may (or may not) need permission to access the existing file. |
---|
632 | |
---|
633 | @subheading NOTES: None |
---|
634 | |
---|
635 | @page |
---|
636 | @subsection mkdir - Makes a directory |
---|
637 | |
---|
638 | @subheading CALLING SEQUENCE: |
---|
639 | |
---|
640 | @ifset is-C |
---|
641 | @example |
---|
642 | #include <sys/types.h> |
---|
643 | #include <sys/stat.h> |
---|
644 | |
---|
645 | int mkdir( |
---|
646 | const char *path, |
---|
647 | mode_t mode |
---|
648 | ); |
---|
649 | @end example |
---|
650 | @end ifset |
---|
651 | |
---|
652 | @ifset is-Ada |
---|
653 | @end ifset |
---|
654 | |
---|
655 | @subheading STATUS CODES: |
---|
656 | |
---|
657 | @table @b |
---|
658 | @item EACCES |
---|
659 | Search permission is denied for a directory in a file's path prefix |
---|
660 | @item EEXIST |
---|
661 | The name file already exist. |
---|
662 | @item EMLINK |
---|
663 | The number of links would exceed LINK_MAX |
---|
664 | @item ENAMETOOLONG |
---|
665 | Length of a filename string exceeds PATH_MAX and _POSIX_NO_TRUNC is in |
---|
666 | effect. |
---|
667 | @item ENOENT |
---|
668 | A file or directory does not exist. |
---|
669 | @item ENOSPC |
---|
670 | No space left on disk. |
---|
671 | @item ENOTDIR |
---|
672 | A component of the specified pathname was not a directory when a directory |
---|
673 | was expected. |
---|
674 | @item EROFS |
---|
675 | Read-only file system. |
---|
676 | |
---|
677 | @end table |
---|
678 | |
---|
679 | @subheading DESCRIPTION: |
---|
680 | |
---|
681 | The @code{mkdir()} function creates a new diectory named @code{path}. The |
---|
682 | permission bits (modified by the file creation mask) are set from @code{mode}. |
---|
683 | The owner and group IDs for the directory are set from the effective user ID |
---|
684 | and group ID. |
---|
685 | |
---|
686 | The new directory may (or may not) contain entries for.. and .. but is otherwise |
---|
687 | empty. |
---|
688 | |
---|
689 | @subheading NOTES: None |
---|
690 | |
---|
691 | @page |
---|
692 | @subsection mkfifo - |
---|
693 | |
---|
694 | @subheading CALLING SEQUENCE: |
---|
695 | |
---|
696 | @ifset is-C |
---|
697 | @example |
---|
698 | int mkfifo( |
---|
699 | ); |
---|
700 | @end example |
---|
701 | @end ifset |
---|
702 | |
---|
703 | @ifset is-Ada |
---|
704 | @end ifset |
---|
705 | |
---|
706 | @subheading STATUS CODES: |
---|
707 | |
---|
708 | @table @b |
---|
709 | @item E |
---|
710 | The |
---|
711 | |
---|
712 | @end table |
---|
713 | |
---|
714 | @subheading DESCRIPTION: |
---|
715 | |
---|
716 | @subheading NOTES: |
---|
717 | |
---|
718 | @page |
---|
719 | @subsection unlink - Removes a directory entry |
---|
720 | |
---|
721 | @subheading CALLING SEQUENCE: |
---|
722 | |
---|
723 | @ifset is-C |
---|
724 | @example |
---|
725 | #include <unistd.h> |
---|
726 | |
---|
727 | int unlink( |
---|
728 | const char path |
---|
729 | ); |
---|
730 | @end example |
---|
731 | @end ifset |
---|
732 | |
---|
733 | @ifset is-Ada |
---|
734 | @end ifset |
---|
735 | |
---|
736 | @subheading STATUS CODES: |
---|
737 | |
---|
738 | @table @b |
---|
739 | @item EACCES |
---|
740 | Search permission is denied for a directory in a file's path prefix |
---|
741 | @item EBUSY |
---|
742 | The directory is in use. |
---|
743 | @item ENAMETOOLONG |
---|
744 | Length of a filename string exceeds PATH_MAX and _POSIX_NO_TRUNC is in |
---|
745 | effect. |
---|
746 | @item ENOENT |
---|
747 | A file or directory does not exist. |
---|
748 | @item ENOTDIR |
---|
749 | A component of the specified pathname was not a directory when a directory |
---|
750 | was expected. |
---|
751 | @item EPERM |
---|
752 | Operation is not permitted. Process does not have the appropriate priviledges |
---|
753 | or permissions to perform the requested operations. |
---|
754 | @item EROFS |
---|
755 | Read-only file system. |
---|
756 | |
---|
757 | @end table |
---|
758 | |
---|
759 | @subheading DESCRIPTION: |
---|
760 | |
---|
761 | The @code{unlink} function removes the link named by @code{path} and decrements the |
---|
762 | link count of the file referenced by the link. When the link count goes to zero |
---|
763 | and no process has the file open, the space occupied by the file is freed and the |
---|
764 | file is no longer accessible. |
---|
765 | |
---|
766 | @subheading NOTES: None |
---|
767 | |
---|
768 | @page |
---|
769 | @subsection rmdir - |
---|
770 | |
---|
771 | @subheading CALLING SEQUENCE: |
---|
772 | |
---|
773 | @ifset is-C |
---|
774 | @example |
---|
775 | int rmdir( |
---|
776 | ); |
---|
777 | @end example |
---|
778 | @end ifset |
---|
779 | |
---|
780 | @ifset is-Ada |
---|
781 | @end ifset |
---|
782 | |
---|
783 | @subheading STATUS CODES: |
---|
784 | |
---|
785 | @table @b |
---|
786 | @item E |
---|
787 | The |
---|
788 | |
---|
789 | @end table |
---|
790 | |
---|
791 | @subheading DESCRIPTION: |
---|
792 | |
---|
793 | @subheading NOTES: |
---|
794 | |
---|
795 | @page |
---|
796 | @subsection rename - Renames a file |
---|
797 | |
---|
798 | @subheading CALLING SEQUENCE: |
---|
799 | |
---|
800 | @ifset is-C |
---|
801 | @example |
---|
802 | #include <unistd.h> |
---|
803 | |
---|
804 | int rename(const char *old, |
---|
805 | const char *new |
---|
806 | ); |
---|
807 | @end example |
---|
808 | @end ifset |
---|
809 | |
---|
810 | @ifset is-Ada |
---|
811 | @end ifset |
---|
812 | |
---|
813 | @subheading STATUS CODES: |
---|
814 | |
---|
815 | @table @b |
---|
816 | @item EACCES |
---|
817 | Search permission is denied for a directory in a file's path prefix. |
---|
818 | @item EBUSY |
---|
819 | The directory is in use. |
---|
820 | @item EEXIST |
---|
821 | The named file already exists. |
---|
822 | @item EINVAL |
---|
823 | Invalid argument. |
---|
824 | @item EISDIR |
---|
825 | Attempt to open a directory for writing or to rename a file to be a |
---|
826 | directory. |
---|
827 | @item EMLINK |
---|
828 | The number of links would exceed LINK_MAX. |
---|
829 | @item ENAMETOOLONG |
---|
830 | Length of a filename string exceeds PATH_MAX and _POSIX_NO_TRUNC is |
---|
831 | in effect. |
---|
832 | @item ENOENT |
---|
833 | A file or directory does no exist. |
---|
834 | @item ENOSPC |
---|
835 | No space left on disk. |
---|
836 | @item ENOTDIR |
---|
837 | A component of the specified pathname was not a directory when a |
---|
838 | directory was expected. |
---|
839 | @item ENOTEMPTY |
---|
840 | Attempt to delete or rename a non-empty directory. |
---|
841 | @item EROFS |
---|
842 | Read-only file system |
---|
843 | @item EXDEV |
---|
844 | Attempt to link a file to another file system. |
---|
845 | @end table |
---|
846 | |
---|
847 | @subheading DESCRIPTION: |
---|
848 | |
---|
849 | The @code{rename()} function causes the file known bo @code{old} to |
---|
850 | now be known as @code{new}. |
---|
851 | |
---|
852 | Ordinary files may be renamed to ordinary files, and directories may be |
---|
853 | renamed to directories; however, files cannot be converted using |
---|
854 | @code{rename()}. The @code{new} pathname may not contain a path prefix |
---|
855 | of @code{old}. |
---|
856 | |
---|
857 | @subheading NOTES: |
---|
858 | |
---|
859 | If a file already exists by the name @code{new}, it is removed. The |
---|
860 | @code{rename()} function is atomic. If the @code{rename()} detects an |
---|
861 | error, no files are removed. This guarantees that the |
---|
862 | @code{rename("x", "x") does not remove @code{x}. |
---|
863 | |
---|
864 | You may not rename dot or dot-dot. |
---|
865 | |
---|
866 | The routine is implemented in Cygnus newlib using @code{link()} and |
---|
867 | @code{unlink()}. |
---|
868 | |
---|
869 | @page |
---|
870 | @subsection stat - Gets information about a file |
---|
871 | |
---|
872 | @subheading CALLING SEQUENCE: |
---|
873 | |
---|
874 | @ifset is-C |
---|
875 | @example |
---|
876 | #include <sys/types.h> |
---|
877 | #include <sys/stat.h> |
---|
878 | |
---|
879 | int stat(const char *path, |
---|
880 | struct stat *buf |
---|
881 | ); |
---|
882 | @end example |
---|
883 | @end ifset |
---|
884 | |
---|
885 | @ifset is-Ada |
---|
886 | @end ifset |
---|
887 | |
---|
888 | @subheading STATUS CODES: |
---|
889 | |
---|
890 | @table @b |
---|
891 | @item EACCES |
---|
892 | Search permission is denied for a directory in a file's path prefix. |
---|
893 | @item EBADF |
---|
894 | Invalid file descriptor. |
---|
895 | @item ENAMETOOLONG |
---|
896 | Length of a filename string exceeds PATH_MAX and _POSIX_NO_TRUNC is |
---|
897 | in effect. |
---|
898 | @item ENOENT |
---|
899 | A file or directory does not exist. |
---|
900 | @item ENOTDIR |
---|
901 | A component of the specified pathname was not a directory when a |
---|
902 | directory was expected. |
---|
903 | |
---|
904 | @end table |
---|
905 | |
---|
906 | @subheading DESCRIPTION: |
---|
907 | |
---|
908 | The @code{path} argument points to a pathname for a file. Read, write, or |
---|
909 | execute permission for the file is not required, but all directories listed |
---|
910 | in @code{path} must be searchable. The @code{stat()} function obtains |
---|
911 | information about the named file and writes it to the area pointed to by |
---|
912 | @code{but}. |
---|
913 | |
---|
914 | @subheading NOTES: None |
---|
915 | |
---|
916 | @page |
---|
917 | @subsection fstat - |
---|
918 | |
---|
919 | @subheading CALLING SEQUENCE: |
---|
920 | |
---|
921 | @ifset is-C |
---|
922 | @example |
---|
923 | int fstat( |
---|
924 | ); |
---|
925 | @end example |
---|
926 | @end ifset |
---|
927 | |
---|
928 | @ifset is-Ada |
---|
929 | @end ifset |
---|
930 | |
---|
931 | @subheading STATUS CODES: |
---|
932 | |
---|
933 | @table @b |
---|
934 | @item E |
---|
935 | The |
---|
936 | |
---|
937 | @end table |
---|
938 | |
---|
939 | @subheading DESCRIPTION: |
---|
940 | |
---|
941 | @subheading NOTES: |
---|
942 | |
---|
943 | @page |
---|
944 | @subsection access - |
---|
945 | |
---|
946 | @subheading CALLING SEQUENCE: |
---|
947 | |
---|
948 | @ifset is-C |
---|
949 | @example |
---|
950 | int access( |
---|
951 | ); |
---|
952 | @end example |
---|
953 | @end ifset |
---|
954 | |
---|
955 | @ifset is-Ada |
---|
956 | @end ifset |
---|
957 | |
---|
958 | @subheading STATUS CODES: |
---|
959 | |
---|
960 | @table @b |
---|
961 | @item E |
---|
962 | The |
---|
963 | |
---|
964 | @end table |
---|
965 | |
---|
966 | @subheading DESCRIPTION: |
---|
967 | |
---|
968 | @subheading NOTES: |
---|
969 | |
---|
970 | @page |
---|
971 | @subsection chmod - Changes file mode. |
---|
972 | |
---|
973 | @subheading CALLING SEQUENCE: |
---|
974 | |
---|
975 | @ifset is-C |
---|
976 | @example |
---|
977 | #include <sys/types.h> |
---|
978 | #include <sys/stat.h> |
---|
979 | |
---|
980 | int chmod( |
---|
981 | const char *path, |
---|
982 | mode_t mode |
---|
983 | ); |
---|
984 | @end example |
---|
985 | @end ifset |
---|
986 | |
---|
987 | @ifset is-Ada |
---|
988 | @end ifset |
---|
989 | |
---|
990 | @subheading STATUS CODES: |
---|
991 | |
---|
992 | @table @b |
---|
993 | @item EACCES |
---|
994 | Search permission is denied for a directory in a file's path prefix |
---|
995 | @item ENAMETOOLONG |
---|
996 | Length of a filename string exceeds PATH_MAX and _POSIX_NO_TRUNC is in |
---|
997 | effect. |
---|
998 | @item ENOENT |
---|
999 | A file or directory does not exist. |
---|
1000 | @item ENOTDIR |
---|
1001 | A component of the specified pathname was not a directory when a directory |
---|
1002 | was expected. |
---|
1003 | @item EPERM |
---|
1004 | Operation is not permitted. Process does not have the appropriate priviledges |
---|
1005 | or permissions to perform the requested operations. |
---|
1006 | @item EROFS |
---|
1007 | Read-only file system. |
---|
1008 | |
---|
1009 | @end table |
---|
1010 | |
---|
1011 | @subheading DESCRIPTION: |
---|
1012 | |
---|
1013 | Set the file permission bits, the set user ID bit, and the set group ID bit |
---|
1014 | for the file named by @code{path} to @code{mode}. If the effective user ID |
---|
1015 | does not match the owner of the file and the calling process does not have |
---|
1016 | the appropriate privileges, @code{chmod()} returns -1 and sets @code{errno} to |
---|
1017 | @code{EPERM}. |
---|
1018 | |
---|
1019 | @subheading NOTES: |
---|
1020 | |
---|
1021 | @page |
---|
1022 | @subsection fchmod - |
---|
1023 | |
---|
1024 | @subheading CALLING SEQUENCE: |
---|
1025 | |
---|
1026 | @ifset is-C |
---|
1027 | @example |
---|
1028 | int fchmod( |
---|
1029 | ); |
---|
1030 | @end example |
---|
1031 | @end ifset |
---|
1032 | |
---|
1033 | @ifset is-Ada |
---|
1034 | @end ifset |
---|
1035 | |
---|
1036 | @subheading STATUS CODES: |
---|
1037 | |
---|
1038 | @table @b |
---|
1039 | @item E |
---|
1040 | The |
---|
1041 | |
---|
1042 | @end table |
---|
1043 | |
---|
1044 | @subheading DESCRIPTION: |
---|
1045 | |
---|
1046 | @subheading NOTES: |
---|
1047 | |
---|
1048 | @page |
---|
1049 | @subsection chown - Changes the owner and/or group of a file. |
---|
1050 | |
---|
1051 | @subheading CALLING SEQUENCE: |
---|
1052 | |
---|
1053 | @ifset is-C |
---|
1054 | @example |
---|
1055 | #include <sys/types.h> |
---|
1056 | #include <unistd.h> |
---|
1057 | |
---|
1058 | int chown( |
---|
1059 | const char *path, |
---|
1060 | uid_t owner, |
---|
1061 | gid_t group |
---|
1062 | ); |
---|
1063 | @end example |
---|
1064 | @end ifset |
---|
1065 | |
---|
1066 | @ifset is-Ada |
---|
1067 | @end ifset |
---|
1068 | |
---|
1069 | @subheading STATUS CODES: |
---|
1070 | |
---|
1071 | @table @b |
---|
1072 | @item EACCES |
---|
1073 | Search permission is denied for a directory in a file's path prefix |
---|
1074 | @item EINVAL |
---|
1075 | Invalid argument |
---|
1076 | @item ENAMETOOLONG |
---|
1077 | Length of a filename string exceeds PATH_MAX and _POSIX_NO_TRUNC is in |
---|
1078 | effect. |
---|
1079 | @item ENOENT |
---|
1080 | A file or directory does not exist. |
---|
1081 | @item ENOTDIR |
---|
1082 | A component of the specified pathname was not a directory when a directory |
---|
1083 | was expected. |
---|
1084 | @item EPERM |
---|
1085 | Operation is not permitted. Process does not have the appropriate priviledges |
---|
1086 | or permissions to perform the requested operations. |
---|
1087 | @item EROFS |
---|
1088 | Read-only file system. |
---|
1089 | |
---|
1090 | @end table |
---|
1091 | |
---|
1092 | @subheading DESCRIPTION: |
---|
1093 | |
---|
1094 | The user ID and group ID of the file named by @code{path} are set to |
---|
1095 | @code{owner} and @code{path}, respectively. |
---|
1096 | |
---|
1097 | For regular files, the set group ID (S_ISGID) and set user ID (S_ISUID) |
---|
1098 | bits are cleared. |
---|
1099 | |
---|
1100 | Some systems consider it a security violation to allow the owner of a file to |
---|
1101 | be changed, If users are billed for disk space usage, loaning a file to |
---|
1102 | another user could result in incorrect billing. The @code{chown()} function |
---|
1103 | may be restricted to privileged users for some or all files. The group ID can |
---|
1104 | still be changed to one of the supplementary group IDs. |
---|
1105 | |
---|
1106 | @subheading NOTES: |
---|
1107 | |
---|
1108 | This function may be restricted for some file. The @code{pathconf} function |
---|
1109 | can be used to test the _PC_CHOWN_RESTRICTED flag. |
---|
1110 | |
---|
1111 | |
---|
1112 | |
---|
1113 | @page |
---|
1114 | @subsection utime - |
---|
1115 | |
---|
1116 | @subheading CALLING SEQUENCE: |
---|
1117 | |
---|
1118 | @ifset is-C |
---|
1119 | @example |
---|
1120 | int utime( |
---|
1121 | ); |
---|
1122 | @end example |
---|
1123 | @end ifset |
---|
1124 | |
---|
1125 | @ifset is-Ada |
---|
1126 | @end ifset |
---|
1127 | |
---|
1128 | @subheading STATUS CODES: |
---|
1129 | |
---|
1130 | @table @b |
---|
1131 | @item E |
---|
1132 | The |
---|
1133 | |
---|
1134 | @end table |
---|
1135 | |
---|
1136 | @subheading DESCRIPTION: |
---|
1137 | |
---|
1138 | @subheading NOTES: |
---|
1139 | |
---|
1140 | @page |
---|
1141 | @subsection ftrunctate - |
---|
1142 | |
---|
1143 | @subheading CALLING SEQUENCE: |
---|
1144 | |
---|
1145 | @ifset is-C |
---|
1146 | @example |
---|
1147 | int ftrunctate( |
---|
1148 | ); |
---|
1149 | @end example |
---|
1150 | @end ifset |
---|
1151 | |
---|
1152 | @ifset is-Ada |
---|
1153 | @end ifset |
---|
1154 | |
---|
1155 | @subheading STATUS CODES: |
---|
1156 | |
---|
1157 | @table @b |
---|
1158 | @item E |
---|
1159 | The |
---|
1160 | |
---|
1161 | @end table |
---|
1162 | |
---|
1163 | @subheading DESCRIPTION: |
---|
1164 | |
---|
1165 | @subheading NOTES: |
---|
1166 | |
---|
1167 | @page |
---|
1168 | @subsection pathconf - |
---|
1169 | |
---|
1170 | @subheading CALLING SEQUENCE: |
---|
1171 | |
---|
1172 | @ifset is-C |
---|
1173 | @example |
---|
1174 | int pathconf( |
---|
1175 | ); |
---|
1176 | @end example |
---|
1177 | @end ifset |
---|
1178 | |
---|
1179 | @ifset is-Ada |
---|
1180 | @end ifset |
---|
1181 | |
---|
1182 | @subheading STATUS CODES: |
---|
1183 | |
---|
1184 | @table @b |
---|
1185 | @item E |
---|
1186 | The |
---|
1187 | |
---|
1188 | @end table |
---|
1189 | |
---|
1190 | @subheading DESCRIPTION: |
---|
1191 | |
---|
1192 | @subheading NOTES: |
---|
1193 | |
---|
1194 | @page |
---|
1195 | @subsection fpathconf - |
---|
1196 | |
---|
1197 | @subheading CALLING SEQUENCE: |
---|
1198 | |
---|
1199 | @ifset is-C |
---|
1200 | @example |
---|
1201 | int fpathconf( |
---|
1202 | ); |
---|
1203 | @end example |
---|
1204 | @end ifset |
---|
1205 | |
---|
1206 | @ifset is-Ada |
---|
1207 | @end ifset |
---|
1208 | |
---|
1209 | @subheading STATUS CODES: |
---|
1210 | |
---|
1211 | @table @b |
---|
1212 | @item E |
---|
1213 | The |
---|
1214 | |
---|
1215 | @end table |
---|
1216 | |
---|
1217 | @subheading DESCRIPTION: |
---|
1218 | |
---|
1219 | @subheading NOTES: |
---|
1220 | |
---|