mars_nwe-0.97.pl01

This commit is contained in:
Mario Fetka 2011-11-13 00:38:56 +01:00
parent 3c4372643c
commit a584c2191f
9 changed files with 145 additions and 50 deletions

View File

@ -544,7 +544,7 @@ static int build_path( NW_PATH *path,
int len, int len,
int only_dir) int only_dir)
/* /*
* fills path structur with the right values * fills path structure with the right values
* if only_dir > 0, then the full path will be interpreted * if only_dir > 0, then the full path will be interpreted
* as directory, in the other way, the last segment of path * as directory, in the other way, the last segment of path
* will be interpreted as fn. * will be interpreted as fn.
@ -700,6 +700,7 @@ int conn_get_kpl_path(NW_PATH *nwpath, int dirhandle,
} else if (dirhandle) lastdirhandle = dirhandle; } else if (dirhandle) lastdirhandle = dirhandle;
#endif #endif
completition = build_path(nwpath, data, len, only_dir); completition = build_path(nwpath, data, len, only_dir);
XDPRINTF((5, 0, "conn_get_kpl_path %s", conn_get_nwpath_name(nwpath)));
if (!completition) completition = build_verz_name(nwpath, dirhandle); if (!completition) completition = build_verz_name(nwpath, dirhandle);
return(completition); return(completition);
} }
@ -1049,7 +1050,7 @@ int insert_new_dir(NW_PATH *nwpath, int inode, int drive, int is_temp, int task)
int freehandle = 0; int freehandle = 0;
int timedhandle = 0; int timedhandle = 0;
/* first look, wether drive is allready in use */ /* first look, whether drive is allready in use */
for (j = 0; j < (int)used_dirs; j++) { for (j = 0; j < (int)used_dirs; j++) {
NW_DIR *d = &(dirs[j]); NW_DIR *d = &(dirs[j]);
if (d->inode && !is_temp && !d->is_temp && (int)d->drive == drive) { if (d->inode && !is_temp && !d->is_temp && (int)d->drive == drive) {
@ -1183,9 +1184,9 @@ int nw_open_dir_handle( int dir_handle,
completition = 0xff; /* Alle Rechte */ completition = 0xff; /* Alle Rechte */
} }
XDPRINTF((5,0,"NW_OPEN_DIR_2: completition = 0x%x", XDPRINTF((5,0,"NW_OPEN_DIR_2: completition = 0x%x",
(int)completition)); completition));
} else { } else {
XDPRINTF((4,0,"NW_OPEN_DIR failed: completition = 0x%x", (int)completition)); XDPRINTF((4,0,"NW_OPEN_DIR failed: completition = -0x%x", -completition));
} }
return(completition); return(completition);
} }
@ -1291,13 +1292,12 @@ static int s_nw_scan_dir_info(int dir_handle,
uint8 *subname, uint8 *subdatetime, uint8 *subname, uint8 *subdatetime,
uint8 *owner, uint8 *wild) uint8 *owner, uint8 *wild)
{ {
int volume; int volume;
int searchsequence; int searchsequence;
int dir_id; int dir_id;
int rights = nw_open_dir_handle(dir_handle, data, len, int rights = nw_open_dir_handle(dir_handle, data, len,
&volume, &dir_id, &searchsequence); &volume, &dir_id, &searchsequence);
if (rights > -1) { if (rights > -1) {
DIR_HANDLE *dh = &(dir_handles[dir_id-1]); DIR_HANDLE *dh = &(dir_handles[dir_id-1]);
struct stat stbuff; struct stat stbuff;
@ -1352,18 +1352,20 @@ int nw_scan_dir_info(int dir_handle, uint8 *data, int len, uint8 *subnr,
int k = len; int k = len;
uint8 *p = data+len; uint8 *p = data+len;
uint8 dirname[256]; uint8 dirname[256];
while (k--) { while (k) {
uint8 c = *--p; uint8 c = *--p;
if (c == '/' || c == '\\' || c == ':') { if (c == '/' || c == '\\' || c == ':') {
p++; p++;
k++;
break; break;
} }
--k;
} }
if (len && k < len) { if (len && k < len) {
strmaxcpy(dirname, p, len-k); strmaxcpy(dirname, p, len-k);
len = k; len = k;
} else dirname[0] = '\0'; } else dirname[0] = '\0';
XDPRINTF((7, 0, "nw_scan_dir_info, dirname=`%s`, len=%d, k=%d",
dirname, len , k));
return(s_nw_scan_dir_info(dir_handle, data, len, subnr, return(s_nw_scan_dir_info(dir_handle, data, len, subnr,
subname, subdatetime, owner, dirname)); subname, subdatetime, owner, dirname));
} }

View File

@ -1,4 +1,4 @@
/* config.h: 01-Mar-96 */ /* config.h: 14-Mar-96 */
/* some of this config is needed by make, others by cc */ /* some of this config is needed by make, others by cc */
#define DO_DEBUG 1 /* Compile in debug code */ #define DO_DEBUG 1 /* Compile in debug code */
#define DO_TESTING 0 #define DO_TESTING 0
@ -7,10 +7,12 @@
# define FILENAME_NW_INI "./nw.ini" /* full name of ini (conf) file */ # define FILENAME_NW_INI "./nw.ini" /* full name of ini (conf) file */
# define PATHNAME_PROGS "." /* path location of progs */ # define PATHNAME_PROGS "." /* path location of progs */
# define PATHNAME_BINDERY "." /* path location of bindery */ # define PATHNAME_BINDERY "." /* path location of bindery */
# define FUNC_17_02_IS_DEBUG 1
#else #else
# define FILENAME_NW_INI "/etc/nwserv.conf" /* full name of ini (conf) file */ # define FILENAME_NW_INI "/etc/nwserv.conf" /* full name of ini (conf) file */
# define PATHNAME_PROGS "/sbin" /* path location of progs */ # define PATHNAME_PROGS "/sbin" /* path location of progs */
# define PATHNAME_BINDERY "/etc" /* path location of bindery */ # define PATHNAME_BINDERY "/etc" /* path location of bindery */
# define FUNC_17_02_IS_DEBUG 0
#endif #endif
#define NETWORK_SERIAL_NMBR 0x44444444L /* Serial Number 4 Byte */ #define NETWORK_SERIAL_NMBR 0x44444444L /* Serial Number 4 Byte */

View File

@ -1,5 +1,5 @@
#if 0 #if 0
#makefile.unx 08-Mar-96 #makefile.unx 10-Mar-96
#endif #endif
VPATH=$(V_VPATH) VPATH=$(V_VPATH)
@ -9,8 +9,9 @@ C=.c
V_H=0 V_H=0
V_L=97 V_L=97
P_L=0 P_L=1
#define D_P_L 0
#define D_P_L 1
DISTRIB=mars_nwe DISTRIB=mars_nwe
#if D_P_L #if D_P_L
DISTRIBF=$(DISTRIB)-$(V_H).$(V_L).pl$(P_L) DISTRIBF=$(DISTRIB)-$(V_H).$(V_L).pl$(P_L)
@ -160,20 +161,20 @@ echo "********************************************************"; \
echo ""; \ echo ""; \
fi; cd $(OBJDIR) ) fi; cd $(OBJDIR) )
n_clean1: clean_d:
cd $(VPATH) && (\ cd $(VPATH) && (\
find . \( -name .e.pck -o -name '~*' -o -name '*~' -o -name core \) \ find $(DISTRIB) \( -name .e.pck -o -name '~*' -o -name '*~' -o -name core \) \
-exec rm {} \; \ -exec rm {} \; \
; cd $(OBJDIR)) ; cd $(OBJDIR))
n_clean: n_clean1 n_clean:
rm -f *.o rm -f *.o
cd $(VPATH) && (rm -f $(PROGS); cd $(OBJDIR) ) cd $(VPATH) && (rm -f $(PROGS); cd $(OBJDIR) )
n_distclean: n_clean n_distclean: n_clean clean_d
cd $(VPATH) && (rm -f *.dir *.pag; cd $(OBJDIR)) cd $(VPATH) && (rm -f *.dir *.pag; cd $(OBJDIR))
n_make_dir: n_clean1 make_dir:
cd $(VPATH) && (rm -rf $(OBJDIR)/$(VPATH)/$(DISTRIB) \ cd $(VPATH) && (rm -rf $(OBJDIR)/$(VPATH)/$(DISTRIB) \
; mkdir $(DISTRIB) \ ; mkdir $(DISTRIB) \
; mkdir $(DISTRIB)/examples \ ; mkdir $(DISTRIB)/examples \
@ -194,7 +195,7 @@ n_make_dir: n_clean1
$(DISTRIB)/doc/. \ $(DISTRIB)/doc/. \
; cd $(OBJDIR) ) ; cd $(OBJDIR) )
n_diff: n_make_dir n_diff: make_dir clean_d
cd $(VPATH) && ( \ cd $(VPATH) && ( \
makepatch $(DISTRIB).org $(DISTRIB) > $(PATCHF) \ makepatch $(DISTRIB).org $(DISTRIB) > $(PATCHF) \
; gzip -9 -f $(PATCHF) \ ; gzip -9 -f $(PATCHF) \

View File

@ -1,5 +1,5 @@
/* ncpserv.c */ /* ncpserv.c */
#define REVISION_DATE "10-Mar-96" #define REVISION_DATE "14-Mar-96"
/* (C)opyright (C) 1993,1996 Martin Stover, Marburg, Germany /* (C)opyright (C) 1993,1996 Martin Stover, Marburg, Germany
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
@ -496,6 +496,26 @@ static int handle_fxx(CONNECTION *c, int gelen, int func)
} }
break; break;
#if FUNC_17_02_IS_DEBUG
case 0x02 : { /* I hope this is call isn't used */
/* now missused as a debug switch :) */
struct XDATA {
uint8 nw_debug; /* old level */
} *xdata = (struct XDATA*) responsedata;
errorp(2, "0x17, ufunc=2", "Got debugchange =%d for module=%d",
(int)*(rdata+1), (int) *rdata);
if (*rdata == NWCONN)
return(-1); /* let nwconn do the call */
if (*rdata == NCPSERV) {
xdata->nw_debug = (uint8) nw_debug;
nw_debug = (int) *(rdata+1);
data_len = 1;
} else completition=0xff;
}
break;
#endif
case 0x0c : { /* Verify Serialization */ case 0x0c : { /* Verify Serialization */
completition=0xff; completition=0xff;
} }

9
net.h
View File

@ -116,6 +116,15 @@
# define DO_DEBUG 1 # define DO_DEBUG 1
#endif #endif
#if DO_DEBUG
# ifndef FUNC_17_02_IS_DEBUG
# define FUNC_17_02_IS_DEBUG 0
# endif
#else
# undef FUNC_17_02_IS_DEBUG
# define FUNC_17_02_IS_DEBUG 0
#endif
#ifndef MAX_CONNECTIONS #ifndef MAX_CONNECTIONS
# define MAX_CONNECTIONS 5 /* maximum Number of Connections */ # define MAX_CONNECTIONS 5 /* maximum Number of Connections */
#endif #endif

View File

@ -244,8 +244,6 @@ static int do_17_17(void)
return(-1); return(-1);
} }
static int get_network_serial_number(void) static int get_network_serial_number(void)
{ {
uint8 data[] = {0, 1, 0x12}; uint8 data[] = {0, 1, 0x12};
@ -317,6 +315,26 @@ static int file_search_cont(DIR_IDS *di, int seq,
return(-1); return(-1);
} }
static int scan_dir_info(int dirhandle, char *path, int sub_dir)
{
uint8 *p=requestdata;
uint8 pathlen= (path) ? strlen(path) : 0;
*p++ = 0;
*p++ = pathlen+4;
*p++ = 0x2;
*p++ = dirhandle;
U16_TO_BE16(sub_dir, p);
p+=2;
*p++ = pathlen;
memcpy(p, path, pathlen);
VDATA(0x16, pathlen+7 , "SCAN DIR INFO");
if (!handle_event()) {
return((int)GET_BE16(responsedata+26));
}
return(-1);
}
static int allocate_dir_handle(int dirhandle, static int allocate_dir_handle(int dirhandle,
int drive, int drive,
char *path, char *path,
@ -601,8 +619,7 @@ static int read_datei(int fh, int offs, int size)
} }
#if 0
static void test1(void) static void test1(void)
{ {
int dirhandle = allocate_dir_handle(0, 'F', "SYS:PUBLIC", 0); int dirhandle = allocate_dir_handle(0, 'F', "SYS:PUBLIC", 0);
@ -611,6 +628,21 @@ static void test1(void)
scan_irgendwas(dirhandle, 6, "NET$LOG.DAT"); scan_irgendwas(dirhandle, 6, "NET$LOG.DAT");
} }
} }
#endif
static void test1(void)
{
int dirhandle = allocate_dir_handle(0, 'd', "SYS:", 1);
if (dirhandle > -1) {
int i;
scan_dir_info(dirhandle, "SYSTEM", 1);
scan_dir_info(dirhandle, "SYSTE*", 1);
i = scan_dir_info(dirhandle, "SYSTEM\\*", 1);
while (i > -1)
i = scan_dir_info(dirhandle, "", i+1);
}
}
static void test2(void) static void test2(void)
{ {

View File

@ -1,4 +1,4 @@
/* nwconn.c 01-Mar-96 */ /* nwconn.c 14-Mar-96 */
/* one process / connection */ /* one process / connection */
/* (C)opyright (C) 1993,1996 Martin Stover, Marburg, Germany /* (C)opyright (C) 1993,1996 Martin Stover, Marburg, Germany
@ -244,9 +244,10 @@ static void handle_ncp_serv()
/******** Scan Dir Info ****************/ /******** Scan Dir Info ****************/
struct INPUT { struct INPUT {
uint8 header[7]; /* Requestheader */ uint8 header[7]; /* Requestheader */
uint8 div[3]; /* 0x0, dlen, typ */ uint8 div[3]; /* 0x0, dlen, typ */
uint8 dir_handle; /* Verzeichnis Handle */ uint8 dir_handle; /* Verzeichnis Handle */
uint8 sub_dir_nmbr[2]; /* HI LOW */ uint8 sub_dir_nmbr[2]; /* HI LOW */
/* firsttime 1 */
uint8 len; /* kann auch 0 sein */ uint8 len; /* kann auch 0 sein */
uint8 path[2]; uint8 path[2];
} *input = (struct INPUT *) (ncprequest); } *input = (struct INPUT *) (ncprequest);
@ -635,8 +636,27 @@ static void handle_ncp_serv()
#if 1 #if 1
case 0x17 : { /* FILE SERVER ENVIRONMENT */ case 0x17 : { /* FILE SERVER ENVIRONMENT */
/* uint8 len = *(requestdata+1); */ /* uint8 len = *(requestdata+1); */
uint8 ufunc = *(requestdata+2); uint8 ufunc = *(requestdata+2);
uint8 *rdata = requestdata+3;
switch (ufunc) { switch (ufunc) {
#if FUNC_17_02_IS_DEBUG
case 0x02 : {
/* I hope this is call isn't used */
/* now missused as a debug switch :) */
struct XDATA {
uint8 nw_debug; /* old level */
} *xdata = (struct XDATA*) responsedata;
if (*rdata == NWCONN) {
xdata->nw_debug = (uint8)org_nw_debug;
nw_debug = org_nw_debug = (int) *(rdata+1);
data_len = 1;
} else completition=0xff;
}
break;
#endif
case 0x14: case 0x14:
case 0x18: { /* ncpserv have change the structure */ case 0x18: { /* ncpserv have change the structure */
struct INPUT { struct INPUT {
@ -815,6 +835,20 @@ static void handle_ncp_serv()
else completition=0xfb; /* request not known */ else completition=0xfb; /* request not known */
} break; } break;
case 0x3d : { /* commit file, flush file buffers */
struct INPUT {
uint8 header[7]; /* Requestheader */
uint8 reserve;
uint8 ext_fhandle[2]; /* all zero */
uint8 fhandle[4]; /* filehandle */
} *input = (struct INPUT *)ncprequest;
uint32 fhandle = GET_BE32(input->fhandle);
XDPRINTF((2,0, "TODO: COMMIT FILE:fhandle=%ld", fhandle));
/* TODO */
;
} break;
case 0x3e : { /* FILE SEARCH INIT */ case 0x3e : { /* FILE SEARCH INIT */
/* returns dhandle for searchings */ /* returns dhandle for searchings */
int dir_handle = (int)*requestdata; int dir_handle = (int)*requestdata;
@ -840,18 +874,6 @@ static void handle_ncp_serv()
} else completition = (uint8) -rights; } else completition = (uint8) -rights;
} break; } break;
case 0x3d : { /* commit file, flush file buffers */
struct INPUT {
uint8 header[7]; /* Requestheader */
uint8 reserve;
uint8 ext_fhandle[2]; /* all zero */
uint8 fhandle[4]; /* filehandle */
} *input = (struct INPUT *)ncprequest;
uint32 fhandle = GET_BE32(input->fhandle);
XDPRINTF((2,0, "TODO: COMMIT FILE:fhandle=%ld", fhandle));
/* TODO */
;
} break;
case 0x3f : { /* file search continue */ case 0x3f : { /* file search continue */
/* Dir_id is from file search init */ /* Dir_id is from file search init */
@ -896,7 +918,7 @@ static void handle_ncp_serv()
} }
break; break;
case 0x40 : /* GET File Mode ?? */ case 0x40 : /* Search for a File */
{ {
struct INPUT { struct INPUT {
uint8 header[7]; /* Requestheader */ uint8 header[7]; /* Requestheader */
@ -907,8 +929,8 @@ static void handle_ncp_serv()
uint8 data[2]; /* Name */ uint8 data[2]; /* Name */
} *input = (struct INPUT *)ncprequest; } *input = (struct INPUT *)ncprequest;
struct OUTPUT { struct OUTPUT {
uint8 sequenz[2]; /* Antwort Sequenz */ uint8 sequenz[2]; /* answer sequence */
uint8 reserve2[2]; /* z.B 0x0 0x0 */ uint8 reserved[2]; /* z.B 0x0 0x0 */
union { union {
NW_DIR_INFO d; NW_DIR_INFO d;
NW_FILE_INFO f; NW_FILE_INFO f;

View File

@ -357,6 +357,9 @@ int nw_lock_datei(int fhandle, int offset, int size, int do_lock)
flockd.l_start = offset; flockd.l_start = offset;
flockd.l_len = size; flockd.l_len = size;
result = fcntl(fh->fd, F_SETLK, &flockd); result = fcntl(fh->fd, F_SETLK, &flockd);
XDPRINTF((2, 0, "nw_%s_datei result=%d, fh=%d, offset=%d, size=%d",
(do_lock) ? "lock" : "unlock", result, fhandle, offset, size));
if (!result) return(0); if (!result) return(0);
else return(-0x21); /* LOCK Violation */ else return(-0x21); /* LOCK Violation */
} }

16
tools.c
View File

@ -31,6 +31,8 @@ FILE *logfile=stdout;
static int in_module=0; /* in which process i am ? */ static int in_module=0; /* in which process i am ? */
static int connection=0; /* which connection (nwconn) */ static int connection=0; /* which connection (nwconn) */
static int my_pid = -1;
static void (*sigsegv_func)(int isig);
static char *modnames[] = static char *modnames[] =
{ "???????", { "???????",
"NWSERV ", "NWSERV ",
@ -121,7 +123,7 @@ void errorp(int mode, char *what, char *p, ...)
int errnum = errno; int errnum = errno;
FILE *lologfile = logfile; FILE *lologfile = logfile;
while (1) { while (1) {
if (mode) fprintf(lologfile, "\n!! %s %d:PANIC !!\n", get_modstr(), connection); if (mode==1) fprintf(lologfile, "\n!! %s %d:PANIC !!\n", get_modstr(), connection);
if (errnum >= 0 && errnum < _sys_nerr) if (errnum >= 0 && errnum < _sys_nerr)
fprintf(lologfile, "%s %d:%s:%s\n", get_modstr(), connection, what, _sys_errlist[errnum]); fprintf(lologfile, "%s %d:%s:%s\n", get_modstr(), connection, what, _sys_errlist[errnum]);
else else
@ -219,10 +221,11 @@ void get_ini_debug(int module)
static void sig_segv(int isig) static void sig_segv(int isig)
{ {
char *s= "PANIC signal SIGSEGV" ; char *s= "!!!! PANIC signal SIGSEGV at pid=%d !!!!!\n" ;
XDPRINTF((0, 0, s)); XDPRINTF((0, 0, s, my_pid));
fprintf(stderr, s); fprintf(stderr, "\n");
exit(99); fprintf(stderr, s, my_pid);
(*sigsegv_func)(isig);
} }
void init_tools(int module, int conn) void init_tools(int module, int conn)
@ -269,7 +272,8 @@ void init_tools(int module, int conn)
XDPRINTF((1, 0, "Starting Version: %d.%02dpl%d", XDPRINTF((1, 0, "Starting Version: %d.%02dpl%d",
_VERS_H_, _VERS_L_, _VERS_P_ )); _VERS_H_, _VERS_L_, _VERS_P_ ));
} }
signal(SIGSEGV, sig_segv); sigsegv_func = signal(SIGSEGV, sig_segv);
my_pid = getpid();
} }
void exit_tools(int what) void exit_tools(int what)