, - 0, . , fd048, fd0. - , fd048ds9 mntf. 17 -1 1 0. 18-22 , - . - , - . mntf - 1 /mnt1, /mnt. /mnt1 , /mnt, , 1. - . - . , , /mnt, /mnt1. 23 , -r, - -r . , shell , -r , -r . 24 -s SYSTEM sysv. , . 25-34 . - , , , , case (*), - . , . 39-42 . case SYSTEM. - "sysv", 40. - 41 XENIX. , - mntf sysv - . System V, , . 41 , XENIX. CMD , , (mount) (umount). /dev/fd . DRIVE 0 1. DENSITY . - , DIR . - , DIR .   (root) . . . , . , : # chown root /etc/mount <- root /etc/mount # chmod 4511 /etc/mount mount # chown root /etc/umount <- # chmod 4511 /etc/umount , . -- (. 9), ! -------------------------------------------------------------- : mntlook -------------------------------------------------------------- mntlook  - , .   mntlook   mntlook /dev/hd*   1 static char id[] = "@(#) mntlook v1.0 Look for mounts Author: Russ Sage"; 3 #include 4 #include 5 #include 6 #include 7 #include 9 #define BSIZ 512 11 main(argc,argv) 12 int argc; 13 char *argv[]; 14 { 15 struct filsys sb; 16 int d, dev; 17 char buf[BSIZ]; 19 for (d = 1; d < argc; d++) 20 { 21 if (argv[d][0] == '-') 22 { 23 printf("mntlook: invalid argument %s\n", argv[d]); 24 printf("usage: mntlook device [device ...]\n"); 25 continue; 26 } 27 if ((dev = open(argv[d],O_RDONLY)) < 0) 28 { 29 sprintf(buf, "cannot open %s",argv[d]); 30 perror(buf); 31 continue; 32 } 34 /* throw away first block */ 35 if (read(dev, &sb, sizeof(sb)) == -1) 36 { 37 perror("cannot read block 0"); 0 38 continue; 39 } 41 /* block 1 is the superblock */ 1 42 if (read(dev, &sb, sizeof(sb)) == -1) 43 { 44 perror("cannot read block 1"); 1 45 continue; 46 } 48 if (sb.s_magic == S_S3MAGIC) 49 { 50 printf("\nDEV: %s --> VALID file system\n",argv[d]); 51 printf("filsys: %s\n",sb.s_fname); 52 printf("pack : %s\n",sb.s_fpack); 53 printf("type : %s byte block\n", 54 (sb.s_type == S_B512) ? "512" : "1024"); 55 printf("magic : %lx\n",sb.s_magic); 56 } 58 close(dev); 59 } 60 }  mntlook? UNIX. , . , , UNIX . , , - . . , - . , . mntlook? mntlook . ( ). , , , " ". , . , , , , . , , . , - . . UNIX - - . ( ) . , . , - , . , , , . System V - update, - . , , , "od -c /dev /rfd0", - . , - , "cp file /dev/rfd0". . tar, cpio . "mount /dev/fd0 /mnt". , - /mnt. , , , - . mntlook . . , . , . " ", . - , filsys.h, #include. , - . , , , , - . . , , - . , - , . , , , - . 9, - , - , - .  1. $ mntlook /dev/hd13 hd13. 1, . XENIX - fdisk. System V - iv. 2. $ mntlook /dev/fd0* , 0. XENIX. 3. $ for DEV in /dev/*[fh]d* > do > echo "checking device: $DEV" > mntlook $DEV > done . . - , .  3-7 , . , , , . 9 . - , - . 15 . filesys (. sys/types.h). - 1024 . , - , : printf ("the size is %d",sizeof(sb)) 16 d dev. 17 BSIZE. 19-59 - for. . , . - 1, argv[0] . , . 21-26 , - '-'. , , , continue . , , . , , 27-32 . open - , , - . (), . , - . continue - for. 35-39 . . - , . 42-46 , , , . , - , . 48 , - , . , mntlook , , ( ), , . 53-54 : printf if-then-else , - . , - , 512. "", - 1024. B.W.Kernighan, D.M.Ritchie "The C Programming Language" (Prentice-Hall, 1978). 58 , .   , , , . , . , - UNIX , UNIX . , - , , , , . , , (.. ), , . . - , , , .   System V AT&T - UNIX. , System V , UNIX. , UNIX . , - . 512 - . . UNIX 512- , , , - , . , UNIX ! 1024 . 512- , 1024 . , - 512- , - 1024-, - , . - , , . , . 7-3 - , . - System V VAX, System V XENIX. , . , - 512 , , , 1024- . UNIX , , . , - vi ( /tmp ), - vi . (- , 20 ) . 7-3 UNIX ------------------------------------------------------------- 512 / 1024 / ------------------------------------------------------------- ls -s fdisk ( ) sum mkfs cpio fsck df du ------------------------------------------------------------- ,  , - , - . - , . , - . . , . . fsck - , - , , , .. ? , - . -, . , . , /, 1 1382 . , , . - , . 20 XENIX/DOS. : 1 = 615 , 615 / 1 = 4 (), 4 / : 1 = 17 , 17 / 1 = 512 , 512 / 1 = 1024 = 2^10 1 = 1024 = 2^20 = 1 048 576 , - . . 7-4 - . 7-4 -------------------------------------------------------------- -------------------------------------------------------------- 981 3 25 697 5 30 981 5 42 925 7 55 1024 8 71 --------------------------------------------------------------- , - . . . 615 4 17 512 ------- * ----- * ------ * -------- = 21 411 840 / 1 1 1 1 21411840 1 ------------- * ------------ = 20.4 / 1 1048576 , , , , . - , , - , /. , - ( " ") , , . , . , . , , - . , . - - . : , , = , , = . - //, . //, - . , - , . , - . , - , . , UNIX. - , , - , UNIX . 1. ? 615 4 : ------- * ----- = 2460 / 1 1 2. ? 17 512 : ------ * -------- = 8704 / 1 1 3. ? 2460 1 : -------- * ------ = 123 / 1 20 4. ? 1 2460 : ----- * -------- = 30 /, 4 20 615 1 123 ------- * -------- * ------- = 30 / 1 2460 1 5. 47, 2, 4. - ? : , . , . - ? , - , , 4 4 : 4 17 17 47 * ----- * ------ + 2 * ------ + 4 = 1 1 1 = 3196 + 34 + 4 = = 3234   UNIX , . , , - " ", - . - UNIX, - , . , . "" . - . - , . UNIX - (inodes). , , - , - , .. , - ulimit (user limit - ). 512 , . shell' ulimit, . - ulimit. (root) ulimit. ulimit , . ulimit shell, , . , ulimit 0, ! - , . , , - . , ulimit , . , ulimit - . . - ulimit ulimit, shell. shell ulimit. , shell, ulimit, - inittab ( ), . , ulimit shell . , . 1 #include 2 #include 4 main() 5 { 6 long v1, v2, v3, newlimit = 5120; 8 v1 = (long)ulimit(UL_GFILLIM, 0L); 9 v2 = (long)ulimit(UL_SFILLIM,newlimit); 10 v3 = (long)ulimit(UL_GFILLIM, 0L); 12 printf("v1: %ld v2: %ld ulim: %ld\n",v1,v2,v3); 13 setuid(getuid()); 14 execl("/bin/sh","ulimit sh", 0); 15 } ulimit ulimit. ulimit 8 . v1. 9 ulimit newlimit. , v2 - -1, , - 12. , ulimit, . 10 ulimit. , , , ulimit. 13 - , - . , , - shell, , - . , , - . ( , - "" - 9 .) 14 shell. shell "ulimit sh". , - "ps -ef". shell ulimit. ulimit - . . , , - , . , . ------------------------------------------------------------- : umntsys ------------------------------------------------------------- umntsys  , - .   umntsys   umntsys   1 : 2 # @(#)umntsys v1.0 Unmount all file systems Author: Russ Sage 4 if [ "$#" -gt 0 ] 5 then echo "umntsys: too many arguments" >&2 6 echo "usage: umntsys" >&2 7 exit 1 8 fi 10 /etc/mount | sed -n -e '/^\/ /d' -e 's/^.* on \(.*\) read.*/umount \1/p' | sh -  umntsys? , . , , , . - - . , , , , - . , " " . (run level) UNIX , . , , - . , , - /etc/inittab. (, 6), ( S). - , - . ( /dev/root, /dev/hd0a ..). . - , - /etc/rc. kill . umntsys - . umntsys? umntsys - , - . , . .  umntsys - . , - . , , - , . 10. - . mount . mount - . : ----------------------- | | / on /dev/hd0a read/write on Mon Jan 06 09:53:03 1986 | /tmp on /dev/hd01 read/write on Mon Jan 06 09:53:03 1986 | /usr on /dev/hd02 read/write on Mon Jan 06 09:53:03 1986 | /u1 on /dev/hd03 read/write on Mon Jan 06 09:53:03 1986 | /u2 on /dev/hd04 read/write on Mon Jan 06 09:53:03 1986 | /u3 on /dev/hd05 read/write on Mon Jan 06 09:53:03 1986 | /mnt on /dev/fd01 read/write on Mon Jan 06 09:54:41 1986 | , , . , - . - umount. - sed. sed -n, - , , . , - . - - , . "/", - . sed - : " ( , ) . , ". . . - , . ( ) \n. , , sed'. - : " , - , `on'; , `read' ". - , . . "umount", , - 1, , - . - ( ) - . : ------------------- | | umount /dev/hd0a | umount /dev/hd01 | umount /dev/hd02 | umount /dev/hd03 | umount /dev/hd04 | umount /dev/hd05 | umount /dev/fd01 | shell ("sh -"). "-" shell, , umount, - . . ------------------------------------------------------------ : lrgf ------------------------------------------------------------ lrgf  , .   lrgf   lrgf   1 char id[] = "@(#) lrgf v1.0 Create the largest file Author: Russ Sage 3 #include 4 #include 5 #include 6 #include 8 #define FSIZ 512 9 #define BSIZ 1024 11 long ulimit(); 12 char buf[BSIZ]; 14 main() 15 { 16 register int n, fd, bcnt; 17 char file[FSIZ]; 19 for (bcnt=0; bcnt