add directory Linux-0.12
This commit is contained in:
103
Linux-0.12/sources/sbin/df.c
Normal file
103
Linux-0.12/sources/sbin/df.c
Normal file
@@ -0,0 +1,103 @@
|
||||
/* df.c: Copywrite (92) Peter MacDonald: distribute freely, don't restrict. */
|
||||
|
||||
#include <sys/time.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include <stdio.h>
|
||||
#include <linux/fs.h>
|
||||
|
||||
char *hdr1="\n inodes inodes inodes blocks blocks blocks mount";
|
||||
char *hdr2= "device total used free total used free point";
|
||||
char *hdr3= "--------------------------------------------------------------------";
|
||||
char *fmt = "%-9s %-7d %-7d %-7d %-7d %-7d %-7d %s\n";
|
||||
|
||||
void do_df(char *dev, char *dir);
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{ int i;
|
||||
|
||||
sync();
|
||||
puts(hdr1);
|
||||
puts(hdr2);
|
||||
puts(hdr3);
|
||||
if (argc != 1)
|
||||
for (i=1; i<argc; i++)
|
||||
do_df(argv[i],"");
|
||||
else
|
||||
{ FILE *F = fopen("/etc/mtab","r");
|
||||
if (!F)
|
||||
{ fprintf(stderr,"/etc/mtab not found\n");
|
||||
exit(1);
|
||||
}
|
||||
do
|
||||
{ char buf[200], dev[40], dir[150];
|
||||
fgets(buf,200,F);
|
||||
if (feof(F) || (strlen(buf)<6))
|
||||
break;
|
||||
sscanf(buf,"%s %s",dev,dir);
|
||||
do_df(dev,dir);
|
||||
} while (1);
|
||||
}
|
||||
exit(0);
|
||||
}
|
||||
|
||||
|
||||
#define oops(str,arg) { fprintf(stderr,str,arg); close(fd); return; }
|
||||
|
||||
int fd;
|
||||
int nibblemap[] = { 0,1,1,2,1,2,2,3,1,2,2,3,2,3,3,4 };
|
||||
|
||||
ino_t count(unsigned numblocks, unsigned numbits)
|
||||
{ unsigned i, j, end, sum = 0;
|
||||
char buf[BLOCK_SIZE];
|
||||
|
||||
for (i=0; (i<numblocks) && numbits; i++)
|
||||
{
|
||||
if (read(fd,buf,sizeof(buf))<0)
|
||||
return(0);
|
||||
if (numbits >= (8*BLOCK_SIZE))
|
||||
{
|
||||
end = BLOCK_SIZE;
|
||||
numbits -= 8*BLOCK_SIZE;
|
||||
}
|
||||
else
|
||||
{ int tmp;
|
||||
end = numbits >> 3;
|
||||
numbits &= 0x7;
|
||||
tmp = buf[end] & ((1<<numbits)-1);
|
||||
sum += nibblemap[tmp&0xf] + nibblemap[(tmp>>4)&0xf];
|
||||
numbits = 0;
|
||||
}
|
||||
for (j=0; j<end; j++)
|
||||
sum += nibblemap[buf[j] & 0xf] + nibblemap[(buf[j]>>4)&0xf];
|
||||
}
|
||||
return(sum);
|
||||
}
|
||||
|
||||
void do_df(char *dev, char *dir)
|
||||
{ int it,iu,bt,bu;
|
||||
struct super_block supstruct;
|
||||
|
||||
if ((fd=open(dev,O_RDONLY))<0)
|
||||
oops("df can't open device: %s",dev);
|
||||
|
||||
lseek(fd,BLOCK_SIZE,SEEK_SET);
|
||||
if (read(fd,(char*)&supstruct,sizeof(struct super_block))
|
||||
!= sizeof(struct super_block))
|
||||
oops("super block unreadable: %s",dev);
|
||||
|
||||
lseek(fd,BLOCK_SIZE*2,SEEK_SET);
|
||||
if (supstruct.s_magic != SUPER_MAGIC)
|
||||
oops("not a valid file system: %s",dev);
|
||||
|
||||
it = supstruct.s_ninodes;
|
||||
iu = count(supstruct.s_imap_blocks,supstruct.s_ninodes+1);
|
||||
|
||||
bt = supstruct.s_nzones << supstruct.s_log_zone_size;
|
||||
bu = count(supstruct.s_zmap_blocks,supstruct.s_nzones) <<
|
||||
supstruct.s_log_zone_size;
|
||||
|
||||
printf(fmt,dev,it,iu,it-iu,bt,bu,bt-bu,dir);
|
||||
}
|
||||
BIN
Linux-0.12/sources/sbin/fd.tar.Z
Normal file
BIN
Linux-0.12/sources/sbin/fd.tar.Z
Normal file
Binary file not shown.
BIN
Linux-0.12/sources/sbin/fdisk.scsi.tar.Z
Normal file
BIN
Linux-0.12/sources/sbin/fdisk.scsi.tar.Z
Normal file
Binary file not shown.
27
Linux-0.12/sources/sbin/hostname.c
Normal file
27
Linux-0.12/sources/sbin/hostname.c
Normal file
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
* Set or display hostname. Jeff Comstock - Bloomington, MN USA 1992
|
||||
* Usage: hostname [name]
|
||||
* Only root may change the hostname.
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
|
||||
main(int argc, char **argv) {
|
||||
struct utsname uts;
|
||||
|
||||
if ( argc == 2 ) {
|
||||
if ( sethostname(argv[1],strlen(argv[1]))) {
|
||||
perror("sethostname");
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (uname(&uts)) {
|
||||
perror("uname");
|
||||
exit(1);
|
||||
}
|
||||
else
|
||||
puts(uts.nodename);
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
BIN
Linux-0.12/sources/sbin/mount.c.Z
Normal file
BIN
Linux-0.12/sources/sbin/mount.c.Z
Normal file
Binary file not shown.
BIN
Linux-0.12/sources/sbin/mylogin3.tar.Z
Normal file
BIN
Linux-0.12/sources/sbin/mylogin3.tar.Z
Normal file
Binary file not shown.
BIN
Linux-0.12/sources/sbin/poeigl-1.2.tar.Z
Normal file
BIN
Linux-0.12/sources/sbin/poeigl-1.2.tar.Z
Normal file
Binary file not shown.
BIN
Linux-0.12/sources/sbin/ps012.tar.gz
Normal file
BIN
Linux-0.12/sources/sbin/ps012.tar.gz
Normal file
Binary file not shown.
BIN
Linux-0.12/sources/sbin/qpl-init.tar.Z
Normal file
BIN
Linux-0.12/sources/sbin/qpl-init.tar.Z
Normal file
Binary file not shown.
BIN
Linux-0.12/sources/sbin/shadow-src.tar.Z
Normal file
BIN
Linux-0.12/sources/sbin/shadow-src.tar.Z
Normal file
Binary file not shown.
BIN
Linux-0.12/sources/sbin/shoelace.tar.Z
Normal file
BIN
Linux-0.12/sources/sbin/shoelace.tar.Z
Normal file
Binary file not shown.
BIN
Linux-0.12/sources/sbin/stty.tar.Z
Normal file
BIN
Linux-0.12/sources/sbin/stty.tar.Z
Normal file
Binary file not shown.
BIN
Linux-0.12/sources/sbin/swapon.tar.Z
Normal file
BIN
Linux-0.12/sources/sbin/swapon.tar.Z
Normal file
Binary file not shown.
BIN
Linux-0.12/sources/sbin/system-0.12.tar.Z
Normal file
BIN
Linux-0.12/sources/sbin/system-0.12.tar.Z
Normal file
Binary file not shown.
BIN
Linux-0.12/sources/sbin/umount.c.Z
Normal file
BIN
Linux-0.12/sources/sbin/umount.c.Z
Normal file
Binary file not shown.
72
Linux-0.12/sources/sbin/uname.c
Normal file
72
Linux-0.12/sources/sbin/uname.c
Normal file
@@ -0,0 +1,72 @@
|
||||
/*
|
||||
* uname - print system information. Jeff Comstock - Bloomington, MN USA 1992
|
||||
* Usage: uname [-asnrvm]
|
||||
* -s prints system name
|
||||
* -n prints nodename
|
||||
* -r prints software release
|
||||
* -v prints os version
|
||||
* -m prints machine name
|
||||
* -a prinst all the above information
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <getopt.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#define SYSNAME 0
|
||||
#define NODENAME 1
|
||||
#define RELEASE 2
|
||||
#define VERSION 3
|
||||
#define MACHINE 4
|
||||
|
||||
struct utsname u;
|
||||
|
||||
struct utstab {
|
||||
char *str;
|
||||
int requested;
|
||||
} uttab[] = {
|
||||
{ u.sysname, 0 },
|
||||
{ u.nodename, 0 },
|
||||
{ u.release, 0 },
|
||||
{ u.version, 0 },
|
||||
{ u.machine, 0 }
|
||||
};
|
||||
|
||||
main(int argc, char **argv) {
|
||||
char *opts="amnrsv";
|
||||
register int c,space, all=0;
|
||||
|
||||
if ( ! uname(&u) ) {
|
||||
if ( argc == 1 ) {
|
||||
puts(u.sysname);
|
||||
} else {
|
||||
while ( (c = getopt(argc,argv,opts)) != -1 ) {
|
||||
switch ( c ) {
|
||||
case 'a' : all++;
|
||||
break;
|
||||
case 'm' : uttab[MACHINE].requested++;
|
||||
break;
|
||||
case 'n' : uttab[NODENAME].requested++;
|
||||
break;
|
||||
case 'r' : uttab[RELEASE].requested++;
|
||||
break;
|
||||
case 's' : uttab[SYSNAME].requested++;
|
||||
break;
|
||||
case 'v' : uttab[VERSION].requested++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
space=0;
|
||||
for(c=0; c <= MACHINE; c++) {
|
||||
if ( uttab[c].requested || all ) {
|
||||
if ( space )
|
||||
putchar(' ');
|
||||
printf("%s", uttab[c].str);
|
||||
space++;
|
||||
}
|
||||
}
|
||||
puts("");
|
||||
}
|
||||
}
|
||||
else
|
||||
perror("uname");
|
||||
}
|
||||
BIN
Linux-0.12/sources/sbin/virtcons.tar.Z
Normal file
BIN
Linux-0.12/sources/sbin/virtcons.tar.Z
Normal file
Binary file not shown.
BIN
Linux-0.12/sources/sbin/vixie-cron.tar.Z
Normal file
BIN
Linux-0.12/sources/sbin/vixie-cron.tar.Z
Normal file
Binary file not shown.
BIN
Linux-0.12/sources/sbin/vp.tar.Z
Normal file
BIN
Linux-0.12/sources/sbin/vp.tar.Z
Normal file
Binary file not shown.
BIN
Linux-0.12/sources/sbin/vt100.tar.Z
Normal file
BIN
Linux-0.12/sources/sbin/vt100.tar.Z
Normal file
Binary file not shown.
Reference in New Issue
Block a user