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{rewinddir} - Resets the @code{readdir()} pointer |
---|
21 | @item @code{scandir} - Scan a directory for matching entries |
---|
22 | @item @code{telldir} - Return current location in directory stream |
---|
23 | @item @code{closedir} - Ends directory read operation |
---|
24 | @item @code{getdents} - Get directory entries |
---|
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} - Create a new file or rewrite an existing one |
---|
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} - Makes a FIFO special file |
---|
33 | @item @code{unlink} - Removes a directory entry |
---|
34 | @item @code{rmdir} - Delete a directory |
---|
35 | @item @code{rename} - Renames a file |
---|
36 | @item @code{stat} - Gets information about a file. |
---|
37 | @item @code{fstat} - Gets file status |
---|
38 | @item @code{access} - Check user's permissions for a file. |
---|
39 | @item @code{chmod} - Changes file mode |
---|
40 | @item @code{fchmod} - Changes permissions of a file |
---|
41 | @item @code{chown} - Changes the owner and/ or group of a file |
---|
42 | @item @code{utime} - Change access and/or modification times of an inode |
---|
43 | @item @code{ftruncate} - Truncate a file to a specified length |
---|
44 | @itme @code{truncate} - Truncate a file to a specified length |
---|
45 | @item @code{pathconf} - Gets configuration values for files |
---|
46 | @item @code{fpathconf} - Get configuration values for files |
---|
47 | @itme @code{mknod} - Create a directory |
---|
48 | @end itemize |
---|
49 | |
---|
50 | @section Background |
---|
51 | |
---|
52 | There is currently no text in this section. |
---|
53 | |
---|
54 | @section Operations |
---|
55 | |
---|
56 | There is currently no text in this section. |
---|
57 | |
---|
58 | @section Directives |
---|
59 | |
---|
60 | This section details the files and directories manager's directives. |
---|
61 | A subsection is dedicated to each of this manager's directives |
---|
62 | and describes the calling sequence, related constants, usage, |
---|
63 | and status codes. |
---|
64 | |
---|
65 | @page |
---|
66 | @subsection opendir - Open a Directory |
---|
67 | |
---|
68 | @subheading CALLING SEQUENCE: |
---|
69 | |
---|
70 | @ifset is-C |
---|
71 | @example |
---|
72 | #include <sys/types.h> |
---|
73 | #include <dirent.h> |
---|
74 | |
---|
75 | int opendir( |
---|
76 | const char *dirname |
---|
77 | ); |
---|
78 | @end example |
---|
79 | @end ifset |
---|
80 | |
---|
81 | @ifset is-Ada |
---|
82 | @end ifset |
---|
83 | |
---|
84 | @subheading STATUS CODES: |
---|
85 | |
---|
86 | @table @b |
---|
87 | @item EACCES |
---|
88 | Search permission was denied on a component of the path |
---|
89 | prefix of @code{dirname}, or read permission is denied |
---|
90 | |
---|
91 | @item EMFILE |
---|
92 | Too many file descriptors in use by process |
---|
93 | |
---|
94 | @item ENFILE |
---|
95 | Too many files are currently open in the system. |
---|
96 | |
---|
97 | @item ENOENT |
---|
98 | Directory does not exist, or @code{name} is an empty string. |
---|
99 | |
---|
100 | @item ENOMEM |
---|
101 | Insufficient memory to complete the operation. |
---|
102 | |
---|
103 | @item ENOTDIR |
---|
104 | @code{name} is not a directory. |
---|
105 | |
---|
106 | @end table |
---|
107 | |
---|
108 | @subheading DESCRIPTION: |
---|
109 | |
---|
110 | This routine opens a directory stream corresponding to the |
---|
111 | directory specified by the @code{dirname} argument. The |
---|
112 | directory stream is positioned at the first entry. |
---|
113 | |
---|
114 | @subheading NOTES: |
---|
115 | |
---|
116 | The routine is implemented in Cygnus newlib. |
---|
117 | |
---|
118 | @page |
---|
119 | @subsection readdir - Reads a directory |
---|
120 | |
---|
121 | @subheading CALLING SEQUENCE: |
---|
122 | |
---|
123 | @ifset is-C |
---|
124 | @example |
---|
125 | #include <sys/types.h> |
---|
126 | #include <dirent.h> |
---|
127 | |
---|
128 | int readdir( |
---|
129 | DIR *dirp |
---|
130 | ); |
---|
131 | @end example |
---|
132 | @end ifset |
---|
133 | |
---|
134 | @ifset is-Ada |
---|
135 | @end ifset |
---|
136 | |
---|
137 | @subheading STATUS CODES: |
---|
138 | |
---|
139 | @table @b |
---|
140 | @item EBADF |
---|
141 | Invalid file descriptor |
---|
142 | |
---|
143 | @end table |
---|
144 | |
---|
145 | @subheading DESCRIPTION: |
---|
146 | |
---|
147 | The @code{readdir()} function returns a pointer to a structure @code{dirent} |
---|
148 | representing the next directory entry from the directory stream pointed to |
---|
149 | by @code{dirp}. On end-of-file, NULL is returned. |
---|
150 | |
---|
151 | The @code{readdir()} function may (or may not) return entries for . or .. Your |
---|
152 | program should tolerate reading dot and dot-dot but not require them. |
---|
153 | |
---|
154 | The data pointed to be @code{readdir()} may be overwritten by another call to |
---|
155 | @code{readdir()} for the same directory stream. It will not be overwritten by |
---|
156 | a call for another directory. |
---|
157 | |
---|
158 | @subheading NOTES: |
---|
159 | |
---|
160 | If @code{ptr} is not a pointer returned by @code{malloc()}, @code{calloc()}, or |
---|
161 | @code{realloc()} or has been deallocated with @code{free()} or |
---|
162 | @code{realloc()}, the results are not portable and are probably disastrous. |
---|
163 | |
---|
164 | The routine is implemented in Cygnus newlib. |
---|
165 | |
---|
166 | @page |
---|
167 | @subsection rewinddir - Resets the readdir() pointer |
---|
168 | |
---|
169 | @subheading CALLING SEQUENCE: |
---|
170 | |
---|
171 | @ifset is-C |
---|
172 | @example |
---|
173 | #include <sys/types.h> |
---|
174 | #include <dirent.h> |
---|
175 | |
---|
176 | void rewinddir( |
---|
177 | DIR *dirp |
---|
178 | ); |
---|
179 | @end example |
---|
180 | @end ifset |
---|
181 | |
---|
182 | @ifset is-Ada |
---|
183 | @end ifset |
---|
184 | |
---|
185 | @subheading STATUS CODES: |
---|
186 | |
---|
187 | No value is returned. |
---|
188 | |
---|
189 | @subheading DESCRIPTION: |
---|
190 | |
---|
191 | The @code{rewinddir()} function resets the position associated with |
---|
192 | the directory stream pointed to by @code{dirp}. It also causes the |
---|
193 | directory stream to refer to the current state of the directory. |
---|
194 | |
---|
195 | @subheading NOTES: |
---|
196 | |
---|
197 | NONE |
---|
198 | |
---|
199 | If @code{dirp} is not a pointer by @code{opendir()}, the results are |
---|
200 | undefined. |
---|
201 | |
---|
202 | The routine is implemented in Cygnus newlib. |
---|
203 | |
---|
204 | @page |
---|
205 | @subsection scandir - Scan a directory for matching entries |
---|
206 | |
---|
207 | @subheading CALLING SEQUENCE: |
---|
208 | |
---|
209 | @ifset is-C |
---|
210 | @example |
---|
211 | #include <dirent.h> |
---|
212 | |
---|
213 | int scandir( |
---|
214 | const char *dir, |
---|
215 | struct direct ***namelist, |
---|
216 | int (*select)(const struct dirent *), |
---|
217 | int (*compar)(const struct dirent **, const struct dirent **) |
---|
218 | ); |
---|
219 | @end example |
---|
220 | @end ifset |
---|
221 | |
---|
222 | @ifset is-Ada |
---|
223 | @end ifset |
---|
224 | |
---|
225 | @subheading STATUS CODES: |
---|
226 | |
---|
227 | @table @b |
---|
228 | @item ENOMEM |
---|
229 | Insufficient memory to complete the operation. |
---|
230 | |
---|
231 | @end table |
---|
232 | |
---|
233 | @subheading DESCRIPTION: |
---|
234 | |
---|
235 | The @code{scandir()} function scans the directory @code{dir}, calling |
---|
236 | @code{select()} on each directory entry. Entries for which @code{select()} |
---|
237 | returns non-zero are stored in strings allocated via @code{malloc()}, |
---|
238 | sorted using @code{qsort()} with the comparison function @code{compar()}, |
---|
239 | and collected in array @code{namelist} which is allocated via @code{malloc()}. |
---|
240 | If @code{select} is NULL, all entries are selected. |
---|
241 | |
---|
242 | @subheading NOTES: |
---|
243 | |
---|
244 | The routine is implemented in Cygnus newlib. |
---|
245 | |
---|
246 | @page |
---|
247 | @subsection telldir - Return current location in directory stream |
---|
248 | |
---|
249 | @subheading CALLING SEQUENCE: |
---|
250 | |
---|
251 | @ifset is-C |
---|
252 | @example |
---|
253 | #include <dirent.h> |
---|
254 | |
---|
255 | off_t telldir( |
---|
256 | DIR *dir |
---|
257 | ); |
---|
258 | @end example |
---|
259 | @end ifset |
---|
260 | |
---|
261 | @ifset is-Ada |
---|
262 | @end ifset |
---|
263 | |
---|
264 | @subheading STATUS CODES: |
---|
265 | |
---|
266 | @table @b |
---|
267 | @item EBADF |
---|
268 | Invalid directory stream descriptor @code{dir}. |
---|
269 | |
---|
270 | @end table |
---|
271 | |
---|
272 | @subheading DESCRIPTION: |
---|
273 | |
---|
274 | The @code{telldir()} function returns the current location associated with the |
---|
275 | directory stream @code{dir}. |
---|
276 | |
---|
277 | @subheading NOTES: |
---|
278 | |
---|
279 | The routine is implemented in Cygnus newlib. |
---|
280 | |
---|
281 | @page |
---|
282 | @subsection closedir - Ends directory read operation |
---|
283 | |
---|
284 | @subheading CALLING SEQUENCE: |
---|
285 | |
---|
286 | @ifset is-C |
---|
287 | @example |
---|
288 | #include <sys/types.h> |
---|
289 | #include <dirent.h> |
---|
290 | |
---|
291 | int closedir( |
---|
292 | DIR *dirp |
---|
293 | ); |
---|
294 | @end example |
---|
295 | @end ifset |
---|
296 | |
---|
297 | @ifset is-Ada |
---|
298 | @end ifset |
---|
299 | |
---|
300 | @subheading STATUS CODES: |
---|
301 | |
---|
302 | @table @b |
---|
303 | @item EBADF |
---|
304 | Invalid file descriptor |
---|
305 | |
---|
306 | @end table |
---|
307 | |
---|
308 | @subheading DESCRIPTION: |
---|
309 | |
---|
310 | The directory stream associated with @code{dirp} is closed. |
---|
311 | The value in @code{dirp} may not be usable after a call to |
---|
312 | @code{closedir()}. |
---|
313 | |
---|
314 | @subheading NOTES: |
---|
315 | |
---|
316 | NONE |
---|
317 | |
---|
318 | The argument to @code{closedir()} must be a pointer returned by |
---|
319 | @code{opendir()}. If it is not, the results are not portable and |
---|
320 | most likely unpleasant. |
---|
321 | |
---|
322 | The routine is implemented in Cygnus newlib. |
---|
323 | |
---|
324 | @page |
---|
325 | @subsection chdir - Changes the current working directory |
---|
326 | |
---|
327 | @subheading CALLING SEQUENCE: |
---|
328 | |
---|
329 | @ifset is-C |
---|
330 | @example |
---|
331 | #include <unistd.h> |
---|
332 | |
---|
333 | int chdir( |
---|
334 | const char *path |
---|
335 | ); |
---|
336 | @end example |
---|
337 | @end ifset |
---|
338 | |
---|
339 | @ifset is-Ada |
---|
340 | @end ifset |
---|
341 | |
---|
342 | @subheading STATUS CODES: |
---|
343 | |
---|
344 | @table @b |
---|
345 | @item EACCES |
---|
346 | Search permission is denied for a directory in a file's path prefix. |
---|
347 | |
---|
348 | @item ENAMETOOLONG |
---|
349 | Length of a filename string exceeds PATH_MAX and _POSIX_NO_TRUNC is |
---|
350 | in effect. |
---|
351 | |
---|
352 | @item ENOENT |
---|
353 | A file or directory does not exist. |
---|
354 | |
---|
355 | @item ENOTDIR |
---|
356 | A component of the specified pathname was not a directory when directory |
---|
357 | was expected. |
---|
358 | |
---|
359 | @end table |
---|
360 | |
---|
361 | @subheading DESCRIPTION: |
---|
362 | |
---|
363 | The @code{chdir()} function causes the directory named by @code{path} to |
---|
364 | become the current working directory; that is, the starting point for |
---|
365 | searches of pathnames not beginning with a slash. |
---|
366 | |
---|
367 | If @code{chdir()} detects an error, the current working directory is not |
---|
368 | changed. |
---|
369 | |
---|
370 | @subheading NOTES: |
---|
371 | |
---|
372 | NONE |
---|
373 | |
---|
374 | @page |
---|
375 | @subsection getcwd - Gets current working directory |
---|
376 | |
---|
377 | @subheading CALLING SEQUENCE: |
---|
378 | |
---|
379 | @ifset is-C |
---|
380 | @example |
---|
381 | #include <unistd.h> |
---|
382 | |
---|
383 | int getcwd( void ); |
---|
384 | @end example |
---|
385 | @end ifset |
---|
386 | |
---|
387 | @ifset is-Ada |
---|
388 | @end ifset |
---|
389 | |
---|
390 | @subheading STATUS CODES: |
---|
391 | |
---|
392 | @table @b |
---|
393 | @item EINVAL |
---|
394 | Invalid argument |
---|
395 | |
---|
396 | @item ERANGE |
---|
397 | Result is too large |
---|
398 | |
---|
399 | @item EACCES |
---|
400 | Search permission is denied for a directory in a file's path prefix. |
---|
401 | |
---|
402 | @end table |
---|
403 | |
---|
404 | @subheading DESCRIPTION: |
---|
405 | |
---|
406 | The @code{getcwd()} function copies the absolute pathname of the current |
---|
407 | working directory to the character array pointed to by @code{buf}. The |
---|
408 | @code{size} argument is the number of bytes available in @code{buf} |
---|
409 | |
---|
410 | @subheading NOTES: |
---|
411 | |
---|
412 | There is no way to determine the maximum string length that @code{fetcwd()} |
---|
413 | may need to return. Applications should tolerate getting @code{ERANGE} |
---|
414 | and allocate a larger buffer. |
---|
415 | |
---|
416 | It is possible for @code{getcwd()} to return EACCES if, say, @code{login} |
---|
417 | puts the process into a directory without read access. |
---|
418 | |
---|
419 | The 1988 standard uses @code{int} instead of @code{size_t} for the second |
---|
420 | parameter. |
---|
421 | |
---|
422 | @page |
---|
423 | @subsection open - Opens a file |
---|
424 | |
---|
425 | @subheading CALLING SEQUENCE: |
---|
426 | |
---|
427 | @ifset is-C |
---|
428 | @example |
---|
429 | #include <sys/types.h> |
---|
430 | #include <sys/stat.h> |
---|
431 | #include <fcntl.h> |
---|
432 | |
---|
433 | int open( |
---|
434 | const char *path, |
---|
435 | int oflag, |
---|
436 | mode_t mode |
---|
437 | ); |
---|
438 | @end example |
---|
439 | @end ifset |
---|
440 | |
---|
441 | @ifset is-Ada |
---|
442 | @end ifset |
---|
443 | |
---|
444 | @subheading STATUS CODES: |
---|
445 | |
---|
446 | @table @b |
---|
447 | |
---|
448 | @item EACCES |
---|
449 | Search permission is denied for a directory in a file's path prefix. |
---|
450 | |
---|
451 | @item EEXIST |
---|
452 | The named file already exists. |
---|
453 | |
---|
454 | @item EINTR |
---|
455 | Function was interrupted by a signal. |
---|
456 | |
---|
457 | @item EISDIR |
---|
458 | Attempt to open a directory for writing or to rename a file to be a |
---|
459 | directory. |
---|
460 | |
---|
461 | @item EMFILE |
---|
462 | Too many file descriptors are in use by this process. |
---|
463 | |
---|
464 | @item ENAMETOOLONG |
---|
465 | Length of a filename string exceeds PATH_MAX and _POSIX_NO_TRUNC is in |
---|
466 | effect. |
---|
467 | |
---|
468 | @item ENFILE |
---|
469 | Too many files are currently open in the system. |
---|
470 | |
---|
471 | @item ENOENT |
---|
472 | A file or directory does not exist. |
---|
473 | |
---|
474 | @item ENOSPC |
---|
475 | No space left on disk. |
---|
476 | |
---|
477 | @item ENOTDIR |
---|
478 | A component of the specified pathname was not a directory when a directory |
---|
479 | was expected. |
---|
480 | |
---|
481 | @item ENXIO |
---|
482 | No such device. This error may also occur when a device is not ready, for |
---|
483 | example, a tape drive is off-line. |
---|
484 | |
---|
485 | @item EROFS |
---|
486 | Read-only file system. |
---|
487 | @end table |
---|
488 | |
---|
489 | @subheading DESCRIPTION: |
---|
490 | |
---|
491 | The @code{open} function establishes a connection between a file and a file |
---|
492 | descriptor. The file descriptor is a small integer that is used by I/O |
---|
493 | functions to reference the file. The @code{path} argument points to the |
---|
494 | pathname for the file. |
---|
495 | |
---|
496 | The @code{oflag} argument is the bitwise inclusive OR of the values of |
---|
497 | symbolic constants. The programmer must specify exactly one of the following |
---|
498 | three symbols: |
---|
499 | |
---|
500 | @table @b |
---|
501 | @item O_RDONLY |
---|
502 | Open for reading only. |
---|
503 | |
---|
504 | @item O_WRONLY |
---|
505 | Open for writing only. |
---|
506 | |
---|
507 | @item O_RDWR |
---|
508 | Open for reading and writing. |
---|
509 | |
---|
510 | @end table |
---|
511 | |
---|
512 | Any combination of the following symbols may also be used. |
---|
513 | |
---|
514 | @table @b |
---|
515 | @item O_APPEND |
---|
516 | Set the file offset to the end-of-file prior to each write. |
---|
517 | |
---|
518 | @item O_CREAT |
---|
519 | If the file does not exist, allow it to be created. This flag indicates |
---|
520 | that the @code{mode} argument is present in the call to @code{open}. |
---|
521 | |
---|
522 | @item O_EXCL |
---|
523 | This flag may be used only if O_CREAT is also set. It causes the call |
---|
524 | to @code{open} to fail if the file already exists. |
---|
525 | |
---|
526 | @item O_NOCTTY |
---|
527 | If @code{path} identifies a terminal, this flag prevents that teminal from |
---|
528 | becoming the controlling terminal for thi9s process. See Chapter 8 for a |
---|
529 | description of terminal I/O. |
---|
530 | |
---|
531 | @item O_NONBLOCK |
---|
532 | Do no wait for the device or file to be ready or available. After the file |
---|
533 | is open, the @code{read} and @code{write} calls return immediately. If the |
---|
534 | process would be delayed in the read or write opermation, -1 is returned and |
---|
535 | @code{errno} is set to @code{EAGAIN} instead of blocking the caller. |
---|
536 | |
---|
537 | @item O_TRUNC |
---|
538 | This flag should be used only on ordinary files opened for writing. It |
---|
539 | causes the file to be tuncated to zero length.. |
---|
540 | |
---|
541 | @end table |
---|
542 | |
---|
543 | Upon successful completion, @code{open} returns a non-negative file |
---|
544 | descriptor. |
---|
545 | |
---|
546 | @subheading NOTES: |
---|
547 | |
---|
548 | NONE |
---|
549 | |
---|
550 | @page |
---|
551 | @subsection creat - Create a new file or rewrite an existing one |
---|
552 | |
---|
553 | @subheading CALLING SEQUENCE: |
---|
554 | |
---|
555 | @ifset is-C |
---|
556 | @example |
---|
557 | #include <sys/types.h> |
---|
558 | #include <sys/stat.h> |
---|
559 | #include <fcntl.h> |
---|
560 | |
---|
561 | int creat( |
---|
562 | const char *path, |
---|
563 | mode_t mode |
---|
564 | ); |
---|
565 | @end example |
---|
566 | @end ifset |
---|
567 | |
---|
568 | @ifset is-Ada |
---|
569 | @end ifset |
---|
570 | |
---|
571 | @subheading STATUS CODES: |
---|
572 | |
---|
573 | @table @b |
---|
574 | @item EEXIST |
---|
575 | @code{path} already exists and O_CREAT and O_EXCL were used. |
---|
576 | |
---|
577 | @item EISDIR |
---|
578 | @code{path} refers to a directory and the access requested involved |
---|
579 | writing |
---|
580 | |
---|
581 | @item ETXTBSY |
---|
582 | @code{path} refers to an executable image which is currently being |
---|
583 | executed and write access was requested |
---|
584 | |
---|
585 | @item EFAULT |
---|
586 | @code{path} points outside your accessible address space |
---|
587 | |
---|
588 | @item EACCES |
---|
589 | The requested access to the file is not allowed, or one of the |
---|
590 | directories in @code{path} did not allow search (execute) permission. |
---|
591 | |
---|
592 | @item ENAMETOOLONG |
---|
593 | @code{path} was too long. |
---|
594 | |
---|
595 | @item ENOENT |
---|
596 | A directory component in @code{path} does not exist or is a dangling |
---|
597 | symbolic link. |
---|
598 | |
---|
599 | @item ENOTDIR |
---|
600 | A component used as a directory in @code{path} is not, in fact, a |
---|
601 | directory. |
---|
602 | |
---|
603 | @item EMFILE |
---|
604 | The process alreadyh has the maximum number of files open. |
---|
605 | |
---|
606 | @item ENFILE |
---|
607 | The limit on the total number of files open on the system has been |
---|
608 | reached. |
---|
609 | |
---|
610 | @item ENOMEM |
---|
611 | Insufficient kernel memory was available. |
---|
612 | |
---|
613 | @item EROFS |
---|
614 | @code{path} refers to a file on a read-only filesystem and write access |
---|
615 | was requested |
---|
616 | |
---|
617 | @end table |
---|
618 | |
---|
619 | @subheading DESCRIPTION: |
---|
620 | |
---|
621 | @code{creat} attempts to create a file and return a file descriptor for |
---|
622 | use in read, write, etc. |
---|
623 | |
---|
624 | @subheading NOTES: |
---|
625 | |
---|
626 | NONE |
---|
627 | |
---|
628 | The routine is implemented in Cygnus newlib. |
---|
629 | |
---|
630 | @page |
---|
631 | @subsection umask - Sets a file creation mask. |
---|
632 | |
---|
633 | @subheading CALLING SEQUENCE: |
---|
634 | |
---|
635 | @ifset is-C |
---|
636 | @example |
---|
637 | #include <sys/types.h> |
---|
638 | #include <sys/stat.h> |
---|
639 | |
---|
640 | mode_t umask( |
---|
641 | mode_t cmask |
---|
642 | ); |
---|
643 | @end example |
---|
644 | @end ifset |
---|
645 | |
---|
646 | @ifset is-Ada |
---|
647 | @end ifset |
---|
648 | |
---|
649 | @subheading STATUS CODES: |
---|
650 | |
---|
651 | @subheading DESCRIPTION: |
---|
652 | |
---|
653 | The @code{umask()} function sets the process file creation mask to @code{cmask}. |
---|
654 | The file creation mask is used during @code{open()}, @code{creat()}, @code{mkdir()}, |
---|
655 | @code{mkfifo()} calls to turn off permission bits in the @code{mode} argument. |
---|
656 | Bit positions that are set in @code{cmask} are cleared in the mode of the |
---|
657 | created file. |
---|
658 | |
---|
659 | @subheading NOTES: |
---|
660 | |
---|
661 | NONE |
---|
662 | |
---|
663 | The @code{cmask} argument should have only permission bits set. All other |
---|
664 | bits should be zero. |
---|
665 | |
---|
666 | In a system which supports multiple processes, the file creation mask is inherited |
---|
667 | across @code{fork()} and @code{exec()} calls. This makes it possible to alter the |
---|
668 | default permission bits of created files. RTEMS does not support multiple processes |
---|
669 | so this behavior is not possible. |
---|
670 | |
---|
671 | @page |
---|
672 | @subsection link - Creates a link to a file |
---|
673 | |
---|
674 | @subheading CALLING SEQUENCE: |
---|
675 | |
---|
676 | @ifset is-C |
---|
677 | @example |
---|
678 | #include <unistd.h> |
---|
679 | |
---|
680 | int link( |
---|
681 | const char *existing, |
---|
682 | const char *new |
---|
683 | ); |
---|
684 | @end example |
---|
685 | @end ifset |
---|
686 | |
---|
687 | @ifset is-Ada |
---|
688 | @end ifset |
---|
689 | |
---|
690 | @subheading STATUS CODES: |
---|
691 | |
---|
692 | @table @b |
---|
693 | |
---|
694 | @item EACCES |
---|
695 | Search permission is denied for a directory in a file's path prefix |
---|
696 | |
---|
697 | @item EEXIST |
---|
698 | The named file already exists. |
---|
699 | |
---|
700 | @item EMLINK |
---|
701 | The number of links would exceed @code{LINK_MAX}. |
---|
702 | |
---|
703 | @item ENAMETOOLONG |
---|
704 | Length of a filename string exceeds PATH_MAX and _POSIX_NO_TRUNC is in |
---|
705 | effect. |
---|
706 | |
---|
707 | @item ENOENT |
---|
708 | A file or directory does not exist. |
---|
709 | @item ENOSPC |
---|
710 | No space left on disk. |
---|
711 | |
---|
712 | @item ENOTDIR |
---|
713 | A component of the specified pathname was not a directory when a directory |
---|
714 | was expected. |
---|
715 | |
---|
716 | @item EPERM |
---|
717 | Operation is not permitted. Process does not have the appropriate priviledges |
---|
718 | or permissions to perform the requested operations. |
---|
719 | |
---|
720 | @item EROFS |
---|
721 | Read-only file system. |
---|
722 | |
---|
723 | @item EXDEV |
---|
724 | Attempt to link a file to another file system. |
---|
725 | |
---|
726 | @end table |
---|
727 | |
---|
728 | @subheading DESCRIPTION: |
---|
729 | |
---|
730 | The @code{link()} function atomically creates a new link for an existing file |
---|
731 | and increments the link count for the file. |
---|
732 | |
---|
733 | If the @code{link()} function fails, no directories are modified. |
---|
734 | |
---|
735 | The @code{existing} argument should not be a directory. |
---|
736 | |
---|
737 | The callder may (or may not) need permission to access the existing file. |
---|
738 | |
---|
739 | @subheading NOTES: |
---|
740 | |
---|
741 | NONE |
---|
742 | |
---|
743 | @page |
---|
744 | @subsection mkdir - Makes a directory |
---|
745 | |
---|
746 | @subheading CALLING SEQUENCE: |
---|
747 | |
---|
748 | @ifset is-C |
---|
749 | @example |
---|
750 | #include <sys/types.h> |
---|
751 | #include <sys/stat.h> |
---|
752 | |
---|
753 | int mkdir( |
---|
754 | const char *path, |
---|
755 | mode_t mode |
---|
756 | ); |
---|
757 | @end example |
---|
758 | @end ifset |
---|
759 | |
---|
760 | @ifset is-Ada |
---|
761 | @end ifset |
---|
762 | |
---|
763 | @subheading STATUS CODES: |
---|
764 | |
---|
765 | @table @b |
---|
766 | @item EACCES |
---|
767 | Search permission is denied for a directory in a file's path prefix |
---|
768 | |
---|
769 | @item EEXIST |
---|
770 | The name file already exist. |
---|
771 | |
---|
772 | @item EMLINK |
---|
773 | The number of links would exceed LINK_MAX |
---|
774 | |
---|
775 | @item ENAMETOOLONG |
---|
776 | Length of a filename string exceeds PATH_MAX and _POSIX_NO_TRUNC is in |
---|
777 | effect. |
---|
778 | |
---|
779 | @item ENOENT |
---|
780 | A file or directory does not exist. |
---|
781 | |
---|
782 | @item ENOSPC |
---|
783 | No space left on disk. |
---|
784 | |
---|
785 | @item ENOTDIR |
---|
786 | A component of the specified pathname was not a directory when a directory |
---|
787 | was expected. |
---|
788 | |
---|
789 | @item EROFS |
---|
790 | Read-only file system. |
---|
791 | |
---|
792 | @end table |
---|
793 | |
---|
794 | @subheading DESCRIPTION: |
---|
795 | |
---|
796 | The @code{mkdir()} function creates a new diectory named @code{path}. The |
---|
797 | permission bits (modified by the file creation mask) are set from @code{mode}. |
---|
798 | The owner and group IDs for the directory are set from the effective user ID |
---|
799 | and group ID. |
---|
800 | |
---|
801 | The new directory may (or may not) contain entries for.. and .. but is otherwise |
---|
802 | empty. |
---|
803 | |
---|
804 | @subheading NOTES: |
---|
805 | |
---|
806 | NONE |
---|
807 | |
---|
808 | @page |
---|
809 | @subsection mkfifo - Makes a FIFO special file |
---|
810 | |
---|
811 | @subheading CALLING SEQUENCE: |
---|
812 | |
---|
813 | @ifset is-C |
---|
814 | @example |
---|
815 | #include <sys/types.h> |
---|
816 | #include <sys/stat.h> |
---|
817 | |
---|
818 | |
---|
819 | int mkfifo( |
---|
820 | const char *path, |
---|
821 | mode_t mode |
---|
822 | ); |
---|
823 | @end example |
---|
824 | @end ifset |
---|
825 | |
---|
826 | @ifset is-Ada |
---|
827 | @end ifset |
---|
828 | |
---|
829 | @subheading STATUS CODES: |
---|
830 | |
---|
831 | @table @b |
---|
832 | @item EACCES |
---|
833 | Search permission is denied for a directory in a file's path prefix |
---|
834 | |
---|
835 | @item EEXIST |
---|
836 | The named file already exists. |
---|
837 | |
---|
838 | @item ENOENT |
---|
839 | A file or directory does not exist. |
---|
840 | |
---|
841 | @item ENOSPC |
---|
842 | No space left on disk. |
---|
843 | |
---|
844 | @item ENOTDIR |
---|
845 | A component of the specified @code{path} was not a directory when a directory |
---|
846 | was expected. |
---|
847 | |
---|
848 | @item EROFS |
---|
849 | Read-only file system. |
---|
850 | |
---|
851 | @end table |
---|
852 | |
---|
853 | @subheading DESCRIPTION: |
---|
854 | |
---|
855 | The @code{mkfifo()} function creates a new FIFO special file named @code{path}. |
---|
856 | The permission bits (modified by the file creation mask) are set from |
---|
857 | @code{mode}. The owner and group IDs for the FIFO are set from the efective |
---|
858 | user ID and group ID. |
---|
859 | |
---|
860 | @subheading NOTES: |
---|
861 | |
---|
862 | NONE |
---|
863 | |
---|
864 | @page |
---|
865 | @subsection unlink - Removes a directory entry |
---|
866 | |
---|
867 | @subheading CALLING SEQUENCE: |
---|
868 | |
---|
869 | @ifset is-C |
---|
870 | @example |
---|
871 | #include <unistd.h> |
---|
872 | |
---|
873 | int unlink( |
---|
874 | const char path |
---|
875 | ); |
---|
876 | @end example |
---|
877 | @end ifset |
---|
878 | |
---|
879 | @ifset is-Ada |
---|
880 | @end ifset |
---|
881 | |
---|
882 | @subheading STATUS CODES: |
---|
883 | |
---|
884 | @table @b |
---|
885 | @item EACCES |
---|
886 | Search permission is denied for a directory in a file's path prefix |
---|
887 | |
---|
888 | @item EBUSY |
---|
889 | The directory is in use. |
---|
890 | |
---|
891 | @item ENAMETOOLONG |
---|
892 | Length of a filename string exceeds PATH_MAX and _POSIX_NO_TRUNC is in |
---|
893 | effect. |
---|
894 | |
---|
895 | @item ENOENT |
---|
896 | A file or directory does not exist. |
---|
897 | |
---|
898 | @item ENOTDIR |
---|
899 | A component of the specified @code{path} was not a directory when a directory |
---|
900 | was expected. |
---|
901 | |
---|
902 | @item EPERM |
---|
903 | Operation is not permitted. Process does not have the appropriate priviledges |
---|
904 | or permissions to perform the requested operations. |
---|
905 | |
---|
906 | @item EROFS |
---|
907 | Read-only file system. |
---|
908 | |
---|
909 | @end table |
---|
910 | |
---|
911 | @subheading DESCRIPTION: |
---|
912 | |
---|
913 | The @code{unlink} function removes the link named by @code{path} and decrements the |
---|
914 | link count of the file referenced by the link. When the link count goes to zero |
---|
915 | and no process has the file open, the space occupied by the file is freed and the |
---|
916 | file is no longer accessible. |
---|
917 | |
---|
918 | @subheading NOTES: |
---|
919 | |
---|
920 | NONE |
---|
921 | |
---|
922 | @page |
---|
923 | @subsection rmdir - Delete a directory |
---|
924 | |
---|
925 | @subheading CALLING SEQUENCE: |
---|
926 | |
---|
927 | @ifset is-C |
---|
928 | @example |
---|
929 | #include <unistd.h> |
---|
930 | |
---|
931 | int rmdir( |
---|
932 | const char *pathname |
---|
933 | ); |
---|
934 | @end example |
---|
935 | @end ifset |
---|
936 | |
---|
937 | @ifset is-Ada |
---|
938 | @end ifset |
---|
939 | |
---|
940 | @subheading STATUS CODES: |
---|
941 | |
---|
942 | @table @b |
---|
943 | @item EPERM |
---|
944 | The filesystem containing @code{pathname} does not support the removal |
---|
945 | of directories. |
---|
946 | |
---|
947 | @item EFAULT |
---|
948 | @code{pathname} points ouside your accessible address space. |
---|
949 | |
---|
950 | @item EACCES |
---|
951 | Write access to the directory containing @code{pathname} was not |
---|
952 | allowed for the process's effective uid, or one of the directories in |
---|
953 | @code{pathname} did not allow search (execute) permission. |
---|
954 | |
---|
955 | @item EPERM |
---|
956 | The directory containing @code{pathname} has the stickybit (S_ISVTX) |
---|
957 | set and the process's effective uid is neither the uid of the file to |
---|
958 | be delected nor that of the director containing it. |
---|
959 | |
---|
960 | @item ENAMETOOLONG |
---|
961 | @code{pathname} was too long. |
---|
962 | |
---|
963 | @item ENOENT |
---|
964 | A dirctory component in @code{pathname} does not exist or is a |
---|
965 | dangling sybolic link. |
---|
966 | |
---|
967 | @item ENOTDIR |
---|
968 | @code{pathname}, or a component used as a directory in @code{pathname}, |
---|
969 | is not, in fact, a directory. |
---|
970 | |
---|
971 | @item ENOTEMPTY |
---|
972 | @code{pathname} contains entries other than . and .. . |
---|
973 | |
---|
974 | @item EBUSY |
---|
975 | @code{pathname} is the current working directory or root directory of |
---|
976 | some process |
---|
977 | |
---|
978 | @item EBUSY |
---|
979 | @code{pathname} is the current directory or root directory of some |
---|
980 | process. |
---|
981 | |
---|
982 | @item ENOMEM |
---|
983 | Insufficient kernel memory was available |
---|
984 | |
---|
985 | @item EROGS |
---|
986 | @code{pathname} refers to a file on a read-only filesystem. |
---|
987 | |
---|
988 | @item ELOOP |
---|
989 | @code{pathname} contains a reference to a circular symbolic link |
---|
990 | |
---|
991 | @end table |
---|
992 | |
---|
993 | @subheading DESCRIPTION: |
---|
994 | |
---|
995 | @code{rmdir} deletes a directory, whic must be empty |
---|
996 | |
---|
997 | |
---|
998 | @subheading NOTES: |
---|
999 | |
---|
1000 | NONE |
---|
1001 | |
---|
1002 | @page |
---|
1003 | @subsection rename - Renames a file |
---|
1004 | |
---|
1005 | @subheading CALLING SEQUENCE: |
---|
1006 | |
---|
1007 | @ifset is-C |
---|
1008 | @example |
---|
1009 | #include <unistd.h> |
---|
1010 | |
---|
1011 | int rename( |
---|
1012 | const char *old, |
---|
1013 | const char *new |
---|
1014 | ); |
---|
1015 | @end example |
---|
1016 | @end ifset |
---|
1017 | |
---|
1018 | @ifset is-Ada |
---|
1019 | @end ifset |
---|
1020 | |
---|
1021 | @subheading STATUS CODES: |
---|
1022 | |
---|
1023 | @table @b |
---|
1024 | @item EACCES |
---|
1025 | Search permission is denied for a directory in a file's path prefix. |
---|
1026 | |
---|
1027 | @item EBUSY |
---|
1028 | The directory is in use. |
---|
1029 | |
---|
1030 | @item EEXIST |
---|
1031 | The named file already exists. |
---|
1032 | |
---|
1033 | @item EINVAL |
---|
1034 | Invalid argument. |
---|
1035 | |
---|
1036 | @item EISDIR |
---|
1037 | Attempt to open a directory for writing or to rename a file to be a |
---|
1038 | directory. |
---|
1039 | |
---|
1040 | @item EMLINK |
---|
1041 | The number of links would exceed LINK_MAX. |
---|
1042 | |
---|
1043 | @item ENAMETOOLONG |
---|
1044 | Length of a filename string exceeds PATH_MAX and _POSIX_NO_TRUNC is |
---|
1045 | in effect. |
---|
1046 | |
---|
1047 | @item ENOENT |
---|
1048 | A file or directory does no exist. |
---|
1049 | |
---|
1050 | @item ENOSPC |
---|
1051 | No space left on disk. |
---|
1052 | |
---|
1053 | @item ENOTDIR |
---|
1054 | A component of the specified pathname was not a directory when a |
---|
1055 | directory was expected. |
---|
1056 | |
---|
1057 | @item ENOTEMPTY |
---|
1058 | Attempt to delete or rename a non-empty directory. |
---|
1059 | |
---|
1060 | @item EROFS |
---|
1061 | Read-only file system |
---|
1062 | |
---|
1063 | @item EXDEV |
---|
1064 | Attempt to link a file to another file system. |
---|
1065 | @end table |
---|
1066 | |
---|
1067 | @subheading DESCRIPTION: |
---|
1068 | |
---|
1069 | The @code{rename()} function causes the file known bo @code{old} to |
---|
1070 | now be known as @code{new}. |
---|
1071 | |
---|
1072 | Ordinary files may be renamed to ordinary files, and directories may be |
---|
1073 | renamed to directories; however, files cannot be converted using |
---|
1074 | @code{rename()}. The @code{new} pathname may not contain a path prefix |
---|
1075 | of @code{old}. |
---|
1076 | |
---|
1077 | @subheading NOTES: |
---|
1078 | |
---|
1079 | If a file already exists by the name @code{new}, it is removed. The |
---|
1080 | @code{rename()} function is atomic. If the @code{rename()} detects an |
---|
1081 | error, no files are removed. This guarantees that the |
---|
1082 | @code{rename("x", "x")} does not remove @code{x}. |
---|
1083 | |
---|
1084 | You may not rename dot or dot-dot. |
---|
1085 | |
---|
1086 | The routine is implemented in Cygnus newlib using @code{link()} and |
---|
1087 | @code{unlink()}. |
---|
1088 | |
---|
1089 | @page |
---|
1090 | @subsection stat - Gets information about a file |
---|
1091 | |
---|
1092 | @subheading CALLING SEQUENCE: |
---|
1093 | |
---|
1094 | @ifset is-C |
---|
1095 | @example |
---|
1096 | #include <sys/types.h> |
---|
1097 | #include <sys/stat.h> |
---|
1098 | |
---|
1099 | int stat( |
---|
1100 | const char *path, |
---|
1101 | struct stat *buf |
---|
1102 | ); |
---|
1103 | @end example |
---|
1104 | @end ifset |
---|
1105 | |
---|
1106 | @ifset is-Ada |
---|
1107 | @end ifset |
---|
1108 | |
---|
1109 | @subheading STATUS CODES: |
---|
1110 | |
---|
1111 | @table @b |
---|
1112 | @item EACCES |
---|
1113 | Search permission is denied for a directory in a file's path prefix. |
---|
1114 | |
---|
1115 | @item EBADF |
---|
1116 | Invalid file descriptor. |
---|
1117 | |
---|
1118 | @item ENAMETOOLONG |
---|
1119 | Length of a filename string exceeds PATH_MAX and _POSIX_NO_TRUNC is |
---|
1120 | in effect. |
---|
1121 | |
---|
1122 | @item ENOENT |
---|
1123 | A file or directory does not exist. |
---|
1124 | |
---|
1125 | @item ENOTDIR |
---|
1126 | A component of the specified pathname was not a directory when a |
---|
1127 | directory was expected. |
---|
1128 | |
---|
1129 | @end table |
---|
1130 | |
---|
1131 | @subheading DESCRIPTION: |
---|
1132 | |
---|
1133 | The @code{path} argument points to a pathname for a file. Read, write, or |
---|
1134 | execute permission for the file is not required, but all directories listed |
---|
1135 | in @code{path} must be searchable. The @code{stat()} function obtains |
---|
1136 | information about the named file and writes it to the area pointed to by |
---|
1137 | @code{but}. |
---|
1138 | |
---|
1139 | @subheading NOTES: |
---|
1140 | |
---|
1141 | NONE |
---|
1142 | |
---|
1143 | @page |
---|
1144 | @subsection fstat - Gets file status |
---|
1145 | |
---|
1146 | @subheading CALLING SEQUENCE: |
---|
1147 | |
---|
1148 | @ifset is-C |
---|
1149 | @example |
---|
1150 | #include <sys/types.h> |
---|
1151 | #include <sys/stat.h> |
---|
1152 | |
---|
1153 | int fstat( |
---|
1154 | int fildes, |
---|
1155 | struct stat *buf |
---|
1156 | ); |
---|
1157 | @end example |
---|
1158 | @end ifset |
---|
1159 | |
---|
1160 | @ifset is-Ada |
---|
1161 | @end ifset |
---|
1162 | |
---|
1163 | @subheading STATUS CODES: |
---|
1164 | |
---|
1165 | @table @b |
---|
1166 | @item EBADF |
---|
1167 | Invalid file descriptor |
---|
1168 | |
---|
1169 | @end table |
---|
1170 | |
---|
1171 | @subheading DESCRIPTION: |
---|
1172 | |
---|
1173 | The @code{fstat()} function obtains information about the file |
---|
1174 | associated with @code{fildes} and writes it to the area pointed |
---|
1175 | to by the @code{buf} argument. |
---|
1176 | |
---|
1177 | @subheading NOTES: |
---|
1178 | |
---|
1179 | NONE |
---|
1180 | |
---|
1181 | @page |
---|
1182 | @subsection access - Check user's permissions for a file |
---|
1183 | |
---|
1184 | @subheading CALLING SEQUENCE: |
---|
1185 | |
---|
1186 | @ifset is-C |
---|
1187 | @example |
---|
1188 | #include <unistd.h> |
---|
1189 | |
---|
1190 | int access( |
---|
1191 | const char *pathname, |
---|
1192 | int mode |
---|
1193 | ); |
---|
1194 | @end example |
---|
1195 | @end ifset |
---|
1196 | |
---|
1197 | @ifset is-Ada |
---|
1198 | @end ifset |
---|
1199 | |
---|
1200 | @subheading STATUS CODES: |
---|
1201 | |
---|
1202 | @table @b |
---|
1203 | @item EACCES |
---|
1204 | The requested access would be denied, either to the file itself or |
---|
1205 | one of the directories in @code{pathname}. |
---|
1206 | |
---|
1207 | @item EFAULT |
---|
1208 | @code{pathname} points outside your accessible address space. |
---|
1209 | |
---|
1210 | @item EINVAL |
---|
1211 | @code{Mode} was incorrectly specified. |
---|
1212 | |
---|
1213 | @item ENAMETOOLONG |
---|
1214 | @code{pathname} is too long. |
---|
1215 | |
---|
1216 | @item ENOENT |
---|
1217 | A directory component in @code{pathname} would have been accessible but |
---|
1218 | does not exist or was a dangling symbolic link. |
---|
1219 | |
---|
1220 | @item ENOTDIR |
---|
1221 | A component used as a directory in @code{pathname} is not, in fact, |
---|
1222 | a directory. |
---|
1223 | |
---|
1224 | @item ENOMEM |
---|
1225 | Insufficient kernel memory was available. |
---|
1226 | |
---|
1227 | @end table |
---|
1228 | |
---|
1229 | @subheading DESCRIPTION: |
---|
1230 | |
---|
1231 | @code{Access} checks whether the process would be allowed to read, write or |
---|
1232 | test for existence of the file (or other file system object) whose name is |
---|
1233 | @code{pathname}. If @code{pathname} is a symbolic link permissions of the |
---|
1234 | file referred by this symbolic link are tested. |
---|
1235 | |
---|
1236 | @code{Mode} is a mask consisting of one or more of R_OK, W_OK, X_OK and F_OK. |
---|
1237 | |
---|
1238 | @subheading NOTES: |
---|
1239 | |
---|
1240 | NONE |
---|
1241 | |
---|
1242 | @page |
---|
1243 | @subsection chmod - Changes file mode. |
---|
1244 | |
---|
1245 | @subheading CALLING SEQUENCE: |
---|
1246 | |
---|
1247 | @ifset is-C |
---|
1248 | @example |
---|
1249 | #include <sys/types.h> |
---|
1250 | #include <sys/stat.h> |
---|
1251 | |
---|
1252 | int chmod( |
---|
1253 | const char *path, |
---|
1254 | mode_t mode |
---|
1255 | ); |
---|
1256 | @end example |
---|
1257 | @end ifset |
---|
1258 | |
---|
1259 | @ifset is-Ada |
---|
1260 | @end ifset |
---|
1261 | |
---|
1262 | @subheading STATUS CODES: |
---|
1263 | |
---|
1264 | @table @b |
---|
1265 | @item EACCES |
---|
1266 | Search permission is denied for a directory in a file's path prefix |
---|
1267 | |
---|
1268 | @item ENAMETOOLONG |
---|
1269 | Length of a filename string exceeds PATH_MAX and _POSIX_NO_TRUNC is in |
---|
1270 | effect. |
---|
1271 | |
---|
1272 | @item ENOENT |
---|
1273 | A file or directory does not exist. |
---|
1274 | |
---|
1275 | @item ENOTDIR |
---|
1276 | A component of the specified pathname was not a directory when a directory |
---|
1277 | was expected. |
---|
1278 | |
---|
1279 | @item EPERM |
---|
1280 | Operation is not permitted. Process does not have the appropriate priviledges |
---|
1281 | or permissions to perform the requested operations. |
---|
1282 | |
---|
1283 | @item EROFS |
---|
1284 | Read-only file system. |
---|
1285 | |
---|
1286 | @end table |
---|
1287 | |
---|
1288 | @subheading DESCRIPTION: |
---|
1289 | |
---|
1290 | Set the file permission bits, the set user ID bit, and the set group ID bit |
---|
1291 | for the file named by @code{path} to @code{mode}. If the effective user ID |
---|
1292 | does not match the owner of the file and the calling process does not have |
---|
1293 | the appropriate privileges, @code{chmod()} returns -1 and sets @code{errno} to |
---|
1294 | @code{EPERM}. |
---|
1295 | |
---|
1296 | @subheading NOTES: |
---|
1297 | |
---|
1298 | NONE |
---|
1299 | |
---|
1300 | @page |
---|
1301 | @subsection fchmod - Changes permissions of a file |
---|
1302 | |
---|
1303 | @subheading CALLING SEQUENCE: |
---|
1304 | |
---|
1305 | @ifset is-C |
---|
1306 | @example |
---|
1307 | #include <sys/types.h> |
---|
1308 | #include <sys/stat.h> |
---|
1309 | |
---|
1310 | int fchmod( |
---|
1311 | int fildes, |
---|
1312 | mode_t mode |
---|
1313 | ); |
---|
1314 | @end example |
---|
1315 | @end ifset |
---|
1316 | |
---|
1317 | @ifset is-Ada |
---|
1318 | @end ifset |
---|
1319 | |
---|
1320 | @subheading STATUS CODES: |
---|
1321 | |
---|
1322 | @table @b |
---|
1323 | @item EACCES |
---|
1324 | Search permission is denied for a directory in a file's path prefix. |
---|
1325 | |
---|
1326 | @item EBADF |
---|
1327 | The descriptor is not valid. |
---|
1328 | |
---|
1329 | @item EFAULT |
---|
1330 | @code{path} points outside your accessible address space. |
---|
1331 | |
---|
1332 | @item EIO |
---|
1333 | A low-level I/o error occurred while modifying the inode. |
---|
1334 | |
---|
1335 | @item ELOOP |
---|
1336 | @code{path} contains a circular reference |
---|
1337 | |
---|
1338 | @item ENAMETOOLONG |
---|
1339 | Length of a filename string exceeds PATH_MAX and _POSIX_NO_TRUNC is |
---|
1340 | in effect. |
---|
1341 | |
---|
1342 | @item ENOENT |
---|
1343 | A file or directory does no exist. |
---|
1344 | |
---|
1345 | @item ENOMEM |
---|
1346 | Insufficient kernel memory was avaliable. |
---|
1347 | |
---|
1348 | @item ENOTDIR |
---|
1349 | A component of the specified pathname was not a directory when a |
---|
1350 | directory was expected. |
---|
1351 | |
---|
1352 | @item EPERM |
---|
1353 | The effective UID does not match the owner of the file, and is not |
---|
1354 | zero |
---|
1355 | |
---|
1356 | @item EROFS |
---|
1357 | Read-only file system |
---|
1358 | @end table |
---|
1359 | |
---|
1360 | @subheading DESCRIPTION: |
---|
1361 | |
---|
1362 | The mode of the file given by @code{path} or referenced by |
---|
1363 | @code{filedes} is changed. |
---|
1364 | |
---|
1365 | @subheading NOTES: |
---|
1366 | |
---|
1367 | NONE |
---|
1368 | |
---|
1369 | @page |
---|
1370 | @subsection getdents - Get directory entries |
---|
1371 | |
---|
1372 | @subheading CALLING SEQUENCE: |
---|
1373 | |
---|
1374 | @ifset is-C |
---|
1375 | @example |
---|
1376 | #include <unistd.h> |
---|
1377 | #include <linux/dirent.h> |
---|
1378 | #include <linux/unistd.h> |
---|
1379 | |
---|
1380 | long getdents( |
---|
1381 | int dd_fd, |
---|
1382 | char *dd_buf, |
---|
1383 | int dd_len |
---|
1384 | ); |
---|
1385 | @end example |
---|
1386 | @end ifset |
---|
1387 | |
---|
1388 | @ifset is-Ada |
---|
1389 | @end ifset |
---|
1390 | |
---|
1391 | @subheading STATUS CODES: |
---|
1392 | |
---|
1393 | @table @b |
---|
1394 | @item E |
---|
1395 | The |
---|
1396 | |
---|
1397 | @end table |
---|
1398 | |
---|
1399 | @subheading DESCRIPTION: |
---|
1400 | |
---|
1401 | @subheading NOTES: |
---|
1402 | |
---|
1403 | NONE |
---|
1404 | |
---|
1405 | @page |
---|
1406 | @subsection chown - Changes the owner and/or group of a file. |
---|
1407 | |
---|
1408 | @subheading CALLING SEQUENCE: |
---|
1409 | |
---|
1410 | @ifset is-C |
---|
1411 | @example |
---|
1412 | #include <sys/types.h> |
---|
1413 | #include <unistd.h> |
---|
1414 | |
---|
1415 | int chown( |
---|
1416 | const char *path, |
---|
1417 | uid_t owner, |
---|
1418 | gid_t group |
---|
1419 | ); |
---|
1420 | @end example |
---|
1421 | @end ifset |
---|
1422 | |
---|
1423 | @ifset is-Ada |
---|
1424 | @end ifset |
---|
1425 | |
---|
1426 | @subheading STATUS CODES: |
---|
1427 | |
---|
1428 | @table @b |
---|
1429 | @item EACCES |
---|
1430 | Search permission is denied for a directory in a file's path prefix |
---|
1431 | |
---|
1432 | @item EINVAL |
---|
1433 | Invalid argument |
---|
1434 | |
---|
1435 | @item ENAMETOOLONG |
---|
1436 | Length of a filename string exceeds PATH_MAX and _POSIX_NO_TRUNC is in |
---|
1437 | effect. |
---|
1438 | |
---|
1439 | @item ENOENT |
---|
1440 | A file or directory does not exist. |
---|
1441 | |
---|
1442 | @item ENOTDIR |
---|
1443 | A component of the specified pathname was not a directory when a directory |
---|
1444 | was expected. |
---|
1445 | |
---|
1446 | @item EPERM |
---|
1447 | Operation is not permitted. Process does not have the appropriate priviledges |
---|
1448 | or permissions to perform the requested operations. |
---|
1449 | |
---|
1450 | @item EROFS |
---|
1451 | Read-only file system. |
---|
1452 | |
---|
1453 | @end table |
---|
1454 | |
---|
1455 | @subheading DESCRIPTION: |
---|
1456 | |
---|
1457 | The user ID and group ID of the file named by @code{path} are set to |
---|
1458 | @code{owner} and @code{path}, respectively. |
---|
1459 | |
---|
1460 | For regular files, the set group ID (S_ISGID) and set user ID (S_ISUID) |
---|
1461 | bits are cleared. |
---|
1462 | |
---|
1463 | Some systems consider it a security violation to allow the owner of a file to |
---|
1464 | be changed, If users are billed for disk space usage, loaning a file to |
---|
1465 | another user could result in incorrect billing. The @code{chown()} function |
---|
1466 | may be restricted to privileged users for some or all files. The group ID can |
---|
1467 | still be changed to one of the supplementary group IDs. |
---|
1468 | |
---|
1469 | @subheading NOTES: |
---|
1470 | |
---|
1471 | This function may be restricted for some file. The @code{pathconf} function |
---|
1472 | can be used to test the @code{_PC_CHOWN_RESTRICTED} flag. |
---|
1473 | |
---|
1474 | |
---|
1475 | |
---|
1476 | @page |
---|
1477 | @subsection utime - Change access and/or modification times of an inode |
---|
1478 | |
---|
1479 | @subheading CALLING SEQUENCE: |
---|
1480 | |
---|
1481 | @ifset is-C |
---|
1482 | @example |
---|
1483 | #include <sys/types.h> |
---|
1484 | |
---|
1485 | int utime( |
---|
1486 | const char *filename, |
---|
1487 | struct utimbuf *buf |
---|
1488 | ); |
---|
1489 | @end example |
---|
1490 | @end ifset |
---|
1491 | |
---|
1492 | @ifset is-Ada |
---|
1493 | @end ifset |
---|
1494 | |
---|
1495 | @subheading STATUS CODES: |
---|
1496 | |
---|
1497 | @table @b |
---|
1498 | @item EACCES |
---|
1499 | Permission to write the file is denied |
---|
1500 | |
---|
1501 | @item ENOENT |
---|
1502 | @code{Filename} does not exist |
---|
1503 | |
---|
1504 | @end table |
---|
1505 | |
---|
1506 | @subheading DESCRIPTION: |
---|
1507 | |
---|
1508 | @code{Utime} changes the access and modification times of the inode |
---|
1509 | specified by @code{filename} to the @code{actime} and @code{modtime} |
---|
1510 | fields of @code{buf} respectively. If @code{buf} is NULL, then the |
---|
1511 | access and modification times of the file are set to the current time. |
---|
1512 | |
---|
1513 | @subheading NOTES: |
---|
1514 | |
---|
1515 | NONE |
---|
1516 | |
---|
1517 | @page |
---|
1518 | @subsection ftruncate - truncate a file to a specified length |
---|
1519 | |
---|
1520 | @subheading CALLING SEQUENCE: |
---|
1521 | |
---|
1522 | @ifset is-C |
---|
1523 | @example |
---|
1524 | #include <unistd.h> |
---|
1525 | |
---|
1526 | int ftrunctate( |
---|
1527 | int fd, |
---|
1528 | size_t length |
---|
1529 | ); |
---|
1530 | @end example |
---|
1531 | @end ifset |
---|
1532 | |
---|
1533 | @ifset is-Ada |
---|
1534 | @end ifset |
---|
1535 | |
---|
1536 | @subheading STATUS CODES: |
---|
1537 | |
---|
1538 | @table @b |
---|
1539 | @item ENOTDIR |
---|
1540 | A component of the path prefix is not a directory. |
---|
1541 | |
---|
1542 | @item EINVAL |
---|
1543 | The pathname contains a character with the high-order bit set. |
---|
1544 | |
---|
1545 | @item ENAMETOOLONG |
---|
1546 | A component of a pathname exceeded 255 characters, or an entire |
---|
1547 | path name exceeded 1023 characters. |
---|
1548 | |
---|
1549 | @item ENOENT |
---|
1550 | The named file does not exist. |
---|
1551 | |
---|
1552 | @item EACCES |
---|
1553 | The named file is not writable by the user. |
---|
1554 | |
---|
1555 | @item EACCES |
---|
1556 | Search permission is denied for a component of the path prefix. |
---|
1557 | |
---|
1558 | @item ELOOP |
---|
1559 | Too many symbolic links were encountered in translating the |
---|
1560 | pathname |
---|
1561 | |
---|
1562 | @item EISDIR |
---|
1563 | The named file is a directory. |
---|
1564 | |
---|
1565 | @item EROFS |
---|
1566 | The named file resides on a read-only file system |
---|
1567 | |
---|
1568 | @item ETXTBSY |
---|
1569 | The file is a pure procedure (shared text) file that is being |
---|
1570 | executed |
---|
1571 | |
---|
1572 | @item EIO |
---|
1573 | An I/O error occurred updating the inode. |
---|
1574 | |
---|
1575 | @item EFAULT |
---|
1576 | @code{Path} points outside the process's allocated address space. |
---|
1577 | |
---|
1578 | @item EBADF |
---|
1579 | The @code{fd} is not a valid descriptor. |
---|
1580 | |
---|
1581 | @end table |
---|
1582 | |
---|
1583 | @subheading DESCRIPTION: |
---|
1584 | |
---|
1585 | @code{truncate()} causes the file named by @code{path} or referenced by |
---|
1586 | @code{fd} to be truncated to at most @code{length} bytes in size. If the |
---|
1587 | file previously was larger than this size, the extra data is lost. With |
---|
1588 | @code{ftruncate()}, the file must be open for writing. |
---|
1589 | |
---|
1590 | @subheading NOTES: |
---|
1591 | |
---|
1592 | NONE |
---|
1593 | |
---|
1594 | @page |
---|
1595 | @subsection truncate - truncate a file to a specified length |
---|
1596 | |
---|
1597 | @subheading CALLING SEQUENCE: |
---|
1598 | |
---|
1599 | @ifset is-C |
---|
1600 | @example |
---|
1601 | #include <unistd.h> |
---|
1602 | |
---|
1603 | int trunctate( |
---|
1604 | const char *path, |
---|
1605 | size_t length |
---|
1606 | ); |
---|
1607 | @end example |
---|
1608 | @end ifset |
---|
1609 | |
---|
1610 | @ifset is-Ada |
---|
1611 | @end ifset |
---|
1612 | |
---|
1613 | @subheading STATUS CODES: |
---|
1614 | |
---|
1615 | @table @b |
---|
1616 | @item ENOTDIR |
---|
1617 | A component of the path prefix is not a directory. |
---|
1618 | |
---|
1619 | @item EINVAL |
---|
1620 | The pathname contains a character with the high-order bit set. |
---|
1621 | |
---|
1622 | @item ENAMETOOLONG |
---|
1623 | A component of a pathname exceeded 255 characters, or an entire |
---|
1624 | path name exceeded 1023 characters. |
---|
1625 | |
---|
1626 | @item ENOENT |
---|
1627 | The named file does not exist. |
---|
1628 | |
---|
1629 | @item EACCES |
---|
1630 | The named file is not writable by the user. |
---|
1631 | |
---|
1632 | @item EACCES |
---|
1633 | Search permission is denied for a component of the path prefix. |
---|
1634 | |
---|
1635 | @item ELOOP |
---|
1636 | Too many symbolic links were encountered in translating the |
---|
1637 | pathname |
---|
1638 | |
---|
1639 | @item EISDIR |
---|
1640 | The named file is a directory. |
---|
1641 | |
---|
1642 | @item EROFS |
---|
1643 | The named file resides on a read-only file system |
---|
1644 | |
---|
1645 | @item ETXTBSY |
---|
1646 | The file is a pure procedure (shared text) file that is being |
---|
1647 | executed |
---|
1648 | |
---|
1649 | @item EIO |
---|
1650 | An I/O error occurred updating the inode. |
---|
1651 | |
---|
1652 | @item EFAULT |
---|
1653 | @code{Path} points outside the process's allocated address space. |
---|
1654 | |
---|
1655 | @item EBADF |
---|
1656 | The @code{fd} is not a valid descriptor. |
---|
1657 | |
---|
1658 | @end table |
---|
1659 | |
---|
1660 | @subheading DESCRIPTION: |
---|
1661 | |
---|
1662 | @code{truncate()} causes the file named by @code{path} or referenced by |
---|
1663 | @code{fd} to be truncated to at most @code{length} bytes in size. If the |
---|
1664 | file previously was larger than this size, the extra data is lost. With |
---|
1665 | @code{ftruncate()}, the file must be open for writing. |
---|
1666 | |
---|
1667 | @subheading NOTES: |
---|
1668 | |
---|
1669 | NONE |
---|
1670 | |
---|
1671 | @page |
---|
1672 | @subsection pathconf - Gets configuration values for files |
---|
1673 | |
---|
1674 | @subheading CALLING SEQUENCE: |
---|
1675 | |
---|
1676 | @ifset is-C |
---|
1677 | @example |
---|
1678 | #include <unistd.h> |
---|
1679 | |
---|
1680 | int pathconf( |
---|
1681 | const char *path, |
---|
1682 | int name |
---|
1683 | ); |
---|
1684 | @end example |
---|
1685 | @end ifset |
---|
1686 | |
---|
1687 | @ifset is-Ada |
---|
1688 | @end ifset |
---|
1689 | |
---|
1690 | @subheading STATUS CODES: |
---|
1691 | |
---|
1692 | @table @b |
---|
1693 | @item EINVAL |
---|
1694 | Invalid argument |
---|
1695 | |
---|
1696 | @item EACCES |
---|
1697 | Permission to write the file is denied |
---|
1698 | |
---|
1699 | @item ENAMETOOLONG |
---|
1700 | Length of a filename string exceeds PATH_MAX and _POSIX_NO_TRUNC |
---|
1701 | is in effect. |
---|
1702 | |
---|
1703 | @item ENOENT |
---|
1704 | A file or directory does not exist |
---|
1705 | |
---|
1706 | @item ENOTDIR |
---|
1707 | A component of the specified @code{path} was not a directory whan a |
---|
1708 | directory was expected. |
---|
1709 | |
---|
1710 | @end table |
---|
1711 | |
---|
1712 | @subheading DESCRIPTION: |
---|
1713 | |
---|
1714 | @code{pathconf()} gets a value for the configuration option @code{name} |
---|
1715 | for the open file descriptor @code{filedes}. |
---|
1716 | |
---|
1717 | The possible values for @code{name} are: |
---|
1718 | |
---|
1719 | @table @b |
---|
1720 | @item _PC_LINK_MAX |
---|
1721 | returns the maximum number of links to the file. If @code{filedes} or |
---|
1722 | @code{path} refer to a directory, then the value applies to the whole |
---|
1723 | directory. The corresponding macro is @code{_POSIX_LINK_MAX}. |
---|
1724 | |
---|
1725 | @item _PC_MAX_CANON |
---|
1726 | returns the maximum length of a formatted input line, where @code{filedes} |
---|
1727 | or @code{path} must refer to a terminal. The corresponding macro is |
---|
1728 | @code{_POSIX_MAX_CANON}. |
---|
1729 | |
---|
1730 | @item _PC_MAX_INPUT |
---|
1731 | returns the maximum length of an input line, where @code{filedes} or |
---|
1732 | @code{path} must refer to a terminal. The corresponding macro is |
---|
1733 | @code{_POSIX_MAX_INPUT}. |
---|
1734 | |
---|
1735 | @item _PC_NAME_MAX |
---|
1736 | returns the maximum length of a filename in the directory @code{path} or |
---|
1737 | @code{filedes}. The process is allowed to create. The corresponding macro |
---|
1738 | is @code{_POSIX_NAME_MAX}. |
---|
1739 | |
---|
1740 | @item _PC_PATH_MAX |
---|
1741 | returns the maximum length of a relative pathname when @code{path} or |
---|
1742 | @code{filedes} is the current working directory. The corresponding macro |
---|
1743 | is @code{_POSIX_PATH_MAX}. |
---|
1744 | |
---|
1745 | @item _PC_PIPE_BUF |
---|
1746 | returns the size of the pipe buffer, where @code{filedes} must refer to a |
---|
1747 | pipe or FIFO and @code{path} must refer to a FIFO. The corresponding macro |
---|
1748 | is @code{_POSIX_PIPE_BUF}. |
---|
1749 | |
---|
1750 | @item _PC_CHOWN_RESTRICTED |
---|
1751 | returns nonzero if the chown(2) call may not be used on this file. If |
---|
1752 | @code{filedes} or @code{path} refer to a directory, then this applies to all |
---|
1753 | files in that directory. The corresponding macro is |
---|
1754 | @code{_POSIX_CHOWN_RESTRICTED}. |
---|
1755 | |
---|
1756 | @end table |
---|
1757 | |
---|
1758 | @subheading NOTES: |
---|
1759 | |
---|
1760 | Files with name lengths longer than the value returned for @code{name} equal |
---|
1761 | @code{_PC_NAME_MAX} may exist in the given directory. |
---|
1762 | |
---|
1763 | @page |
---|
1764 | @subsection fpathconf - Gets configuration values for files |
---|
1765 | |
---|
1766 | @subheading CALLING SEQUENCE: |
---|
1767 | |
---|
1768 | @ifset is-C |
---|
1769 | @example |
---|
1770 | #include <unistd.h> |
---|
1771 | |
---|
1772 | int fpathconf( |
---|
1773 | int filedes, |
---|
1774 | int name |
---|
1775 | ); |
---|
1776 | @end example |
---|
1777 | @end ifset |
---|
1778 | |
---|
1779 | @ifset is-Ada |
---|
1780 | @end ifset |
---|
1781 | |
---|
1782 | @subheading STATUS CODES: |
---|
1783 | |
---|
1784 | @table @b |
---|
1785 | @item EINVAL |
---|
1786 | Invalid argument |
---|
1787 | |
---|
1788 | @item EACCES |
---|
1789 | Permission to write the file is denied |
---|
1790 | @item ENAMETOOLONG |
---|
1791 | |
---|
1792 | Length of a filename string exceeds PATH_MAX and _POSIX_NO_TRUNC |
---|
1793 | is in effect. |
---|
1794 | |
---|
1795 | @item ENOENT |
---|
1796 | A file or directory does not exist |
---|
1797 | |
---|
1798 | @item ENOTDIR |
---|
1799 | A component of the specified @code{path} was not a directory whan a |
---|
1800 | directory was expected. |
---|
1801 | |
---|
1802 | @end table |
---|
1803 | |
---|
1804 | |
---|
1805 | @subheading DESCRIPTION: |
---|
1806 | |
---|
1807 | @code{pathconf()} gets a value for the configuration option @code{name} |
---|
1808 | for the open file descriptor @code{filedes}. |
---|
1809 | |
---|
1810 | The possible values for name are: |
---|
1811 | |
---|
1812 | @table @b |
---|
1813 | @item _PC_LINK_MAX |
---|
1814 | returns the maximum number of links to the file. If @code{filedes} or |
---|
1815 | @code{path} refer to a directory, then the value applies to the whole |
---|
1816 | directory. The corresponding macro is _POSIX_LINK_MAX. |
---|
1817 | |
---|
1818 | @item _PC_MAX_CANON |
---|
1819 | returns the maximum length of a formatted input line, where @code{filedes} |
---|
1820 | or @code{path} must refer to a terminal. The corresponding macro is |
---|
1821 | @code{_POSIX_MAX_CANON}. |
---|
1822 | |
---|
1823 | @item _PC_MAX_INPUT |
---|
1824 | returns the maximum length of an input line, where @code{filedes} or |
---|
1825 | @code{path} must refer to a terminal. The corresponding macro is |
---|
1826 | @code{_POSIX_MAX_INPUT}. |
---|
1827 | |
---|
1828 | @item _PC_NAME_MAX |
---|
1829 | returns the maximum length of a filename in the directory @code{path} or |
---|
1830 | @code{filedes}. The process is allowed to create. The corresponding macro |
---|
1831 | is @code{_POSIX_NAME_MAX}. |
---|
1832 | |
---|
1833 | @item _PC_PATH_MAX |
---|
1834 | returns the maximum length of a relative pathname when @code{path} or |
---|
1835 | @code{filedes} is the current working directory. The corresponding macro |
---|
1836 | is @code{_POSIX_PATH_MAX}. |
---|
1837 | |
---|
1838 | @item _PC_PIPE_BUF |
---|
1839 | returns the size of the pipe buffer, where @code{filedes} must refer to a |
---|
1840 | pipe or FIFO and @code{path} must refer to a FIFO. The corresponding macro |
---|
1841 | is @code{_POSIX_PIPE_BUF}. |
---|
1842 | |
---|
1843 | @item _PC_CHOWN_RESTRICTED |
---|
1844 | returns nonzero if the @code{chown()} call may not be used on this file. If |
---|
1845 | @code{filedes} or @code{path} refer to a directory, then this applies to all |
---|
1846 | files in that directory. The corresponding macro is |
---|
1847 | @code{_POSIX_CHOWN_RESTRICTED}. |
---|
1848 | |
---|
1849 | @end table |
---|
1850 | |
---|
1851 | @subheading NOTES: |
---|
1852 | |
---|
1853 | NONE |
---|
1854 | |
---|
1855 | @page |
---|
1856 | @subsection mknod - create a directory |
---|
1857 | |
---|
1858 | @subheading CALLING SEQUENCE: |
---|
1859 | |
---|
1860 | @ifset is-C |
---|
1861 | @example |
---|
1862 | #include <unistd.h> |
---|
1863 | #include <fcntl.h> |
---|
1864 | #include <sys/types.h> |
---|
1865 | #include <sys/stat.h> |
---|
1866 | |
---|
1867 | long mknod( |
---|
1868 | const char *pathname, |
---|
1869 | mode_t mode, |
---|
1870 | dev_t dev |
---|
1871 | ); |
---|
1872 | @end example |
---|
1873 | @end ifset |
---|
1874 | |
---|
1875 | @ifset is-Ada |
---|
1876 | @end ifset |
---|
1877 | |
---|
1878 | @subheading STATUS CODES: |
---|
1879 | |
---|
1880 | @code{mknod} returns zero on success, or -1 if an error occurred (in which case, |
---|
1881 | errno is set appropriately). |
---|
1882 | |
---|
1883 | @table @b |
---|
1884 | @item ENAMETOOLONG |
---|
1885 | @code{pathname} was too long. |
---|
1886 | |
---|
1887 | @item ENOENT |
---|
1888 | A directory component in @code{pathname} does not exist or is a dangling symbolic |
---|
1889 | link. |
---|
1890 | |
---|
1891 | @item ENOTDIR |
---|
1892 | A component used in the directory @code{pathname} is not, in fact, a directory. |
---|
1893 | |
---|
1894 | @item ENOMEM |
---|
1895 | Insufficient kernel memory was available |
---|
1896 | |
---|
1897 | @item EROFS |
---|
1898 | @code{pathname} refers to a file on a read-only filesystem. |
---|
1899 | |
---|
1900 | @item ELOOP |
---|
1901 | @code{pathname} contains a reference to a circular symbolic link, ie a symbolic |
---|
1902 | link whose expansion contains a reference to itself. |
---|
1903 | |
---|
1904 | @item ENOSPC |
---|
1905 | The device containing @code{pathname} has no room for the new node. |
---|
1906 | |
---|
1907 | @end table |
---|
1908 | |
---|
1909 | @subheading DESCRIPTION: |
---|
1910 | |
---|
1911 | @code{mknod} attempts to create a filesystem node (file, device special file or |
---|
1912 | named pipe) named @code{pathname}, specified by @code{mode} and @code{dev}. |
---|
1913 | |
---|
1914 | @code{mode} specifies both the permissions to use and the type of node to be created. |
---|
1915 | |
---|
1916 | It should be a combination (using bitwise OR) of one of the file types listed |
---|
1917 | below and the permissions for the new node. |
---|
1918 | |
---|
1919 | The permissions are modified by the process's @code{umask} in the usual way: the |
---|
1920 | permissions of the created node are @code{(mode & ~umask)}. |
---|
1921 | |
---|
1922 | The file type should be one of @code{S_IFREG}, @code{S_IFCHR}, @code{S_IFBLK} and |
---|
1923 | @code{S_IFIFO} to specify a normal file (which will be created empty), character |
---|
1924 | special file, block special file or FIFO (named pipe), respectively, or zero, which |
---|
1925 | will create a normal file. |
---|
1926 | |
---|
1927 | If the file type is @code{S_IFCHR} or @code{S_IFBLK} then @code{dev} specifies the major |
---|
1928 | and minor numbers of the newly created device special file; otherwise it is ignored. |
---|
1929 | |
---|
1930 | The newly created node will be owned by the effective uid of the process. If the |
---|
1931 | directory containing the node has the set group id bit set, or if the filesystem |
---|
1932 | is mounted with BSD group semantics, the new node will inherit the group ownership |
---|
1933 | from its parent directory; otherwise it will be owned by the effective gid of the |
---|
1934 | process. |
---|
1935 | |
---|
1936 | |
---|
1937 | @subheading NOTES: |
---|
1938 | |
---|
1939 | NONE |
---|