4 4.1 I / O I / s t a t s t a t ( ) U N I X 4.2 stat fstat lstat s t a t #include <sys/types.h> #include <sys/stat.h> int stat(const char p a * t h n a m e, struct stat b * u f) ; int fstat(int f i l e d e s,struct stat b * u f) ; int lstat(const char p a t * h n a m e, struct stat b * u f) ; 0 1 p a t h n a m e s t a t f s t a f i l e d e s l s t a t s t a t l s t a t ( 4. 21 l s t a t 4. 16 ) l s t a t POSIX 1003.1-1990. 1 a S V R 4 4. 3 + B S D l s t a t b u f
4 55 P O S I X. 1 s t _ r d e v s t _ b l k s i z e s t _ b l o c k s S V R 4 4. 3 + B S D ( 2. 7 ) s t a t ls -l 4.3 U N I X (1) (regular file) (2) (directory file) (3) (character special file) (4) (block special file) ( 5 ) F I F O 14. 5 (6) ( s o c k e t ) 15 4. 3 + B S D S V R 4 S V R 4 (7) (symbolic link) 4. 16 s t a t s t _ m o d e 4-1 s t a t s t _ m o d e 4-1 < s y s / s t a t. h > S _ I S R E G () S _ I S D I R () S _ I S C H R () S _ I S B L K ()
5 6 U N I X S _ I S F I F O () S _ I S L N K () S _ I S S O C K () F I F O P O S I X. 1 S V R 4 P O S I X. 1 S V R 4 4-1 4-1 4-1
4 57 s h e l l s h e l l > l s t a t s t a t s t a t U N I X S _ I S x x x s t _ m o d e S _ I F M T S _ I F x x x S V R 4 4. 3 + B S D < s y s / s t a t. h > S _ I S D I R #define S_ISDIR (mode) (((mode) & S_IFMT) == S_IFDIR) 4-2 4. 21 4-2 ( %) 30 369 91. 7 1 901 5. 7 416 1. 3 373 1. 1 61 0. 2 5 0. 0 F I F O 1 0. 0 4.4 - - I D - - I D I D 4-3 4-3 I D I D I D I D I D I D I D - - I D - - I D e x e c I D I D 8. 10 I D I D I D ( 1. 8 I D ) - - I D - - I D I I 8. 10 s e t u i d
5 8 U N I X P O S I X. 1 I D _ P O S I X _ S AV E D _ I D S _ S C _ S AV E D _ I D S s y s c o n f S V R 4 FIPS 151-1 P O S I X. 1 I D I I D I s t a t s t _ u i d s t _ g i d I D I I D I D ( s t _ m o d e ) I D ( s t _ u i d ) I D ( s t _ g i d ) - - I D ( s e t - u s e r- I D ) - - I D ( s e t - g r o u p - I D ) - - I D I D U N I X p a s s w d ( 1 ) - - I D ( / e t c / p a s s w d /etc/shadow), - - I D - -I D 8 s t a t - - I D - -I D s t _ m o d e S _ I S U I D S _ I S G I D 4.5 s t _ m o d e ( ) 9 4-4 4-4 4-4 9 < s y s / s t a t. h > c h m o d ( 1 ) 9 u s t _ m o d e ( ) g o S _ I R U S R - S _ I W U S R - S _ I X U S R - c h m o d o S _ I R G R P - S _ I W G R P - c h m o d S _ I X G R P S _ I R O T H S _ I W O T H S _ I X O T H - - - -
4 59 / u s r / d i c t / w o r d s /, /usr, /usr/dict ( - ) / u s r / d i c t, w o r d s w o r d s / u s r / d i c t./ w o r d ( ) PAT H ( 8. 4 ) s h e l l o p e n O _ R D O N LY O _ R D W R o p e n O _ W R O N LY O _ R D W R o p e n O _ T R U N C 6 e x e c 8. 9 ( s t _ u i d s t _ g i d ) ID ( I D I D ) ID ( ) I D I I D (1) I D 0 ( ) (2) I D I D ( ) (a) (b) - 1-1 - (3) I D I D I (a) (b) (4) ( ( 2 ) )
6 0 U N I X 4.6 3 o p e n c r e a t I D I D 4. 20 m k d i r I D I I D P O S I X. 1 I D (1) I D I (2) I D I S V R 4 I D - - I I D I D I D I 4. 3 + B S D I D I P O S I X. 1 m o u n t ( 1 ) FIPS 151-1 I D I P O S I X. 1 ( I D ) I D / v a r / s p o o l 4. 3 + B S D S V R 4 S V R 4 - - I D S V R 4 m k d i r - - I D 4. 20 m k d i r 4.7 access o p e n I D I I D I D - - I D - - I D ( ) - - I D a c c e s s I D I D ( 4. 5 ) # i n c l u d e < u n i s t d. h > int access(const char p a t * h n a m e, int m o d e) ; 0 1
4 61 m o d e 4-5 4-5 access m o d e < u n i s t d. h > m o d e R _ O K W _ O K X _ O K F _ O K 4-2 a c c e s s 4-2 access $ ls -1 a.out -rwxrwxr-x 1 stevens 105216 Jan 18 08:48 a.out $ a.out a.out read access OK open for reading OK $ ls -1/ etc/uucp/systems -rw-r----- 1 uucp 1441 Jul 18 15:05 /etc/uucp/systems $ a.out /etc/uucp/systems access error for /etc/uucp/systems: Permission denied open error for /etc/uucp/systems: Permission denied $ s u P a s s w o r d : # chown uucp a.out u u c p # chmod u+s a.out - -I D $ ls -1 a.out S U I D -rwsrwxr-x 1 uucp 105216 Jan 18 08:48 a.out
6 2 U N I X # exit $ a.out /etc/uucp/systems access error for /etc/uucp/systems: Permission denied open for reading OK - - I D o p e n 8 4.8 umask 9 u m a s k ( ) #include <sys/types.h> #include <sys/stat.h> mode_t umask(mode_t c m a s k) ; c m a s k 4-4 9 ( S _ I R U S R, S _ I W U S R ) ( 3. 3 3. 4 o p e n c r e a t m o d e ) 4. 20 1 m o d e 0 4-3 u m a s k 0 u m a s k $ u m a s k 02 $ a. o u t 4 ls -1 foo bar -rw------- 1 stevens 0 Nov 16 16:23 bar -rw-rw-rw- 1 stevens 0 Nov 16 16:23 foo $ u m a s k 0 2 4-3 umask
4 63 4.9 chmod f c h m o d #include <sys/types.h> #include <sys/stat.h> int chmod(const char p a t * h n a m e, mode_t m o d e) ; int fchmod(int f i l e d e s, mode_t m o d e) ; 0 1 c h m o d f c h m o d f c h m o d P O S I X. 1 S V R 4 4. 3 + B S D I D m o d e 4-6 4-6 chmod m o d e < s y s / s t a t. h > m o d e S _ I S U I D S _ I S G I D S _ I S V T X S _ I R W X U S _ I R U S R S _ I W U S R S _ I X U S R S _ I R W X G S _ I R G R P S _ I W G R P S _ I X G R P - - I D - - I D
6 4 U N I X m o d e S _ I R W X O S _ I R O T H S _ I W O T H S _ I X O T H 4-6 9 4-4 9 - I D ( S _ I S U G ID), - ( S _ I S V T X ) ( S _ I RW X U G O ) ( U N I X S _ I RW X U G O S _ I RW X U S _ I RW X G S _ I RW X O UNIX shell U N I X ) - ( S _ I S V T X ) P O S I X. 1 u m a s k 4-3 f o o b a r $ ls -1 foo bar -rw------- 1 stevens 0 Nov 16 16:23 bar -rw-rw-rw- 1 stevens 0 Nov 16 16:23 foo 4-4 4-4 $ ls -1 foo bar -rw-r--r-- 1 stevens 0 Nov 16 16:23 bar -rw-rwlrw- 1 stevens 0 Nov 16 16:23 foo f o o s t a t - -I D - 12. 3 l s - l b a r 4-4 chmod
4 65 4-4 l s 4. 18 c h m o d i ls -l c h m o d ( S _ I S V T X ) m o d e ( ) ( - ) I D 4. 6 I I D I I D I - - I D - - I D 4. 3 + B S D - - I D - - I D - - I D - - I D 4.10 S _ I S V T X U N I X sticky bit ( ) U N I X U N I X - saved-text bit S _ I S V T X U N I X S V R 4 4. 3 + B S D / t m p / v a r / s p o o l / u u c p p u b l i c
6 6 U N I X ( ) P O S I X. 1 S V R 4 4. 3 + B S D 4. 11 chown, fchown l c h o w n c h o w n I D I D #include <sys/types.h> #include <unistd.h> int chown(const char p a t * h n a m e, uid_to w n e r, gid_t g ro u p) ; int fchown(int f i l e d e s, uid_t o w n e r, gid_t g ro u p) ; int lchown(const char p a t * h n a m e, uid_t o w n e r, gid_t g ro u p) ; 0 1 l c h o w n f c h o w n POSIX 1003.1-1990. 1 a S V R 4 4. 3 + B S D f c h o w n S V R 4 l c h o w n S V R 4 ( P O S I X. 1 4. 3 + B S D ) c h o w n p a t h n a m e p a t h n a m e p a t h n a m S V R 4 4. 3 + B S D X P G 3 o w n e r g ro u p 1, I D P O S I X. 1 V _ P O S I X _ C H O W N _ R E S T R I C T E D P O S I X. 1 FIPS 151-1 _ P O S I X _ C H O W N _ R E S T R I C T E D S V R 4 4. 3 + B S D c h o w n 2-5 < u n i s t d. h > p a t h c o n f f p a t h c o n f _ P O S I X _ C H O W N _ R E S T R I C T E D ( 4. 3 + B S D )
4 67 _ P O S I X _ C H O W N _ R E S T R I C T E D (1) I D (2) I D (a) I D I (b) o w n e r I D g ro u p I D I _ P O S I X _ C H O W N _ R E S T R I C T E D I D I D - - I D - - I D 4.12 s t a t s t _ s i z e S V R 4 1 4. 2 0 16 5 12 4. 21 lrwxrwxrwx 1 root 7 Sep 25 07:14 lib -> usr/lib 7 u s r / l i b ( s t _ s i z e C n u l l ) S V R 4 4. 3 + B S D s t _ b l k s i z e s t _ b l o c k s I / O 512 3. 9 s t _ b l k s i z e I / O ( 5 ) s t _ b l k s i z e U N I X s t - b l o c k s 512 3. 6 3-2 $ ls -1 core -rw-r--r-- 1 stevens 8483248 Nov 18 12:18 core $ du -s core 272 core c o r e 8 M d u 272 5 12 (139 264 ) ( d u 1024 S V R 512
6 8 U N I X ) 3. 6 r e a d 0 $ wc -c core 8483248 core I / O - c w c ( 1 ) cat(1), 0 $ cat core > core.copy $ ls -1 core* -rw-r--r-- 1 stevens 8483248 Nov 18 12:18 core -rw-rw-r-- 1 stevens 8483248 Nov 18 12:27 core.copy $ du -s core* 272 core 16592 core.copy 8 495 104 (512 16 592 l s B a c h 1 986 4. 2 L e ff l e r 1 989 7. 2 4.13 0 O _ T R U N C t r u n c a t e f t r u n c a t e #include <sys/types.h> #include <unistd.h> int truncate(const char p a t h * n a m e, off_t l e n g t h) ; int ftruncate(int f i l e d e s, off_t l e n g t h) ; 0 1 p a t h n a m e f i l e d e s l e n g t h l e n g t l e n g t h l e n g t h 0 ( ) S V R 4 4. 3 + B S D P O S I X. 1 X P G 3 S V R 4 4. 3 + B S D U N I X S V R 4 f c n t l P O S I X. 1 F _ F R E E S P,
4 69 12-5 f t r u n c a t e 4.14 i i U N I X S V R 4 U N I X V S 5 U F S 2-6 U F S S V R 4 U N I X V V 7 4-1 i i i i 4-1 i V 7 i 64 4. 3 + B S D i 128 S V R 4 i S5 64 UFS i 128 4-2 i i i i i i i 4-2
7 0 U N I X 4-2 i i 0 ( ) u n l i n k d e l e t e s t a t s t _ n l i n k n l i n k _ t 2-7 P O S I X. 1 L I N K _ M A X symbolic link ( ) lrwxrwxrwx 1 root 7 Sep 25 07:14 lib -> urs/lib l i b 7 u s r / l i b i S _ I F L N K i s t a t i i i i n o _ t i i l n ( 1 ) l i n k i / u s r / l i b / f o o / u s r / f o o / u s r / l i b / u s r f o o m v ( 1 )? $ mkdir testdir 4-3... i i 0 i 1 2 6 7 i 2 5 4 9 i 4-3 testdir
4 71 2549 i 2 ( ) 2 2 t e s t d i r. 1267 i 3 3 ( 4-3 ). t e s t d i r.. 1 U N I X B a c h 1 986 4 L e ffler 1989 7 4.15 link,unlink,remove r e n a m e i l i n k #include <unistd.h> int link(const char e x i * s t i n g p a t h, const char n * e w p a t h) ; 0 1 n e w p a t h e x i s t i n g p a t h n e w p a t h 3.11 S V R 4 4. 3 B S D P O S I X. 1 4. 16 u n l i n k #include <unistd.h> int unlink(const char p a t * h n a m e) ; 0 1 p a t h n a m e 1 4. 10
7 2 U N I X 0 0 4-5 u n l i n k 15 4-5 u n l i n k $ ls -1 tempfile -rw-r--r-- 1 stevens 9240990 Jul 31 13:42 tempfile $ d f / h o m e Filesystem kbytes used avail capacity Mounted on /dev/sd0h 282908 181979 72638 71% / h o m e $ a.out & 4-5 1364 s h e l l I D $ file unlinked ls -1 tempfile tempfile not found $ d f / h o m e Filesystem kbytes used avail capacity Mounted on /dev/sd0h 282908 181979 72638 71% /home $ done d f / h o m e Filesystem kbytes used avail capacity Mounted on /dev/sd0h 282908 172939 81678 68% /home 9. 2 M u n l i n k o p e n c r e a t u n l i n k
4 73 p a t h n a m e u n l i n k p a t h n a m e u n l i n k r m d i r 4. 20 r m d i r r e m o v e r e m o v u n l i n k r e m o v e r m d i r #include <stdio.h> int remove(const char p a t * h n a m e) ; 0 1 ANSI C r e m o v e U N I X u n l i n k, C U N I X r e n a m e #include <stdio.h> int rename(const char o l d * n a m e, const char n * e w n a m e) ; 0 1 ANSI C C P O S I X. 1 o l d n a m e n e w n a m (1) o l d n a m e n e w n a m e n e w n a m e o l d n a m e n e w n a m e o l d n a m e n e w n a m e (2) o l d n a m e n e w n a m... n e w n a m e o l d n a m e n e w n a m e n e w n a m e o l d n a m e / u s r / f o o / u s r / f o o / t e s t d i r / u s r / f o o (3) o l d n a m e n e w n a m e n e w n a m e o l d n a m e n e w n a m e o l d n a m n e w n a m e 4.16
7 4 U N I X i ( a ) ( b ) 4. 2 B S D S V R 4 S V R 4 V ( S 5 ) ( U F S ) POSIX 1003.1-1990. 1 a 4-7 r m d i r p a t h 4-7 o p e n fstat, fchmod c h o w n 4. 11 4-7 a c c e s s c h d i r c h m o d c h o w n c r e a t e x e c l c h o w n l i n k l s t a t m k d i r m k f i f o m k n o d o p e n o p e n d i r p a t h c o n f r e a d l i n k r e m o v e r e n a m e s t a t t r u n c a t e u n l i n k
4 75 E L O O P e r r n o $ mkdir foo $ touch foo/a 0 $ ln -s../foo foo/testdir $ ls -1 foo total 1 -rw-rw-r-- 1 stevens 0 Dec 6 06:06 a lrwxrwxrwx 1 stevens 6 Dec 6 06:06 testdir ->../foo f o o a f o o 4-4 ftw(3) f o o f o o / a f o o / t e s t d i r f o o / t e s t d i r / a f o o / t e s t d i r / t e s t d i r f o o / t e s t d i r / t e s t d i r / a f o o / t e s t d i r / t e s t d i r / t e s t d i r f o o / t e s t d i r / t e s t d i r / t e s t d i r / a ftw returned -1:Too many levels of symbolic links 4. 21 f t w l s t a t s t a t u n l i n k u n l i n k f o o / t e s t d i r l i n k 4-4 t e s t d i r o p e n o p e o p e n o p e n $ ln -s /no/such/file myfile $ ls myfile m y f i l e l s $ cat myfile cat: myfile: No such file or directory $ ls -1 myfile - l lrwxrwxrwx 1 stevens 13 Dec 6 07:27 myfile -> /no/such/file m y f i l e c a t m y f i l e f s c k ( 1 ) c l r i ( 8 ) d c h e c k ( 8 )
7 6 U N I X l s - l > l s - F @ - l 4.17 symlink r e a d l i n k s y m l i n k #include <unistd.h> int symlink(const char a c t * u a l p a t h, const char s * y m p a t h) ; 0 1 a c t u a l p a t h s y m p a t h a c t u a l p a t h a c t u a l p a t h s y m p a t h o p e n r e a d l i n k #include <unistd.h> int readlink(const char p a t h * n a m e, char *b u f, int b u f s i z e) ; 1 open, read c l o s e b u f b u f n u l l 4.18 4-8 4-8 l s ( 1 ) s t _ a t i m e s t _ m t i m e s t _ c t i m e r e a d w r i t e i chmod, chown - u - c ( s t _ m t i m e ) ( s t _ c t i m e ) i i I D i i a c c e s s s t a t
4 77 a. o u t c o r e f i n d ( 1 ) i l s ( - l - t ) - u - c 4-9 4. 14 i 4-9 ( ) i i m k d i r r m d i r 4. 20 u t i m e 6 e x e c 4. 20 14 m k f i f o p i p e 4-9 a m c a m c chmod,fchmod chown,fchown creat O_CREAT creat O_TRUNC exec lchown link mkdir mkfifo open O_CREAT open O_TRUNC pipe read remove = unlink remove = rmdir rename rmdir truncate,ftruncate unlink utime w r i t e
7 8 U N I X 4.19 utime u t i m e #include <sys/types.h> #include <utime.h> int utime(const char p a t * h n a m e, const struct utimbuf t i m e * s) ; 0 1 struct utimbuf { time_t actime; time_t modtime; } /*access time*/ /*modification time*/ 1. 10 1970 1 1 00 : 00 : 00 t i m e s N U L L (1) t i m e s ( a ) I D I D ( b ) (2) t i m e s t i m e I D I D s t _ c t i m e u t i m e U N I X t o u c h ( 1 ) t a r ( 1 ) c p i o ( 1 u t i m e, 4-6 O _ T R U N C o p e n 0 s t a t u t i m e 4-6 utime
4 79 4-6 $ ls -1 changemod times -rwxrwxr-x 1 stevens 24576 Dec 4 16:13 changemod -rwxrwxr-x 1 stevens 24576 Dec 6 09:24 times $ ls -lu changemod times -rwxrwxr-x 1 stevens 24576 Feb 1 12:44 changemod -rwxrwxr-x 1 stevens 24576 Feb 1 12:44 times $ d a t e Sun Feb 3 18:22:33 MST 1991 $ a.out changemod times 4-6 $ ls -1 changemod times -rwxrwxr-x 1 stevens 0 Dec 4 16:13 changemod -rwxrwxr-x 1 stevens 0 Dec 6 09:24 times $ ls -lu changemod times -rwxrwxr-x 1 stevens 0 Feb 1 12:44 changemod -rwxrwxr-x 1 stevens 0 Feb 1 12:44 times $ ls -lc changemod times -rwxrwxr-x 1 stevens 0 Feb 3 18:23 changemod -rwxrwxr-x 1 stevens 0 Feb 3 18:23 times t a r 4.20 mkdir r m d i r m k d i r r m d i r #include <sys/types.h> #include <sys/stat.h> int mkdir(const char p a t * h n a m e, mode_t m o d e) ; 0 1
8 0 U N I X... m o d e mode ( ) 1 4. 18 4. 6 I D I D S V R 4 - - I D I D 4. 3 + B S D - - I D - - I D I D U N I X m k d i r 4. 2 B S D S V R 3 m k n o d m k n o d m k d i r ( 1 ) - - I D s y s t e m ( 3 ) m k d i r ( 1 ) r m d i r #include <unistd.h> int rmdir(const char p a t * h n a m e) ; 0-1 0 0... r m d i r 4.21 4. 5 U N I X V 7 16 14 2 i 4. 2 B S D U N I X P O S I X. 1 #include <sys/types.h> #include <dirent.h> DIR *opendir(const char p a t h * n a m e) ;
4 81 N U L L struct dirent *readdir(dir d p) ;* N U L L void rewinddir(dir d p) *; int closedir(dir d p) * ; 0 1 1-1 l s < d i r e n t. h > d i r e n t S V R 4 4. 3 + B S D struct dirent { ino_t d_ino; /*i-node number*/ char d_name N A M E _ M A X + 1 ; /*null-terminated filename*/ } P O S I X. 1 d _ i n o, P O S I X. 1 d _ n a m e S V R 4 N A M E _ M A X f p a t h c o n f B S D N A M E _ M A X 255 2-7 n u l l d _ n a m e D I R F I L E F I L E I / O 5 o p e n d i r D I R o p e n d i r r e a d d i r 4-2 4-7 V f t w ( 3 ) s t a t r o o t / l i b / u s r / l i b, / u s r / l i b S V R 4 n f t w ( 3 ) n f t w 4-7
8 2 U N I X
4 83
8 4 U N I X f t w m y f u n c 0 U N I X find, ls, tar F o w l e r, K o r n Vo 1 9894. 3 + B S D fts (3) 4.22 chdir, fchdir getcwd ( ) U N I X (/ e t c / p a s s w d ) 6 c h d i r f c h d i r #include <unistd.h> int chdir(const char p a t * h n a m e) ; int fchdir(int f i l e d e s) ; 0 1 p a t h n a m e f c h d i r P O S I X. 1 S V R 4 4. 3 + B S D c h d i r 8 4-8 4-8 $ p w d / u s r / l i b $ m y c d chdir to /tmp succeeded $ p w d / u s r / l i b m y c d s h e l l s h e l c h d i r c d s h e l l
4 85 i 4-8 chdir i i g e t c w d # i n c l u d e < u n i s t d. h > char *getcwd(char b u * f, size_t s i z e); buf, N U L L b u f s i z e n u l l 2. 5. 7 g e t c w d b u f N U L L m a l l o c s i z e P O S I X. 1 X P G 3 4-9 g e t c w d, $ a. o u t cwd = /var/spool/uucppublic $ ls -1/usr/spool lrwxrwxrwx 1 root 12 Jan 31 07:57 /usr/spool ->../var/spool 4-9 getcwd
8 6 U N I X c h d i r 4-7 g e t c w d / v a r / s p o o l / u s r / s p o o l 4.23 s t _ d e v s t _ r d e v 11. 9 t t y n a m e d e v _ t 4-1 m a j o r m i n o r d e v _ t 16 8 8 S V R 4 32 14 18 4. 3 + B S D 16 8 8 P O S I X. 1 d e v _ t m a j o r m i n o r s t _ d e v i s t _ r d e v 4-10 s t _ r d e v 4-10 s t _ d e v s t _ r d e v
4 87 S V R 4 m a j o r m i n o r < s y s / s y s m a c r o s. h > $ a.out / /home/stevens /dev/tty[ab] /: dev = 7/0 /home/stevens: dev = 7/7 /dev/ttya: dev = 7/0 (character) rdev = 12/0 /dev/ttyb: dev = 7/0 (character) rdev = 12/1 $ mount /dev/sd0a on / /dev/sd0h on /home $ ls -1 /dev/sd0[ah] /dev/tty[ab] brw-r----- 1 root 7, 0 Jan 31 08:23 /dev/sd0a brw-r----- 1 root 7, 7 Jan 31 08:23 /dev/sd0h crw-rw-rw- 1 root 12, 0 Jan 31 08:22 /dev/ttya crw-rw-rw- 1 root 12, 1 Jul 9 10:11 /dev/ttyb / h o m e / s t e v e n s / d e v / t t y [ a b ] / h o m e / s t e v e n s m o u n t ( 1 ) l s m o u n t C D - R O M U N I X s t _ d e v i 7 / 0 / d e v 12 / 0 1 2 / 1 4.24 sync f s y n c U N I X I / O I / O delayed writebach 1 986 3
8 8 U N I X U N I X s y n c f s y n c #include <unistd.h> void sync(void); int fsync(int f i l e d e s) ; 0 1 s y n c I / O ( u p d a t e ) 30 s y n c s y n c ( 1 ) s y n c f s y n c ( f i l e d e s ) I / O f s y n c f s y n c O _ S Y N C ( 3. 13 ) f s y n c O _ S Y N C w r i t e S V R 4 4. 3 + B S D s y n c f s y n c, P O S I X. 1 X P G 3 f s y n c 4.25 4-10 4-10 S _ I S U I D S _ I S G I D - - I D I D - - I D I D I D I D S _ I S V T X S _ I S U S R S _ I W U S R S _ I X U S R S _ I R G R P S _ I W G R P S _ I X G R P S _ I R O T H S _ I W O T H S _ I X O T H 9 3
4 89 S_IRWXU = S_IRUSR S _ I W U S R S _ I X U S R S_IRWXG = S_IRGRP S _ I W G R P S _ I X G R P S_IRWXO = S_IROTH S _ I W O T H S _ I X O T H 4.26 s t a t s t a t U N I X U N I X 4. 1 stat 4-1 lstat 4. 2 4-1 S V R 4 S _ I S L N K S V R 4 < s y s / s t a t. h > S _ I F L N K o u r h d r. h S _ I S L N K 4. 3 777 u m a s k 4. 4 4. 5 f o o b a r 4-3 4. 6 4. 12 0 st_size 0 4. 7 cp(1) 0 4. 8 4. 12 l s c o r e c o r e. c o p y u m a s k 4. 9 4-5 d f ( 1 ) d u ( 1? 4. 10 4-9 u n l i n k 4. 11 4. 21 m y f t w 4. 12 4. 21 ftw c h d i r l s t a t chdir ("..") 4. 13 c h r o o t 4. 14 u t i m e 4. 15 f i n g e r ( 1 ) New mail received... unread since...... 4. 1 6 c p i o ( 1 ) t a r ( 1 ) 4. 1 7 f i l e ( 1 ) C F o r t r a n s h e l l U N I X S V R 4 t r u s s ( 1 ) 4. 3 + B S D k t r a c e ( 1 ) k d u m p ( 1 ) S u n O S t r a c e ( 1 ) f i l e trace file a.out f i l e
9 0 U N I X lstat ("a.out", 0xf7fff650) = 0 open ("a.out", 0, 0) = 3 read (3,"".., 512) = 512 fstat (3,0xf7fff160) = 0 write (1, "a.out: demand paged execu".., 44) = 44 a.out: demand paged executable not stripped utime ("a.out", 0xf7fff1b0) = 0 f i l e u t i m 4. 1 8 U N I X PAT H _ M A X g e t c w d U N I X t a r c p i o 4. 19 3. 15 / d e v / f d r w - r w - r w - unlink (path); if ( (fd = creat(path, FILE_MODE)) < 0) e r r _ s y s (...); p a t h / d e v / f d / 1