add directory Linux-0.12

This commit is contained in:
gohigh
2024-02-19 00:21:02 -05:00
parent 26e015eb99
commit 059f8848b1
177 changed files with 15195 additions and 0 deletions

View File

@@ -0,0 +1,10 @@
curses.tar.Z contains the curses library from bsd-net-2, with
pre-installed diffs & RCS files for linux changes.
You'll need to use 'pmake' to build it, or reconstruct the Makefile.
I'm not completely certain that I got all of the raw(), crmode() etc
stuff right. If you have applications that use curses, try them out and
send back patches if you find bugs.
John Kohl <jtkohl@cs.berkeley.edu>

Binary file not shown.

View File

@@ -0,0 +1,49 @@
Reply-To: obz@sisd.sisd.Kodak.COM
Date: Tue, 28 Jan 1992 15:54:57 +0200
From: obz@sisd.sisd.Kodak.COM (Orest Zborowski COMP)
Sender: linux-activists-request@joker.cs.hut.fi
To: linux-activists@joker.cs.hut.fi
Subject: libcurses patch
hi-
we don't have news posting working quite right (or at all) at our
site but i couldn't wait any longer. i have a fun yahtzee program (good as
a short break between hacking) which makes pretty good use of the libcurses
library on tsx-11. the problem with that library is that it was missing
the fwopen() call, which apparently creates a special FILE which does
output through the curses window vectors. i made the small change to
make it use vsprintf instead and avoid the non-portable FILE creation
code.
zorst (orest zborowski)
obz@sisd.kodak.com
---cut here---
*** printw.c.ORIG Sat Jan 25 06:19:45 1992
--- printw.c Sat Jan 25 06:26:19 1992
***************
*** 131,141 ****
#endif
va_list ap;
{
! FILE *f;
! extern FILE *fwopen();
! if ((f = fwopen((void *)win, _winwrite)) == NULL)
return ERR;
! (void) vfprintf(f, fmt, ap);
! return fclose(f) ? ERR : OK;
}
--- 131,140 ----
#endif
va_list ap;
{
! char buf[1024];
! vsprintf(buf, fmt, ap);
! if (_winwrite(win, buf, strlen(buf)))
return ERR;
! return OK;
}
---cut here---

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View 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);
}

Binary file not shown.

Binary file not shown.

View 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);
}

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View 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");
}

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -0,0 +1,186 @@
From: db1@ukc.ac.uk (D.Bolla)
Newsgroups: alt.os.linux
Subject: Patches to have reboot and /dev/kmem working
Summary: How to add a syscall. And various considerations
Message-ID: <5375@falcon.ukc.ac.uk>
Date: 22 Feb 92 13:50:56 GMT
Sender: db1@ukc.ac.uk
Organization: Computing Lab, University of Kent at Canterbury, UK.
Lines: 174
Hello
This time I have some small solutions :-)
The first one is the implentation of the reboot syscall.
The syscall just does a reboot after having checked that you are root.
The old method does not work anymore ( CTRL-ALT-DEL )
The second is an implementation of the /dev/kmem. Most of the code is
done by linux. I just added FEW lines in the right place ( I hope ).
The point is that with this /unix and nlist(3) it is possible to get
all information we need from the kernel WITHOUT having to add code to the
kernel.
It seems to me that people who complain about "normal users cannot read
/dev/kmem" and "A library to read kernel data is not nice" don't have a
clear idea about what /dev/kmem is used for.
When you look in /dev/kmem you look for VERY special information about
the system. I am not sayng that normal user should be denied ps :-)
but if you think, normal users use ps just to see what others are doing
( The same thing for w )
Anyway.... under Sun there are three programs that "look" into /dev/kmem
ps, w, pstats. The amount of information you can get out of them is very
big. The point that I am tryng to make here is:
To obtain the same amount of information from syscalls you need a
GREAT number of variations and parameters. Is this worth the work ?
( Considering the small amount of programs that need that information )
Again.....
Negative points of kernel implementation.
1) Extra (Unnecessary) code in the kernel -> Kernel bigger.
2) Possible introduction of ERRORS -> Kernel panic.
3) Increased number of syscall and paramentrs -> Complexity
4) Problems on returning lists of data in user space
To me point 2 is already enough NOT to use this method. If you can live
with possible kernel panics.......
Positive points of a library implementation.
1) NO extra code in the kernel. -> Save memory
2) Impossibility to add ERRORS to the kernel code. -> NO panic
3) Easy to update, modify even by average user.
4) No problems in allcating memory for the result.
What it is important is to DEFINE what information we want to
extract from /dev/kmem and who can use them. After that is defined it
is possible to discuss about implementaion.
And now to the code :-)
-----------------------------------------------------------------
I decided to put the actual routine that does reboot into
kernel/sys.c Probably your sys.c may be different....
522a523,533
> /* This function reboots the system if the current UID is root
> * No sync is performed. The optional flag is not used yet
> * The called routine is in kernel/chr_drv/keyboard.S
> */
> int sys_reboot ( int flag )
> {
> if (!suser())
> return (-EPERM);
> __asm__("call _hard_reset;" );
> return (0);
> }
The next step is to add the syscall code in the file
include/unistd.h
148a149
> #define __NR_reboot 87
And then add the syscall address in the file
include/linux/sys.h
91a92
> extern int sys_reboot();
108c109
< sys_lstat, sys_readlink, sys_uselib };
---
> sys_lstat, sys_readlink, sys_uselib ,sys_reboot };
The last bit is to modify the keyboard.S file
kernel/chr_drv/keyboard.S
This file is different from yours so.... don't just apply the diff
Understand what it does and do it by hand.
25a26
> .globl _hard_reset
203c204
< jne reboot
---
> jne 1f /* CTRL-ALT-DEL */
659c660
< reboot:
---
> _hard_reset:
661,662c662,663
< movw $0x1234,0x472 /* don't do memory check */
< movb $0xfc,%al /* pulse reset and A20 low */
---
> movw $0x1234,0x472 /* don't do memory check */
> movb $0xfc,%al /* pulse reset and A20 low */
At this point recompile the kernel and all should go together.
Unfortunately the work is NOT finished. You have to add the syscall to
libc.a To do this you need the source for the library. Usually in
/usr/src/lib. Go into the unistd directory and create the file
reboot.c with the following content.
/* This function will reboot the syestem
*/
#define __LIBRARY__
#include <unistd.h>
_syscall1(int,reboot,int,param)
And then modify the Makefile as follow.
At the end of OBJ=.... list add reboot.o and do a make dep
Before making the new libary you have to change the standard unistd.h library
file to point to the unistd.h file in the linux directory
cd /usr/include
rm unistd.h
ln -s /usr/src/linux/include/unistd.h unistd.h
At this point you can make the new libc.a
Then you can experiment with the new syscall.
Eg:
#include <stdio.h>
#include <errno.h>
main ()
{
if ( reboot (1) ==(-EPERM) )
printf ("Not superuser \n");
exit (-1);
}
-------------------------------------------------------------
The second part is a patch that gives you access to the kernel memory
in particular kernel DATA memory.
The following diff applies to the file fs/char_dev.c and in particular
to the function rw_kmem .
52,54c52,67
< {
< return -EIO;
< }
---
> {
> int i = *pos; /* Current position where to read */
>
> /* i can go from 0 to LOW_MEM (See include/linux/mm.h */
> /* I am not shure about it but it doesn't mem fault :-) */
> while ( (count-- > 0) && (i <LOW_MEM) )
> {
> if (rw==READ) put_fs_byte( *(char *)i ,buf++);
> else return (-EIO);
> i++;
> }
>
> i -= *pos; /* Count how many read or write */
> *pos += i; /* Update position */
> return (i); /* Return number read */
> }
NOTE: The LOW_MEM value may not be the most appropriate. Linus please
confirm if it is the correct one.
Damiano

