SCCS-vsn: old/berknet/net.c 4.2
SCCS-vsn: old/berknet/netdaemon.c 4.2
SCCS-vsn: old/berknet/netq.c 4.2
SCCS-vsn: old/berknet/netrm.c 4.2
SCCS-vsn: old/berknet/mach.h 4.2
-/* @(#)mach.h 4.1 (Berkeley) %G% */
+/* @(#)mach.h 4.2 (Berkeley) %G% */
/* sccs id variable */
static char *mach_h_sid = "@(#)mach.h 1.11";
/* sccs id variable */
static char *mach_h_sid = "@(#)mach.h 1.11";
*/
/* be sure to include <stdio.h> before these defns */
*/
/* be sure to include <stdio.h> before these defns */
# include <sysexits.h>
/* note NUID is only used in mmail.c */
# include <sysexits.h>
/* note NUID is only used in mmail.c */
# define ANYP 0300
# define ECHO 010
# define ROOTINO 1
# define ANYP 0300
# define ECHO 010
# define ROOTINO 1
# define TIOCEXCL 0
# define SIGHUP 1
# define SIGINT 2
# define TIOCEXCL 0
# define SIGHUP 1
# define SIGINT 2
# define setjmp(a) setexit()
# define setjmp(a) setexit()
-struct stat {
- int st_dev;
- int st_ino;
- int st_mode;
- char st_nlink:8;
- char st_uid:8;
- char st_gid:8;
- char st_size0;
- int st_size1;
- int st_addr[8];
- long st_atime;
- long st_mtime;
- };
-struct direct {
- int d_ino;
- char d_name[DIRSIZ];
- };
struct tms { /* see times - sect 2 */
int tms_utime; /* user time */
int tms_stime; /* system time */
struct tms { /* see times - sect 2 */
int tms_utime; /* user time */
int tms_stime; /* system time */
-static char sccsid[] = "@(#)net.c 4.1 (Berkeley) %G%";
+static char sccsid[] = "@(#)net.c 4.2 (Berkeley) %G%";
/* sccs id variable */
static char *net_sid = "@(#)net.c 1.8";
/* sccs id variable */
static char *net_sid = "@(#)net.c 1.8";
static struct stat x;
static struct direct y;
static struct stat x;
static struct direct y;
static int off = -1;
/* these three routines gwd, cat, ckroot and
data structures x, y, off, do a pwd to string name */
#ifdef V6
static int off = -1;
/* these three routines gwd, cat, ckroot and
data structures x, y, off, do a pwd to string name */
#ifdef V6
gwd(name)
register char *name; {
*name = 0;
gwd(name)
register char *name; {
*name = 0;
static struct stat xx;
gwd(name)
register char *name; {
int rdev, rino;
register int i;
static struct stat xx;
gwd(name)
register char *name; {
int rdev, rino;
register int i;
+ register struct direct *dp;
*name = 0;
stat("/", &x);
*name = 0;
stat("/", &x);
stat(".", &x);
if (x.st_ino == rino && x.st_dev == rdev)
break;
stat(".", &x);
if (x.st_ino == rino && x.st_dev == rdev)
break;
- if ((file = fopen("..", "r")) == NULL)
+ if ((file = opendir("..")) == NULL)
- fstat(fileno(file), &xx);
+ fstat(file->dd_fd, &xx);
chdir("..");
if (x.st_dev == xx.st_dev) {
if (x.st_ino == xx.st_ino)
break;
do
chdir("..");
if (x.st_dev == xx.st_dev) {
if (x.st_ino == xx.st_ino)
break;
do
- if (fread((char *)&y, 1, sizeof y, file) != sizeof y)
+ if ((dp = readdir(file)) == NULL)
- while (y.d_ino != x.st_ino);
+ while (dp->d_ino != x.st_ino);
- if (fread((char *)&y, 1, sizeof y, file) != sizeof y)
+ if ((dp = readdir(file)) == NULL)
} while (xx.st_ino != x.st_ino || xx.st_dev != x.st_dev);
} while (xx.st_ino != x.st_ino || xx.st_dev != x.st_dev);
+ blkcpy(dp, &y, DIRSIZ(dp));
+ closedir(file);
+
+blkcpy(from, to, size)
+ register *from, *to;
+ register int size;
+{
+ while (size-- > 0)
+ *to++ = *from++;
+}
-static char sccsid[] = "@(#)netdaemon.c 4.1 (Berkeley) %G%";
+static char sccsid[] = "@(#)netdaemon.c 4.2 (Berkeley) %G%";
/* sccs id variable */
static char *netdaemon_sid = "@(#)netdaemon.c 1.10";
/* sccs id variable */
static char *netdaemon_sid = "@(#)netdaemon.c 1.10";
/* local variables */
static long length;
/* local variables */
static long length;
/* static char sheader[] = "ABCDE"; */
static char tempfile[]= TEMPFILE;
static char publogfile[]= PUBLOGFILE;
static struct stat statbuf;
/* static char sheader[] = "ABCDE"; */
static char tempfile[]= TEMPFILE;
static char publogfile[]= PUBLOGFILE;
static struct stat statbuf;
-static struct direct dirbuf;
int handlekill();
static char frommach;
long linechars();
int handlekill();
static char frommach;
long linechars();
perror(senddir);
exit(EX_OSFILE);
}
perror(senddir);
exit(EX_OSFILE);
}
- dir = fopen(senddir,"r");
+ dir = opendir(senddir);
if(dir == NULL){
perror(senddir);
exit(EX_OSFILE);
if(dir == NULL){
perror(senddir);
exit(EX_OSFILE);
register int i;
char stemp[20];
static char jname[FNS];
register int i;
char stemp[20];
static char jname[FNS];
+ register struct direct *dp;
debug("ck send");
if(stat(senddir,&statbuf) < 0){
debug("ck send");
if(stat(senddir,&statbuf) < 0){
}
if(statbuf.st_mtime == lasttime && nleft == 0)return; /* no need to search */
lasttime = statbuf.st_mtime;
}
if(statbuf.st_mtime == lasttime && nleft == 0)return; /* no need to search */
lasttime = statbuf.st_mtime;
lFileLen = 10000000L;
nleft = 0;
lFileLen = 10000000L;
nleft = 0;
- while(fread(&dirbuf,1,sizeof dirbuf,dir) == sizeof dirbuf){
- if(dirbuf.d_ino == 0
- || dirbuf.d_name[0] != 'c'
- || dirbuf.d_name[1] != 'f'
- || dirbuf.d_name[2] != remote
- || stat(dirbuf.d_name,&statbuf) < 0
+ while((dp = readdir(dir)) != NULL){
+ if(dp->d_name[0] != 'c'
+ || dp->d_name[1] != 'f'
+ || dp->d_name[2] != remote
+ || stat(dp->d_name,&statbuf) < 0
|| statbuf.st_mode == 0)
continue;
|| statbuf.st_mode == 0)
continue;
- dirbuf.d_name[0] = 'd';
- if(stat(dirbuf.d_name,&statbuf) < 0 || statbuf.st_mode == 0)
+ dp->d_name[0] = 'd';
+ if(stat(dp->d_name,&statbuf) < 0 || statbuf.st_mode == 0)
continue;
uid = guid(statbuf.st_uid,statbuf.st_gid);
if(netd.dp_onlyuid != 0 && uid != netd.dp_onlyuid && uid != SUPERUSER
continue;
uid = guid(statbuf.st_uid,statbuf.st_gid);
if(netd.dp_onlyuid != 0 && uid != netd.dp_onlyuid && uid != SUPERUSER
if( !debugflg )
continue;
else
if( !debugflg )
continue;
else
- debug("sending large file %s\n", dirbuf.d_name );
+ debug("sending large file %s\n", dp->d_name );
}
#endif DONTHOLDBIG
if(lFileLen > filesize){
lFileLen = filesize;
}
#endif DONTHOLDBIG
if(lFileLen > filesize){
lFileLen = filesize;
- for(i=0; i<DIRSIZ; i++)
- jname[i] = dirbuf.d_name[i];
+ strcpy(jname,dp->d_name);
uidBest = uid;
}
# ifdef MAXSENDQ
uidBest = uid;
}
# ifdef MAXSENDQ
-static char sccsid[] = "@(#)netq.c 4.1 (Berkeley) %G%";
+static char sccsid[] = "@(#)netq.c 4.2 (Berkeley) %G%";
/* netq - print the netq send queue */
/* netq [-] [mach] */
/* netq - print the netq send queue */
/* netq [-] [mach] */
be sorted correctly */
# define STSIZE 150
be sorted correctly */
# define STSIZE 150
static char jname[16], printlong;
static struct table {
char name[16];
static char jname[16], printlong;
static struct table {
char name[16];
static int hisuid,sumj,nsumj;
static long sumb, nsumb;
static struct stat statbuf;
static int hisuid,sumj,nsumj;
static long sumb, nsumb;
static struct stat statbuf;
-static struct direct dirbuf;
char _sobuf[BUFSIZ];
main(argc,argv)
char _sobuf[BUFSIZ];
main(argc,argv)
char listrest = 0;
int (*compar)();
char printhead = 0;
char listrest = 0;
int (*compar)();
char printhead = 0;
+ register struct direct *dp;
+ df = opendir(str);
if(df == NULL){
perror(str);
exit(EX_OSFILE);
}
stptr = 0;
if(df == NULL){
perror(str);
exit(EX_OSFILE);
}
stptr = 0;
- while(fread(&dirbuf,1,sizeof dirbuf,df)==sizeof dirbuf){
- if(dirbuf.d_ino == 0
- || dirbuf.d_name[0] != 'c'
- || dirbuf.d_name[1] != 'f'
- || stat(dirbuf.d_name,&statbuf) < 0)
+ while((dp = readdir(df)) != NULL){
+ if(dp->d_name[0] != 'c'
+ || dp->d_name[1] != 'f'
+ || stat(dp->d_name,&statbuf) < 0)
- if(mach != dirbuf.d_name[2])continue;
- dirbuf.d_name[0] = 'd';
- if(stat(dirbuf.d_name,&statbuf) < 0)continue;
+ if(mach != dp->d_name[2])continue;
+ dp->d_name[0] = 'd';
+ if(stat(dp->d_name,&statbuf) < 0)continue;
#ifdef MAXSENDQ
if( stptr >= MAXSENDQ ) {
listrest++;
#ifdef MAXSENDQ
if( stptr >= MAXSENDQ ) {
listrest++;
- if(!insert(dirbuf.d_name,getsize(&statbuf))){
+ if(!insert(dp->d_name,getsize(&statbuf))){
more++;
break;
}
}
if(stptr == 0){
printf("Network queue to/thru %s is empty.\n",longname(mach));
more++;
break;
}
}
if(stptr == 0){
printf("Network queue to/thru %s is empty.\n",longname(mach));
return;
}
cp = (char *)&(stack[0].name[0]);
return;
}
cp = (char *)&(stack[0].name[0]);
}
# ifdef MAXSENDQ
if( listrest )
}
# ifdef MAXSENDQ
if( listrest )
printsum();
if(more)printf(" ... more ...\n");
}
printsum();
if(more)printf(" ... more ...\n");
}
b->filesize = t;
}
# ifdef MAXSENDQ
b->filesize = t;
}
# ifdef MAXSENDQ
+listem(dp)
+register struct direct *dp; {
- fseek( df, -(long)(sizeof dirbuf), 1 ); /* backspace over already read entry */
-
- while( fread( &dirbuf, 1, sizeof dirbuf, df ) == sizeof dirbuf ) {
- if( dirbuf.d_ino == 0
- || dirbuf.d_name[0] != 'c'
- || dirbuf.d_name[1] != 'f'
- || stat( dirbuf.d_name, &statbuf ) < 0 )
+ do {
+ if(dp->d_name[0] != 'c'
+ || dp->d_name[1] != 'f'
+ || stat( dp->d_name, &statbuf ) < 0 )
- if( mach != dirbuf.d_name[2] )
+ if( mach != dp->d_name[2] )
- dirbuf.d_name[0] = 'd';
- if( stat( dirbuf.d_name, &statbuf ) < 0 )
+ dp->d_name[0] = 'd';
+ if( stat( dp->d_name, &statbuf ) < 0 )
continue;
if( printlong || guid( statbuf.st_uid, statbuf.st_gid) == hisuid )
process();
else
summarize( getsize( &statbuf ) );
continue;
if( printlong || guid( statbuf.st_uid, statbuf.st_gid) == hisuid )
process();
else
summarize( getsize( &statbuf ) );
+ } while((dp = readdir(df)) != NULL);
-static char sccsid[] = "@(#)netrm.c 4.1 (Berkeley) %G%";
+static char sccsid[] = "@(#)netrm.c 4.2 (Berkeley) %G%";
# include "defs.h"
/* sccs id variable */
# include "defs.h"
/* sccs id variable */
int hisuid, hisgid;
static char visit[26];
static struct stat statbuf;
int hisuid, hisgid;
static char visit[26];
static struct stat statbuf;
-static struct direct dirbuf;
main(argc,argv)
char *argv[];
main(argc,argv)
char *argv[];
}
static pdir(str)
char *str; {
}
static pdir(str)
char *str; {
- FILE *df;
- df = fopen(str,"r");
+ DIR *df;
+ register struct direct *dp;
+ df = opendir(str);
if(df == NULL){
perror(str);
exit(EX_OSFILE);
}
if(df == NULL){
perror(str);
exit(EX_OSFILE);
}
- while(fread(&dirbuf,1,sizeof dirbuf,df) == sizeof dirbuf){
- if(dirbuf.d_ino == 0
- || dirbuf.d_name[0] != 'd'
- || dirbuf.d_name[1] != 'f'
- || stat(dirbuf.d_name,&statbuf) < 0)
+ while((dp = readdir(df)) != NULL){
+ if(dp->d_name[0] != 'd'
+ || dp->d_name[1] != 'f'
+ || stat(dp->d_name,&statbuf) < 0)
continue;
if(guid(statbuf.st_uid,statbuf.st_gid) != hisuid)
continue;
/* kludge in file name */
continue;
if(guid(statbuf.st_uid,statbuf.st_gid) != hisuid)
continue;
/* kludge in file name */
- dirbuf.d_name[3] = dirbuf.d_name[2];
- rmfile(dirbuf.d_name+3);
+ dp->d_name[3] = dp->d_name[2];
+ rmfile(dp->d_name+3);