Binary file not shown.

View File

@@ -0,0 +1,210 @@
From: torvalds@klaava.Helsinki.FI (Linus Benedict Torvalds)
Newsgroups: alt.os.linux
Subject: patches for sys_rename
Summary: patch to 0.12
Keywords: rename mvdir
Message-ID: <1992Jan23.194334.23058@klaava.Helsinki.FI>
Date: 23 Jan 92 19:43:34 GMT
Organization: University of Helsinki
Lines: 198
Ok, here's the sys_rename patch to "linux/kernel/namei.c". Additionally
you need to remove the sys_rename stub function (just returns -ENOSYS)
from "linux/kerne|/sys.c". This is not heavily tested: I wrote it today,
but it seems to work.
Patch the file, remove the stub and recompile linux: voila, you have a
rename system call that actually works. It's not in the library, so
you'll have to explicitly call it by using __asm__'s. A simple
/usr/bin/mvdir command is here:
#define __LIBRARY__
#include <unistd.h>
#include <stdio.h>
int main(int argc, char ** argv)
{
int i;
if (argc != 3)
return -1;
__asm__("int $0x80":"=a" (i):"0" (__NR_rename),
"b" ((long) argv[1]),
"c" ((long) argv[2]));
return i;
}
and with this in place mv seems to be able to move directories without
problems. (You can also use mvdir to move non-directories, but who
cares). And, yes, I'm interested in bug-reports if it doesn't work.
Linus
---- snip snip -----------------------------------------
*** linux/fs/namei.c Sun Jan 12 06:09:58 1992
--- namei.c Thu Jan 23 23:05:53 1992
***************
*** 892,894 ****
--- 892,1051 ----
iput(oldinode);
return 0;
}
+
+ static int subdir(struct m_inode * new, struct m_inode * old)
+ {
+ unsigned short fs;
+ int ino;
+ int result;
+
+ __asm__("mov %%fs,%0":"=r" (fs));
+ __asm__("mov %0,%%fs"::"r" ((unsigned short) 0x10));
+ new->i_count++;
+ result = 0;
+ for (;;) {
+ if (new == old) {
+ result = 1;
+ break;
+ }
+ if (new->i_dev != old->i_dev)
+ break;
+ ino = new->i_num;
+ new = _namei("..",new,0);
+ if (new->i_num == ino)
+ break;
+ }
+ iput(new);
+ __asm__("mov %0,%%fs"::"r" (fs));
+ return result;
+ }
+
+ #define PARENT_INO(buffer) \
+ (((struct dir_entry *) (buffer))[1].inode)
+
+ #define PARENT_NAME(buffer) \
+ (((struct dir_entry *) (buffer))[1].name)
+
+ /*
+ * rename uses the -ERESTARTNOINTR error return to avoid race conditions:
+ * it tries to allocate all the blocks, then sanity-checks, and if the sanity-
+ * checks fail, it tries to restart itself again. Very practical - no changes
+ * are done until we know everything works ok.. and then all the changes can be
+ * done in one fell swoop when we have claimed all the buffers needed.
+ *
+ * Anybody can rename anything that they have access to (and write access to the
+ * parents) - except the '.' and '..' directories.
+ */
+ static int do_rename(const char * oldname, const char * newname)
+ {
+ struct m_inode * inode;
+ struct m_inode * old_dir, * new_dir;
+ struct buffer_head * old_bh, * new_bh, * dir_bh;
+ struct dir_entry * old_de, * new_de;
+ const char * old_base, * new_base;
+ int old_len, new_len;
+ int retval;
+
+ inode = old_dir = new_dir = NULL;
+ old_bh = new_bh = dir_bh = NULL;
+ old_dir = dir_namei(oldname,&old_len,&old_base, NULL);
+ retval = -ENOENT;
+ if (!old_dir)
+ goto end_rename;
+ retval = -EPERM;
+ if (!old_len || get_fs_byte(old_base) == '.' &&
+ (old_len == 1 || get_fs_byte(old_base+1) == '.' &&
+ old_len == 2))
+ goto end_rename;
+ retval = -EACCES;
+ if (!permission(old_dir,MAY_WRITE))
+ goto end_rename;
+ old_bh = find_entry(&old_dir,old_base,old_len,&old_de);
+ retval = -ENOENT;
+ if (!old_bh)
+ goto end_rename;
+ inode = iget(old_dir->i_dev, old_de->inode);
+ if (!inode)
+ goto end_rename;
+ new_dir = dir_namei(newname,&new_len,&new_base, NULL);
+ if (!new_dir)
+ goto end_rename;
+ retval = -EPERM;
+ if (!new_len || get_fs_byte(new_base) == '.' &&
+ (new_len == 1 || get_fs_byte(new_base+1) == '.' &&
+ new_len == 2))
+ goto end_rename;
+ retval = -EACCES;
+ if (!permission(new_dir, MAY_WRITE))
+ goto end_rename;
+ if (new_dir->i_dev != old_dir->i_dev)
+ goto end_rename;
+ new_bh = find_entry(&new_dir,new_base,new_len,&new_de);
+ retval = -EEXIST;
+ if (new_bh)
+ goto end_rename;
+ retval = -EPERM;
+ if (S_ISDIR(inode->i_mode)) {
+ if (!permission(inode, MAY_WRITE))
+ goto end_rename;
+ if (subdir(new_dir, inode))
+ goto end_rename;
+ retval = -EIO;
+ if (!inode->i_zone[0])
+ goto end_rename;
+ if (!(dir_bh = bread(inode->i_dev, inode->i_zone[0])))
+ goto end_rename;
+ if (PARENT_INO(dir_bh->b_data) != old_dir->i_num)
+ goto end_rename;
+ }
+ new_bh = add_entry(new_dir,new_base,new_len,&new_de);
+ retval = -ENOSPC;
+ if (!new_bh)
+ goto end_rename;
+ /* sanity checking before doing the rename - avoid races */
+ retval = -ERESTARTNOINTR;
+ if (new_de->inode || (old_de->inode != inode->i_num))
+ goto end_rename;
+ /* ok, that's it */
+ old_de->inode = 0;
+ new_de->inode = inode->i_num;
+ old_bh->b_dirt = 1;
+ new_bh->b_dirt = 1;
+ if (dir_bh) {
+ PARENT_INO(dir_bh->b_data) = new_dir->i_num;
+ dir_bh->b_dirt = 1;
+ old_dir->i_nlinks--;
+ new_dir->i_nlinks++;
+ old_dir->i_dirt = 1;
+ new_dir->i_dirt = 1;
+ }
+ retval = 0;
+ end_rename:
+ brelse(dir_bh);
+ brelse(old_bh);
+ brelse(new_bh);
+ iput(inode);
+ iput(old_dir);
+ iput(new_dir);
+ return retval;
+ }
+
+ /*
+ * Ok, rename also locks out other renames, as they can change the parent of
+ * a directory, and we don't want any races. Other races are checked for by
+ * "do_rename()", which restarts if there are inconsistencies.
+ */
+ int sys_rename(const char * oldname, const char * newname)
+ {
+ static struct task_struct * wait = NULL;
+ static int lock = 0;
+ int result;
+
+ while (lock)
+ sleep_on(&wait);
+ lock = 1;
+ result = do_rename(oldname, newname);
+ lock = 0;
+ wake_up(&wait);
+ return result;
+ }

View File

@@ -0,0 +1,125 @@
*** orig/makefile Thu Feb 21 17:15:06 1991
--- makefile Wed Feb 5 10:38:20 1992
***************
*** 4,12 ****
#
# define STDLIB for systems that have <stdlib.h>
DEFS = -DUNIX -DSTDLIB
! CFLAGS = -g ${DEFS}
HDR = cawf.h regexp.h regmagic.h
--- 4,14 ----
#
# define STDLIB for systems that have <stdlib.h>
+ CC = gcc
+
DEFS = -DUNIX -DSTDLIB
! CFLAGS = ${DEFS}
HDR = cawf.h regexp.h regmagic.h
*** orig/bsfilt.c Thu Feb 21 17:14:54 1991
--- bsfilt.c Sat Jan 18 20:15:50 1992
***************
*** 45,51 ****
int Ulx = 0; /* underline buffer index */
void Putchar();
! #ifndef STDDEF
char *strrchr();
#endif
--- 45,51 ----
int Ulx = 0; /* underline buffer index */
void Putchar();
! #ifndef STDLIB
char *strrchr();
#endif
*** orig/cawf.c Thu Feb 21 17:14:54 1991
--- cawf.c Sat Jan 18 20:15:50 1992
*** orig/cawf.h Thu Feb 21 17:14:54 1991
--- cawf.h Wed Feb 5 10:43:06 1992
***************
*** 40,46 ****
#include "regexp.h"
#ifdef UNIX
! #define CAWFLIB "/Homes/abe/src/cawf" /* UNIX library location */
#else
#define CAWFLIB "c:/sys/lib/cawf" /* PC-DOS library location */
#endif
--- 40,46 ----
#include "regexp.h"
#ifdef UNIX
! #define CAWFLIB "/usr/local/lib" /* UNIX library location */
#else
#define CAWFLIB "c:/sys/lib/cawf" /* PC-DOS library location */
#endif
*** orig/error.c Thu Feb 21 17:14:56 1991
--- error.c Sat Jan 18 20:15:50 1992
*** orig/expand.c Thu Feb 21 17:14:56 1991
--- expand.c Sat Jan 18 20:15:50 1992
*** orig/expr.c Thu Feb 21 17:14:56 1991
--- expr.c Sat Jan 18 20:15:50 1992
*** orig/macsup.c Thu Feb 21 17:14:56 1991
--- macsup.c Sat Jan 18 20:15:50 1992
*** orig/output.c Thu Feb 21 17:14:56 1991
--- output.c Sat Jan 18 20:15:50 1992
*** orig/pass2.c Thu Feb 21 17:14:58 1991
--- pass2.c Sat Jan 18 20:15:50 1992
*** orig/pass3.c Thu Feb 21 17:14:58 1991
--- pass3.c Sat Jan 18 20:15:50 1992
*** orig/regerror.c Thu Feb 21 17:14:58 1991
--- regerror.c Sat Jan 18 20:15:50 1992
*** orig/regexp.c Thu Feb 21 17:15:00 1991
--- regexp.c Sat Jan 18 20:25:37 1992
***************
*** 708,714 ****
register char *string;
{
register char *s;
! extern char *strchr();
/* Be paranoid... */
if (prog == NULL || string == NULL) {
--- 708,714 ----
register char *string;
{
register char *s;
! /* extern char *strchr(); */
/* Be paranoid... */
if (prog == NULL || string == NULL) {
***************
*** 807,813 ****
{
register char *scan; /* Current node. */
char *next; /* Next node. */
! extern char *strchr();
scan = prog;
#ifdef DEBUG
--- 807,813 ----
{
register char *scan; /* Current node. */
char *next; /* Next node. */
! /* extern char *strchr(); */
scan = prog;
#ifdef DEBUG
*** orig/regexp.h Thu Feb 21 17:15:00 1991
--- regexp.h Sat Jan 18 19:55:38 1992
*** orig/regmagic.h Thu Feb 21 17:15:00 1991
--- regmagic.h Sat Jan 18 20:10:06 1992
*** orig/store.c Thu Feb 21 17:15:00 1991
--- store.c Sat Jan 18 20:26:26 1992
*** orig/string.c Thu Feb 21 17:15:02 1991
--- string.c Sat Jan 18 20:27:18 1992

Binary file not shown.

View File

@@ -0,0 +1,104 @@
/* 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);
}

Binary file not shown.

View File

@@ -0,0 +1,34 @@
#include <stdio.h>
#include <sys/file.h>
#include <errno.h>
extern char *sys_errlist[];
main(int argc, char *argv[])
{
if (argc != 3) {
fprintf(stderr, "usage: doshell <ttyname> <shellname> &\n");
exit(1);
}
/* close down fd's */
close(0);
close(1);
close(2);
/* detach from parent process's group */
setsid();
/* open new tty */
if (open(argv[1], O_RDWR, 0) == -1)
exit(2);
dup(0);
dup(0);
execlp(argv[2], "-", 0);
/* should appear on new tty...: */
fprintf(stderr, "can't exec shell: %s\n", sys_errlist[errno]);
exit(3);
}

View File

@@ -0,0 +1,204 @@
To: Linux-Activists@BLOOM-PICAYUNE.MIT.EDU
From: gt0178a@prism.gatech.EDU (BURNS)
Subject: Re: elle(1) and rc(1) ports uploaded to tsx-11.mit.edu
Date: 10 May 92 08:13:59 GMT
I found out why I was getting undefineds from elle's make. There was a
syntax problem with the '-sh -c if ...' line in Makefile that prevented
ranlib from processing the made libraries. That, plus adding -ltermcap to
the link line solved everything. To remake things in mid-stream, I also had
to reorganize things in sbmake. New make files follow:
=========
Makefile:
=========
# ELLE Makefile.
# The main trickery to notice is that this Makefile invokes itself
# in order to build ELLE. This allows it to generate sections of
# the makefile dynamically, namely:
# makecf.rl - defines the RANLIB macro to use "ranlib" if system has it
# makecf.fun - defines the FUN_OFILES macro to specify which modules
# are needed in order to furnish all of the desired
# functions for a specific ELLE configuration.
# Basic definitions
CFLAGS = -c -O
CONFS = makecf.rl makecf.fun defprf.c eefdef.h eefidx.h
CORE_OFILES = eemain.o eecmds.o eesite.o eevini.o\
eedisp.o eeterm.o eeerr.o eeques.o\
eebuff.o eefile.o eefed.o eeedit.o eebit.o
.c.o:
cc $(CFLAGS) $*.c
ar rv elib.a $*.o
# ------------------------------------------------------------------
# Standard ELLE configuration: "elle".
# Default if no target given to make.
# Note that "xelle" is created, not "elle".
elle: $(CONFS)
make -f makecf.rl -f makecf.fun -f Makefile B-elle
B-elle: $(CORE_OFILES) $(FUN_OFILES) elle.h eesite.h libsb.a
$(RANLIB) elib.a
cc -o xelle eemain.o elib.a libsb.a -ltermcap
# Don't flush these files if interrupted, dammit!
.PRECIOUS: ellec deffun.e defprf.e $(CONFS) libsb.a
# Configuration setup stuff, for files listed by CONFS.
# If any of the files is missing or outdated, all must be
# re-generated. We assume the *.t files always exist.
# A forced re-compilation of eecmds.c must also be done to
# ensure that the latest .h files are included in ELLE.
makecf.fun defprf.c eefdef.h eefidx.h : ellec defprf.e deffun.e
cat deffun.e defprf.e | ./ellec -CMconf > makecf.fun
cat deffun.e defprf.e | ./ellec -Pconf > defprf.c
cat deffun.e defprf.e | ./ellec -Fconf > eefdef.h
cat deffun.e defprf.e | ./ellec -FXconf > eefidx.h
rm -f eecmds.o
# The following modules make use of eefidx.h and thus must also
# be recompiled if the configuration is changed.
eebuff.o eeerr.o eehelp.o eejust.o eemain.o eeques.o eef1.o : eefidx.h
cc $(CFLAGS) $*.c
ar rv elib.a $*.o
# RANLIB definition stuff. The idea here is to automatically check to see
# whether a system has the "ranlib" program, and set up the RANLIB
# macro appropriately (use ranlib if possible; else substitute a dummy
# program, "echo" in this case). The existence of "makecf.rl"
# indicates that this setup code has been executed; it should never
# need to be done again.
makecf.rl:
echo "RANLIB = echo" > makecf.rl
-sh -c "if [ ranlib ]; then (echo \"RANLIB = ranlib\" > makecf.rl;) fi"
# ELLE profile compiler. Needed to generate makecf files!
# Although eefdef.h and defprf.c are included by ELLEC, they
# are not listed as dependencies in order to avoid loops (see
# their target entries). That is OK because their information is not
# used when generating the makecf files; it only furnishes default
# values needed when an ELLE user compiles a user profile.
ellec: ellec.c
cc -o ellec -O ellec.c
# SB library, used by ELLE.
# This target should not be directly invoked by the user since it
# requires that RANLIB be defined; for direct invocation, better to
# just do a MAKE of "sb" in the sbmake file.
libsb.a:
make -f sbmake sbnoran
$(RANLIB) libsb.a
# ------------------------------------------------------------------
# ELLE Variants (system or configuration dependent)
# SUN workstation system/configuration.
# Needs extra libraries to support window hacking; libsb.a comes last
# so that "valloc" refs can be satisfied from SB library instead of
# C library.
# Plus special patch to binary, very installation-dependent!
sunelle: $(CONFS)
make -f makecf.rl -f makecf.fun -f Makefile B-sunelle
B-sunelle: $(CORE_OFILES) $(FUN_OFILES) eesun.o elle.h eesite.h libsb.a
$(RANLIB) elib.a
cc -o xelle -u _main elib.a -ltermlib\
-lsuntool -lsunwindow -lpixrect\
libsb.a
echo "tool_select+148?W my_select" > esunpat.sh
adb -w xelle < esunpat.sh
# APOLLO system.
# Linker doesn't understand libraries as regular arguments.
# May have troubles with duplication of CORE and FUN files.
# System has no termlib - uses TERMCAP emulation that comes with AUX.
SB_OFILES = sbstr.o sbm.o sberr.o
apolloelle: $(CONFS)
make -f makecf.rl -f makecf.fun -f Makefile B-apolloelle
B-apolloelle: $(CORE_OFILES) $(FUN_OFILES) elle.h eesite.h libsb.a
cc -o xelle $(CORE_OFILES) $(FUN_OFILES) $(SB_OFILES) -ltermcap
# IBM PC/IX system.
# Just needs -ltermcap instead of -ltermlib.
# Does not have/need "ranlib" by the way.
pcixelle: $(CONFS)
make -f makecf.rl -f makecf.fun -f Makefile B-pcixelle
B-pcixelle: $(CORE_OFILES) $(FUN_OFILES) elle.h eesite.h libsb.a
cc -i -o xelle -u _main elib.a libsb.a -ltermcap
=========
sbmake:
=========
# SB library makefile.
# Only funny stuff is handling for the "bcopy" routine, where
# we try to use the system version if any exists.
#
# On PDP-11 systems only, BCOPYSUF can be set to ".s" to use
# an assembly-language version. The bcopy.s here is
# better than the BSD2.9 version and can replace it.
CFLAGS = -c -O
OFILES = sbstr.o sbvall.o sbm.o sberr.o sbbcpy.o
BCOPYSUF = .c
.c.o:
cc $(CFLAGS) $*.c
# ar rv libsb.a $*.o
# Default entry - build library and attempt ranlib, but since some
# systems don't have ranlib, ignore error in latter.
sb: libsb.a $(OFILES)
-sh -c "ranlib libsb.a"
# Note that ELLE's makefile invokes this entry, since it does the ranlib
# itself if necessary.
sbnoran: libsb.a $(OFILES)
libsb.a: $(OFILES)
ar rv libsb.a $(OFILES)
# BCOPY special-case handling. If system already appears to have
# a "bcopy" routine, we use that for best efficiency (normally it
# is written in assembler to take advantage of things like
# block move instructions).
# Otherwise, we use our own C-language version.
sbbcpy.o: sbbcpy$(BCOPYSUF)
cc -c -O sbbcpy$(BCOPYSUF)
rm -f a.out bnull.c bnull.o bfind.c bfind.o bfind
echo "sbm_null(){}" > bnull.c
cc -c bnull.c
echo "main(){exit(0);bcopy();}" > bfind.c
-cc -o bfind bfind.c
-sh -c "if ./bfind;\
then echo Using system bcopy; (mv bnull.o sbbcpy.o)\
else echo Using SB bcopy; fi"
rm -f bfind bfind.c bfind.o a.out bnull.c bnull.o
ar rv libsb.a sbbcpy.o
--
BURNS,JIM (returned student)
Georgia Institute of Technology, 30178 Georgia Tech Station,
Atlanta Georgia, 30332 | Internet: gt0178a@prism.gatech.edu
uucp: ...!{decvax,hplabs,ncar,purdue,rutgers}!gatech!prism!gt0178a

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View 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);
}

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -0,0 +1,11 @@
This archive contains a Executable of LHA and an archive with the source
and the addapted Makefile so one can compile under Linux.
I (The Sender of this File) would like to see this archive added to the
archive of Linux Programs.
I hope it is of any use to someone out there!
For any questions I'm reacheable by E-Mail under
m2c6@sci.kun.nl (At least until June 1992).

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -0,0 +1,44 @@
This is the Mtools v2.0 distribution package. Mtools is a public domain
collection of programs to allow Unix systems to read, write, and
manipulate files on an MSDOS filesystem (typically a diskette).
The following MSDOS commands are emulated:
Mtool MSDOS
name equivalent Description
----- ---- -----------
mattrib ATTRIB change MSDOS file attribute flags
mcd CD change MSDOS directory
mcopy COPY copy MSDOS files to/from Unix
mdel DEL/ERASE delete an MSDOS file
mdir DIR display an MSDOS directory
mformat FORMAT add MSDOS filesystem to a low-level format
mlabel LABEL make an MSDOS volume label.
mmd MD/MKDIR make an MSDOS subdirectory
mrd RD/RMDIR remove an MSDOS subdirectory
mread COPY low level read (copy) an MSDOS file to Unix
mren REN/RENAME rename an existing MSDOS file
mtype TYPE display contents of an MSDOS file
mwrite COPY low level write (copy) a Unix file to MSDOS
Here are what the files should look like:
file name length att sum bsd sum
mtools_patches1-5.Z 43331 01381 04887
mtools_sh.1.Z 27527 34726 38082
mtools_sh.2.Z 26902 17097 42191
mtools_sh.3.Z 16327 04558 20371
mtools_sh.4.Z 10405 51165 39152
The 'mtools_patches1-5' file is for those people who already have Mtools
version 2.0, but are missing one or more of the patches. The 'mtools_sh.*'
files already have the patches installed. The last file 'mtools_sh.4' is
optional... it contains the formatted output of the manual pages for the
benefit of those without nroff.
Emmet P. Gray US Army, HQ III Corps & Fort Hood
...!uunet!uiucuxc!fthood!egray Attn: AFZF-DE-ENV
fthood!egray@uxc.cso.uiuc.edu Directorate of Engineering & Housing
Environmental Management Office
Fort Hood, TX 76544-5057

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -0,0 +1,283 @@
/*
* Stat.c Dump out inode info in nice form. pur-ee!rsk
* Original version by someone at Purdue in the days of v6;
* this one by Rsk for modern times. (4.2, V)
*
* Bug fix for setuid bit misplacement, and modifications
* for System V by Bill Stoll, whuxlm!wws.
*
* Masscomp (and system V) mods by Stan Barber, neuro1!sob.
*
* Bug fix for setuid bit and flag mods, and for
* misplaced include of time.h, okstate!zap.
* Note: I left SINCE as a compile-time option; it
* probably shouldn't even be there. ---Rsk
*
* (void)'s added to make lint happy, pur-ee!rsk.
*
* Still doesn't run under 2.9; to be fixed soon.
*
*
* Vanilla version is for system V.
* Define BSD42 for 4.2bsd version.
* Define SINCE for "elapsed time" since inode times.
* Define MASSCOMP for those machines; this implies system V.
*/
/*
* 1992-03-03 bergt@informatik.tu-chemnitz.de: ported the stuff
* to Linux 0.12 and add's unknown uid's and gid's
*/
#ifdef MASSCOMP
#undef BSD42
#endif MASSCOMP
#include <stdio.h>
#include <sys/time.h>
#include <sys/types.h>
#include <ctype.h>
#include <sys/stat.h>
#include <pwd.h>
#include <grp.h>
#include <strings.h>
#include <stdlib.h>
#define FAIL -1 /* Failure return code from call */
#define OKAY 0 /* Success return code from call */
struct stat Sbuf; /* for return values from stat() call */
char *ctime(); /* Time conversion */
struct passwd *pwent; /* User structure */
struct group *grent; /* Group structure */
char Mode[10]; /* File protection mode */
#define LBUFSIZ 256 /* Length for symbolic link translation buffer */
char Lbuf[LBUFSIZ]; /* Symbolic link translation buffer */
main(argc, argv)
int argc;
char *argv[];
{
int i;
i = 1;
if(argc == 1) {
(void) fprintf(stderr,"Usage: stat file1 [file2 ...]\n");
exit(1);
}
do {
(void) stat_it(argv[i]);
if( (argc > 1) && (i < (argc-1)) )
(void) printf("\n");
}
while(++i < argc);
exit(0);
}
/*
* stat_it() - Actually stat and format results from file.
* exit - OKAY if no problems encountered
* FAIL if couldn't open or other nastiness
*
*/
stat_it(filename)
char *filename;
{
int count;
#ifdef BSD42
if( lstat(filename,&Sbuf) == FAIL) {
(void) fprintf(stderr,"Can't lstat %s\n",filename);
return(FAIL);
}
#else BSD42
if( stat(filename,&Sbuf) == FAIL) {
(void) fprintf(stderr,"Can't stat %s\n",filename);
return(FAIL);
}
#endif BSD42
#ifdef BSD42
if( (Sbuf.st_mode & S_IFMT) == S_IFLNK) {
if( (count=readlink(filename,Lbuf,LBUFSIZ)) == FAIL) {
(void) fprintf(stderr,"Can't readlink %s\n", filename);
return(FAIL);
}
if( count < LBUFSIZ)
Lbuf[count] = '\0';
(void) printf(" File: \"%s\" -> \"%s\"\n",filename,Lbuf);
}
else
#endif BSD42
(void) printf(" File: \"%s\"\n", filename);
(void) printf(" Size: %-10d", Sbuf.st_size);
#ifdef BSD42
(void) printf(" Allocated Blocks: %-10ld", Sbuf.st_blocks);
#endif BSD42
(void) printf(" Filetype: ");
switch( Sbuf.st_mode & S_IFMT) {
case S_IFDIR: (void) printf("Directory\n");
break;
case S_IFCHR: (void) printf("Character Device\n");
break;
case S_IFBLK: (void) printf("Block Device\n");
break;
case S_IFREG: (void) printf("Regular File\n");
break;
#ifdef BSD42
case S_IFLNK: (void) printf("Symbolic Link\n");
break;
case S_IFSOCK: (void) printf("Socket\n");
break;
#else BSD42
case S_IFIFO: (void) printf("Fifo File\n");
break;
#endif BSD42
#ifdef MASSCOMP
case S_IFCTG: (void) printf("Contiguous File\n");
break;
#endif MASSCOMP
default : (void) printf("Unknown\n");
}
(void) strcpy(Mode,"----------");
if(Sbuf.st_mode & (S_IXUSR>>6)) /* Other execute */
Mode[9] = 'x';
if(Sbuf.st_mode & (S_IWUSR>>6)) /* Other write */
Mode[8] = 'w';
if(Sbuf.st_mode & (S_IRUSR>>6)) /* Other read */
Mode[7] = 'r';
if(Sbuf.st_mode & (S_IXUSR>>3)) /* Group execute */
Mode[6] = 'x';
if(Sbuf.st_mode & (S_IWUSR>>3)) /* Group write */
Mode[5] = 'w';
if(Sbuf.st_mode & (S_IRUSR>>3)) /* Group read */
Mode[4] = 'r';
if(Sbuf.st_mode & S_IXUSR) /* User execute */
Mode[3] = 'x';
if(Sbuf.st_mode & S_IWUSR) /* User write */
Mode[2] = 'w';
if(Sbuf.st_mode & S_IRUSR) /* User read */
Mode[1] = 'r';
if(Sbuf.st_mode & S_ISVTX) /* Sticky bit */
Mode[9] = 't';
if(Sbuf.st_mode & S_ISGID) /* Set group id */
Mode[6] = 's';
if(Sbuf.st_mode & S_ISUID) /* Set user id */
Mode[3] = 's';
switch( Sbuf.st_mode & S_IFMT) {
case S_IFDIR: Mode[0] = 'd';
break;
case S_IFCHR: Mode[0] = 'c';
break;
case S_IFBLK: Mode[0] = 'b';
break;
case S_IFREG: Mode[0] = '-';
break;
#ifdef BSD42
case S_IFLNK: Mode[0] = 'l';
break;
case S_IFSOCK: Mode[0] = 's';
break;
#else BSD42
case S_IFIFO: Mode[0] = 'f';
break;
#endif BSD42
#ifdef MASSCOMP
case S_IFCTG: Mode[0] = 'C';
break;
#endif MASSCOMP
default : Mode[0] = '?';
}
(void) printf(" Mode: (%04o/%s)", Sbuf.st_mode&07777,Mode);
(void) setpwent();
if( (pwent = getpwuid(Sbuf.st_uid)) == NULL) {
pwent = (PTR) malloc(sizeof(struct passwd));
(void) strcpy(pwent->pw_name, "???");
}
(void) printf(" Uid: (%5d/%8s)", Sbuf.st_uid, pwent->pw_name);
(void) setgrent();
if( (grent = getgrgid(Sbuf.st_gid)) == NULL) {
grent = (PTR) malloc(sizeof(struct passwd));
(void) strcpy(grent->gr_name, "???");
}
(void) printf(" Gid: (%5d/%8s)\n", Sbuf.st_gid, grent->gr_name);
(void) printf("Device: %-5d", Sbuf.st_dev);
(void) printf(" Inode: %-10d", Sbuf.st_ino);
(void) printf("Links: %-5d", Sbuf.st_nlink);
/* Only meaningful if file is device */
if( ( (Sbuf.st_mode & S_IFMT) == S_IFCHR)
|| ( (Sbuf.st_mode & S_IFMT) == S_IFBLK) )
(void) printf(" Device type: %d\n",Sbuf.st_rdev);
else
(void) printf("\n");
/* The %.24s strips the newline from the ctime() string */
#ifdef SINCE
(void) printf("Access: %.24s",ctime(&Sbuf.st_atime));
(void) tsince(Sbuf.st_atime);
(void) printf("Modify: %.24s",ctime(&Sbuf.st_mtime));
(void) tsince(Sbuf.st_mtime);
(void) printf("Change: %.24s",ctime(&Sbuf.st_ctime));
(void) tsince(Sbuf.st_ctime);
#else SINCE
(void) printf("Access: %s",ctime(&Sbuf.st_atime));
(void) printf("Modify: %s",ctime(&Sbuf.st_mtime));
(void) printf("Change: %s",ctime(&Sbuf.st_ctime));
#endif SINCE
/*
* Should I put this in somewhere? No.
*
* printf("Optimal Blocksize: %ld\n", Sbuf.st_blksize);
*/
return(OKAY);
}
#ifdef SINCE
tsince(time_sec)
long time_sec;
{
long time_buf;
long d_since; /* days elapsed since time */
long h_since; /* hours elapsed since time */
long m_since; /* minutes elapsed since time */
long s_since; /* seconds elapsed since time */
(void) time(&time_buf);
if(time_sec > time_buf) {
(void) fprintf(stderr,"Time going backwards\n");
exit(1);
}
s_since = time_buf - time_sec;
d_since = s_since / 86400l ;
s_since -= d_since * 86400l ;
h_since = s_since / 3600l ;
s_since -= h_since * 3600l ;
m_since = s_since / 60l ;
s_since -= m_since * 60l ;
(void) printf("(%05ld.%02ld:%02ld:%02ld)\n",d_since,h_since,m_since,s_since);
return(OKAY);
}
#endif SINCE

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -0,0 +1,133 @@
This is a version of tty.c for linux.
john harvey JOHNBOB at AUSVMQ I don't speak for my employer.
johnbob@innerdoor.austin.ibm.com johnbob@there.austin.ibm.com
johnbob@129.35.81.111 johnbob@129.35.81.200
main(int c,char**v){if(c==2){int n=atoi(v[1]);printf("%d\n",
n*main(-n+1,v));}else if(c<0)return-c*main(c+1,v);return 1;}
---- Cut Here and unpack ----
#!/bin/sh
# This is a shell archive (shar 3.10)
# made 01/21/1992 18:47 UTC by rjohnbobpts/4@AIX
# Source directory /drive2/u/johnbob/net/linux/contrib
#
# existing files will NOT be overwritten
#
# This shar contains:
# length mode name
# ------ ---------- ------------------------------------------
# 170 -rw-r--r-- Makefile
# 158 -rw-r--r-- add.this
# 587 -rw-r--r-- tty.c
#
touch 2>&1 | fgrep '[-amc]' > /tmp/s3_touch$$
if [ -s /tmp/s3_touch$$ ]
then
TOUCH=can
else
TOUCH=cannot
fi
rm -f /tmp/s3_touch$$
# ============= Makefile ==============
if test -f Makefile; then echo "File Makefile exists"; else
echo "x - extracting Makefile (Text)"
sed 's/^X//' << 'SHAR_EOF' > Makefile &&
X#
X#
X
XPROGRAM = tty
XSRC = tty.c
XOBJS = tty.o
X
XCC=cc
XCFLAGS = -O
X
X
Xall: $(PROGRAM)
X
X$(PROGRAM): $(OBJS)
X $(CC) -o $(PROGRAM) $(OBJS) $(LIBS)
X
X.c.o:
X $(CC) $(CFLAGS) -c $<
X
SHAR_EOF
chmod 0644 Makefile || echo "restore of Makefile fails"
if [ $TOUCH = can ]
then
touch -am 0120162992 Makefile
fi
fi
# ============= add.this ==============
if test -f add.this; then echo "File add.this exists"; else
echo "x - extracting add.this (Text)"
sed 's/^X//' << 'SHAR_EOF' > add.this &&
XThe prototype for the ttyname() function wasn't in
X/usr/include/unistd.h so you will have to add it to
Xthe bottom of the file:
X
Xchar * ttyname(int fildes);
X
X
SHAR_EOF
chmod 0644 add.this || echo "restore of add.this fails"
if [ $TOUCH = can ]
then
touch -am 0120174392 add.this
fi
fi
# ============= tty.c ==============
if test -f tty.c; then echo "File tty.c exists"; else
echo "x - extracting tty.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > tty.c &&
X/*
X tty.c
X By John Harvey AKA johnbob AKA qk
X copy this all you want
X*/
X
X#include <sys/types.h>
X#include <stdio.h>
X#include <unistd.h>
X
Xvoid syntax(int rv)
X{
X fprintf(stderr,"syntax: tty [-s]\n");
X exit(rv);
X}
X
Xmain(int argc, char **argv)
X{
X int silent = 0;
X char *n;
X
X if( argc == 2 )
X {
X if( strcmp(argv[1],"-s") )
X syntax(1);
X silent = 1;
X }
X else if ( argc != 1 )
X syntax(1);
X if( n=ttyname(0) )
X {
X if ( ! silent )
X printf("%s\n", n);
X exit(0);
X }
X else
X {
X if ( ! silent )
X printf("%s\n", "Not a tty");
X exit(1);
X }
X}
SHAR_EOF
chmod 0644 tty.c || echo "restore of tty.c fails"
if [ $TOUCH = can ]
then
touch -am 0120173492 tty.c
fi
fi
exit 0

Binary file not shown.

View 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");
}

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.