mars_nwe-0.98.pl00
This commit is contained in:
parent
6331687e52
commit
79edfdd7a3
3
Makefile
3
Makefile
@ -45,6 +45,9 @@ clean: mk.li nw.ini
|
||||
distrib: mk.li nw.ini
|
||||
./mk.li $@
|
||||
|
||||
distrib_bin: mk.li nw.ini
|
||||
./mk.li $@
|
||||
|
||||
diff:
|
||||
./mk.li $@
|
||||
|
||||
|
101
connect.c
101
connect.c
@ -1,4 +1,4 @@
|
||||
/* connect.c 04-May-96 */
|
||||
/* connect.c 13-Jul-96 */
|
||||
/* (C)opyright (C) 1993,1996 Martin Stover, Marburg, Germany
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@ -34,15 +34,14 @@
|
||||
static int default_uid=-1;
|
||||
static int default_gid=-1;
|
||||
|
||||
static int act_uid=-1;
|
||||
static int act_gid=-1;
|
||||
|
||||
#include "nwvolume.h"
|
||||
#include "nwfile.h"
|
||||
#include "connect.h"
|
||||
|
||||
NW_DIR dirs[MAX_NW_DIRS];
|
||||
int used_dirs=0;
|
||||
int act_uid=-1;
|
||||
int act_gid=-1;
|
||||
|
||||
static int connect_is_init = 0;
|
||||
|
||||
@ -227,48 +226,48 @@ static int x_str_match(uint8 *s, uint8 *p)
|
||||
int not = 0;
|
||||
uint found = 0;
|
||||
while ( (pc = *p++) != 0) {
|
||||
|
||||
if (state != 100) {
|
||||
if (pc == 255 && (*p == '*' || *p == '?'
|
||||
|| *p==0xaa || *p==0xae || *p==0xbf || *p=='.')) {
|
||||
pc=*p++;
|
||||
}
|
||||
|
||||
switch (pc) {
|
||||
case 0xaa: pc='*'; break;
|
||||
case 0xae: pc='.'; break;
|
||||
case 0xbf: pc='?'; break;
|
||||
}
|
||||
}
|
||||
|
||||
switch (state){
|
||||
case 0 :
|
||||
switch (pc) {
|
||||
case 255: if (*p == '*' || *p == '?'
|
||||
|| *p==0xaa || *p==0xae || *p=='.') continue;
|
||||
break;
|
||||
|
||||
case '\\': /* any following char */
|
||||
if (*p++ != *s++) return(0);
|
||||
break;
|
||||
|
||||
case '?' : if ( (sc = *s++) == '.' || sc == '\0' ) {
|
||||
uint8 *pp=p;
|
||||
while (*pp=='?' || *pp=='*') ++pp;
|
||||
if (*pp=='.') p=++pp;
|
||||
else if (*pp || sc) return(0);
|
||||
if (!sc) {
|
||||
while (*pp=='?' || *pp=='*') ++pp;
|
||||
return((*pp) ? 0 : 1);
|
||||
}
|
||||
}
|
||||
case '?' : if (!*s || (sc = *s++) == '.')
|
||||
state = 10;
|
||||
break;
|
||||
|
||||
case '.' :
|
||||
if (!*s && (!*p || *p == '*' || *p == '?')) return(1);
|
||||
if (pc != *s++) return(0);
|
||||
if (*p == '*') return(1);
|
||||
case '.' : if (*s && pc != *s++) return(0);
|
||||
break;
|
||||
|
||||
case '*' :
|
||||
if (!*p) return(1);
|
||||
while (*s){
|
||||
case '*' : if (!*p) return(1); /* last star */
|
||||
while (*s) {
|
||||
if (x_str_match(s, p) == 1) return(1);
|
||||
else if (*s == '.') return(0);
|
||||
++s;
|
||||
}
|
||||
return((*p == '.' && *(p+1) == '*') ? 1 : 0);
|
||||
state = 30;
|
||||
break;
|
||||
|
||||
case '[' : if ( (*p == '!') || (*p == '^') ){
|
||||
++p;
|
||||
not = 1;
|
||||
}
|
||||
state = 1;
|
||||
state = 100;
|
||||
continue;
|
||||
|
||||
default : if (pc != *s++) return(0); /* normal char */
|
||||
@ -277,7 +276,21 @@ static int x_str_match(uint8 *s, uint8 *p)
|
||||
} /* switch */
|
||||
break;
|
||||
|
||||
case 1 : /* Bereich von Zeichen */
|
||||
case 10 : if (pc != '*' && pc != '?' ) {
|
||||
if (pc == '.')
|
||||
state = 0;
|
||||
else return(0);
|
||||
}
|
||||
break;
|
||||
|
||||
case 30: if (pc != '.') return(0);
|
||||
state = 31;
|
||||
break;
|
||||
|
||||
case 31: if (pc != '*' ) return(0);
|
||||
break;
|
||||
|
||||
case 100 : /* Bereich von Zeichen */
|
||||
sc = *s++;
|
||||
found = not;
|
||||
if (!sc) return(0);
|
||||
@ -314,7 +327,7 @@ int fn_match(uint8 *s, uint8 *p, int options)
|
||||
int pf=0;
|
||||
for (; *ss; ss++){
|
||||
if (*ss == '.') {
|
||||
if (pf++) return(0); /* no 2. pouint */
|
||||
if (pf++) return(0); /* no 2. point */
|
||||
len=0;
|
||||
} else {
|
||||
++len;
|
||||
@ -1246,7 +1259,7 @@ int nw_init_connect(void)
|
||||
int nw_free_handles(int task)
|
||||
/*
|
||||
* if task== -1 then all is initialized
|
||||
* else the temp handles of the actual task ( and greater )
|
||||
* else the temp handles of the actual task
|
||||
* are deleted. I hope this is right. !??
|
||||
*/
|
||||
{
|
||||
@ -1255,12 +1268,8 @@ int nw_free_handles(int task)
|
||||
NW_DIR *d = &(dirs[0]);
|
||||
int k = used_dirs;
|
||||
while (k--) {
|
||||
#if 0
|
||||
if (d->is_temp && d->task >= task) {
|
||||
#else
|
||||
if (d->is_temp && d->task == task) {
|
||||
/* only actual task */
|
||||
#endif
|
||||
xfree(d->path);
|
||||
d->volume = 0;
|
||||
d->inode = 0;
|
||||
@ -1276,30 +1285,27 @@ int nw_free_handles(int task)
|
||||
int xinsert_new_dir(int volume, uint8 *path, int inode, int drive, int is_temp, int task)
|
||||
{
|
||||
int j = 0;
|
||||
time_t lowtime = time(NULL);
|
||||
int freehandle = 0;
|
||||
#if 0
|
||||
time_t lowtime = time(NULL);
|
||||
int timedhandle = 0;
|
||||
|
||||
#endif
|
||||
/* first look, whether drive is allready in use */
|
||||
for (j = 0; j < (int)used_dirs; j++) {
|
||||
NW_DIR *d = &(dirs[j]);
|
||||
if (!d->inode) freehandle = j+1;
|
||||
else if (!is_temp && !d->is_temp
|
||||
&& (int)d->drive == drive
|
||||
if (!d->inode)
|
||||
freehandle = j+1;
|
||||
#if 0
|
||||
&& (int)d->task == task
|
||||
#endif
|
||||
) {
|
||||
(void)change_dir_entry(d, volume, path, inode, drive, is_temp, 1, task);
|
||||
return(++j);
|
||||
} else if (!d->inode) freehandle = j+1;
|
||||
else if (d->is_temp && d->timestamp < lowtime) {
|
||||
} else if (d->is_temp && d->timestamp < lowtime) {
|
||||
timedhandle = j+1;
|
||||
lowtime = d->timestamp;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
if (!freehandle && used_dirs < MAX_NW_DIRS) freehandle = ++used_dirs;
|
||||
#if 0
|
||||
if (!freehandle) freehandle = timedhandle;
|
||||
#endif
|
||||
if (freehandle){
|
||||
(void)change_dir_entry(&(dirs[freehandle-1]),
|
||||
volume, path, inode,
|
||||
@ -1469,7 +1475,8 @@ int nw_get_directory_path(int dir_handle, uint8 *name)
|
||||
{
|
||||
int result = -0x9b;
|
||||
name[0] = '\0';
|
||||
if (dir_handle > 0 && --dir_handle < (int)used_dirs) {
|
||||
if (dir_handle > 0 && --dir_handle < (int)used_dirs
|
||||
&& dirs[dir_handle].inode) {
|
||||
int volume = dirs[dir_handle].volume;
|
||||
if (volume > -1 && volume < used_nw_volumes){
|
||||
result=sprintf((char*)name, "%s:%s", nw_volumes[volume].sysname, dirs[dir_handle].path);
|
||||
|
@ -133,7 +133,8 @@ extern int nw_scan_dir_info(int dir_handle, uint8 *data, int len,
|
||||
#define MAX_NW_DIRS 255
|
||||
extern NW_DIR dirs[MAX_NW_DIRS];
|
||||
extern int used_dirs;
|
||||
|
||||
extern int act_uid;
|
||||
extern int act_gid;
|
||||
|
||||
extern int conn_get_kpl_path(NW_PATH *nwpath, int dirhandle,
|
||||
uint8 *data, int len, int only_dir) ;
|
||||
|
13
doc/CHANGES
13
doc/CHANGES
@ -1,5 +1,6 @@
|
||||
Sorry, this is in German only.
|
||||
Aenderungen in mars_nwe bis zum : 24-Jun-96
|
||||
User important notes are in the NEWS file.
|
||||
Aenderungen in mars_nwe bis zum : 22-Jul-96
|
||||
--------------------------------
|
||||
Erste 'oeffentliche' Version
|
||||
^^^^^^^^^^ VERSION 0.94 ^^^^^^^^
|
||||
@ -153,7 +154,15 @@ Erste 'oeffentliche' Version
|
||||
- Dateien werden nun mittels mmap gelesen.
|
||||
neuer config.h Schalter USE_MMAP
|
||||
<----- ^^^^^^^^^^ pl9 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
^^^^^^^^^^ VERSION 0.97 ^^^^^^^^
|
||||
- automatischen Ueberschreiben von bestimmten Directory Handles
|
||||
entfernt. War von Anfang an falsch verstanden. :(
|
||||
- namespace routinen verbessert/erweitert.
|
||||
namespace OS/2 rudimentaer eingebaut.
|
||||
- wildcardhandling wiederum geaendert.
|
||||
- Dummy Routinen fuer OS/2 extended attributes eingebaut.
|
||||
- NFS-namespace rudimentaer eingebaut.
|
||||
<----- ^^^^^^^^^^ pl0 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
|
||||
|
||||
|
@ -129,5 +129,5 @@ the mars_nwe-package.
|
||||
|
||||
good luck :-)
|
||||
|
||||
Martin Stover <mstover@freeway.de>
|
||||
Martin Stover <mstover@stover.f.eunet.de>
|
||||
|
||||
|
23
doc/NEWS
23
doc/NEWS
@ -1,13 +1,20 @@
|
||||
# in this files are important notes for user of mars_nwe.
|
||||
------22-Jul-96--- 0.98.pl0 ----------
|
||||
- problems with directory handles eliminated.
|
||||
(missunderstood 'creat permanent directory handle' call :( )
|
||||
- now poor OS/2 and NFS namespace added.
|
||||
- dummy routine for OS/2 extended attributes.
|
||||
(OS/2 WP needs it)
|
||||
------12-Jul-96--- 0.97.pl9 ----------
|
||||
automatic adding and removing of ipx-interfaces. (internal router)
|
||||
now running under linux/sparc.
|
||||
better file locking/sharing.
|
||||
some unix->dos attribute handling now.
|
||||
better read performance (mmap(ing))
|
||||
A not yet assigned mars_nwe user is now automatic assigned
|
||||
to a Linux user with same name when the password is changed and the
|
||||
new password is not null.
|
||||
- better automatic handling of adding and removing
|
||||
of ipx-interfaces. (internal router)
|
||||
- now running under linux/sparc.
|
||||
- better file locking/sharing.
|
||||
- some unix->dos attribute handling now.
|
||||
- better read performance (mmap(ing)) config.h: USE_MMAP
|
||||
- A not yet assigned mars_nwe user is now automatic assigned
|
||||
to a Linux user with same name when the password is changed and the
|
||||
new password is not null.
|
||||
------------------ 0.97.pl7 ----------
|
||||
Crypted Change password call implemented.
|
||||
------05-May-96--- 0.97.pl3 ----------
|
||||
|
@ -1,15 +1,15 @@
|
||||
Begin3
|
||||
Title: mars_nwe
|
||||
Version: 0.97.pl9
|
||||
Entered-date: 12-Jul-96
|
||||
Version: 0.98
|
||||
Entered-date: 22-Jul-96
|
||||
Description: Full netware-emulator (src), beta.
|
||||
Supports file-services, bindery-services,
|
||||
printing-services, routing-services.
|
||||
Keywords: novell, netware, server, ipx, ncp, tli
|
||||
Author: mstover@freeway.de (Martin Stover)
|
||||
Maintained-by: mstover@freeway.de (Martin Stover)
|
||||
Author: mstover@stover.f.eunet.de (Martin Stover)
|
||||
Maintained-by: mstover@stover.f.eunet.de (Martin Stover)
|
||||
Primary-site: ftp.gwdg.de:/pub/linux/misc/ncpfs
|
||||
160kB mars_nwe-0.97.pl9.tgz
|
||||
165kB mars_nwe-0.98.tgz
|
||||
Alternate-site: ftp.uni-duisburg.de /pub/linux/ipxware
|
||||
Platforms: Linux (1.2.xx, 1.3.xx, 2.xx), UnixWare (2.xx)
|
||||
Copying-policy: GNU
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* config.h: 21-May-96 */
|
||||
/* config.h: 18-Jul-96 */
|
||||
/* some of this config is needed by make, others by cc */
|
||||
|
||||
#define DO_DEBUG 1 /* compile in debug code */
|
||||
@ -35,6 +35,12 @@
|
||||
#define IPX_DATA_GR_546 1 /* allow ipx packets > 546+30 Byte */
|
||||
|
||||
#define USE_MMAP 1 /* use mmap systen call */
|
||||
|
||||
#if 0
|
||||
#define SOCK_EXTERN 0x8005 /* creat socket for external access */
|
||||
/* i.e. Xmarsmon from H. Buchholz */
|
||||
#endif
|
||||
|
||||
/* <--------------------------------------------------------------------> */
|
||||
#define MAX_NW_VOLS 10 /* max. number of mars_nwe-volumes */
|
||||
#define MAX_FILE_HANDLES_CONN 80 /* max. number of open files per */
|
||||
@ -42,7 +48,7 @@
|
||||
/* <--------------- new namespace services call -----------------------> */
|
||||
#define MAX_DIR_BASE_ENTRIES 50 /* max. cached base entries per */
|
||||
/* connection */
|
||||
#define WITH_NAME_SPACE_CALLS 0 /* Namespace Calls are only minimal */
|
||||
#define WITH_NAME_SPACE_CALLS 1 /* Namespace Calls are only minimal */
|
||||
/* supported so far. */
|
||||
/* To enable testing of them this */
|
||||
/* entry must be changed to '1' and */
|
||||
|
@ -2,7 +2,7 @@
|
||||
# This is the configuration-file for "mars_nwe", a free netware-emulator
|
||||
# for Linux.
|
||||
#
|
||||
# last change: 16-May-96
|
||||
# last change: 17-Jul-96
|
||||
|
||||
# This file specifies which Linux-resources (printers, users, directories)
|
||||
# should be accessible to the DOS-clients via "mars_nwe". Furthermore
|
||||
@ -71,6 +71,9 @@
|
||||
# between several devices/namespaces for one volume.
|
||||
# p "PIPE"-filesystem. All files are pipe commands.
|
||||
# See `doc/PIPE-FS'.
|
||||
#
|
||||
# O + OS/2 namespace.
|
||||
# N + NFS namespace.
|
||||
# -------------------------------------------------------------------------
|
||||
#
|
||||
# Examples:
|
||||
|
13
makefile.unx
13
makefile.unx
@ -1,5 +1,5 @@
|
||||
#if 0
|
||||
#makefile.unx 10-Jul-96
|
||||
#makefile.unx 12-Jul-96
|
||||
#endif
|
||||
|
||||
VPATH=$(V_VPATH)
|
||||
@ -8,10 +8,10 @@ O=.o
|
||||
C=.c
|
||||
|
||||
V_H=0
|
||||
V_L=97
|
||||
P_L=9
|
||||
V_L=98
|
||||
P_L=0
|
||||
|
||||
#define D_P_L 1
|
||||
#define D_P_L 0
|
||||
DISTRIB=mars_nwe
|
||||
#if D_P_L
|
||||
DISTRIBF=$(DISTRIB)-$(V_H).$(V_L).pl$(P_L)
|
||||
@ -247,11 +247,10 @@ n_distrib: n_diff
|
||||
; cd $(OBJDIR) )
|
||||
|
||||
n_distrib_bin:
|
||||
cd $(VPATH) && (tar cvzf /tmp/$(DISTRIB).bin.tgz \
|
||||
cd $(VPATH) && (/usr/local/bin/cdar cb /tmp/mars_nwb.cda \
|
||||
$(PROGS) \
|
||||
COPYING \
|
||||
README \
|
||||
examples \
|
||||
doc \
|
||||
; cd $(OBJDIR))
|
||||
|
||||
|
||||
|
341
namspace.c
341
namspace.c
@ -1,4 +1,4 @@
|
||||
/* namspace.c 13-May-96 : NameSpace Services, mars_nwe */
|
||||
/* namspace.c 17-Jul-96 : NameSpace Services, mars_nwe */
|
||||
|
||||
/* !!!!!!!!!!!! NOTE !!!!!!!!!! */
|
||||
/* Its very dirty till now. */
|
||||
@ -42,6 +42,7 @@
|
||||
typedef struct {
|
||||
int volume; /* Volume Number */
|
||||
int has_wild; /* fn has wildcards */
|
||||
int namespace; /* which namespace do we use here*/
|
||||
struct stat statb; /* stat buff */
|
||||
uint8 *fn; /* points to last entry of path */
|
||||
uint8 path[512]; /* path + fn */
|
||||
@ -56,9 +57,9 @@ typedef struct {
|
||||
|
||||
typedef struct {
|
||||
uint32 basehandle;
|
||||
int namespace; /* namespace of this entry */
|
||||
int slot; /* act slot in table */
|
||||
int locked; /* if locked then do not remove */
|
||||
/* and do not move till end */
|
||||
DIR_SEARCH_STRUCT *dir; /* for dir searches */
|
||||
N_NW_PATH nwpath;
|
||||
} DIR_BASE_ENTRY;
|
||||
@ -66,14 +67,22 @@ typedef struct {
|
||||
static DIR_BASE_ENTRY *dir_base[MAX_DIR_BASE_ENTRIES];
|
||||
static int anz_dbe = 0;
|
||||
|
||||
static void init_nwpath(N_NW_PATH *nwpath)
|
||||
static void init_nwpath(N_NW_PATH *nwpath, int namespace)
|
||||
{
|
||||
nwpath->volume = -1;
|
||||
nwpath->namespace = namespace;
|
||||
nwpath->has_wild = 0;
|
||||
nwpath->fn = nwpath->path;
|
||||
*(nwpath->path) = '\0';
|
||||
}
|
||||
|
||||
static void norm_nwpath_fn(N_NW_PATH *nwpath)
|
||||
{
|
||||
nwpath->fn = (uint8*)strrchr((char*)nwpath->path, '/');
|
||||
if (nwpath->fn) nwpath->fn++;
|
||||
else nwpath->fn=nwpath->path;
|
||||
}
|
||||
|
||||
static char *xnwpath_2_unix(N_NW_PATH *nwpath, int modus,
|
||||
int allocate_extra, uint8 *extra_path)
|
||||
/*
|
||||
@ -127,7 +136,8 @@ static char *xnwpath_2_unix(N_NW_PATH *nwpath, int modus,
|
||||
len += len_extra;
|
||||
}
|
||||
*p = '\0';
|
||||
if (nw_volumes[volume].options & VOL_OPTION_DOWNSHIFT)
|
||||
if (nwpath->namespace == NAME_DOS
|
||||
&& nw_volumes[volume].options & VOL_OPTION_DOWNSHIFT)
|
||||
downstr((uint8*)pp);
|
||||
}
|
||||
if (!allocate_extra) {
|
||||
@ -182,8 +192,9 @@ static void free_dbe_ptr(DIR_BASE_ENTRY *dbe)
|
||||
}
|
||||
|
||||
static int base_open_seek_dir(DIR_BASE_ENTRY *dbe, uint32 offset)
|
||||
/* opens a directory struct for searching */
|
||||
{
|
||||
int result = ((dbe->nwpath.statb.st_mode & S_IFMT) != S_IFDIR) ? -0xff : 0;
|
||||
int result = S_ISDIR(dbe->nwpath.statb.st_mode) ? 0 : -0xff;
|
||||
if (!result) {
|
||||
if (offset == MAX_U32) {
|
||||
free_dbe_dir(dbe);
|
||||
@ -204,10 +215,13 @@ static DIR_BASE_ENTRY *allocate_dbe_p(int namespace)
|
||||
int j=-1;
|
||||
int to_use=-1;
|
||||
DIR_BASE_ENTRY **pdbe=(DIR_BASE_ENTRY**) NULL;
|
||||
if (namespace) return(NULL); /* TODO: more namespaces */
|
||||
|
||||
/* if (namespace) return(NULL); /* TODO: more namespaces */
|
||||
|
||||
while (++j < anz_dbe && NULL != *(pdbe = &(dir_base[j])) ){
|
||||
if (to_use < 0 && !(*pdbe)->basehandle && !(*pdbe)->locked) to_use=j;
|
||||
}
|
||||
|
||||
if (j == anz_dbe) {
|
||||
if (anz_dbe == MAX_DIR_BASE_ENTRIES) { /* return(-0xff); */
|
||||
if (to_use > -1) j=to_use;
|
||||
@ -218,10 +232,10 @@ static DIR_BASE_ENTRY *allocate_dbe_p(int namespace)
|
||||
free_dbe_ptr(*pdbe);
|
||||
} else pdbe = &(dir_base[anz_dbe++]);
|
||||
}
|
||||
|
||||
*pdbe = (DIR_BASE_ENTRY*)xcmalloc(sizeof(DIR_BASE_ENTRY));
|
||||
(*pdbe)->namespace = namespace;
|
||||
(*pdbe)->slot = j;
|
||||
init_nwpath(&((*pdbe)->nwpath));
|
||||
init_nwpath(&((*pdbe)->nwpath), namespace);
|
||||
return(*pdbe);
|
||||
}
|
||||
|
||||
@ -249,14 +263,20 @@ static int touch_handle_entry_p(DIR_BASE_ENTRY *dbe)
|
||||
XDPRINTF((4, 0, "touch_handle_entry entry dbase=%d", dbase));
|
||||
if (dbase > 2) {
|
||||
DIR_BASE_ENTRY **dbp=&(dir_base[dbase]);
|
||||
DIR_BASE_ENTRY **dbpq=dbp;
|
||||
int aktbase=dbase;
|
||||
while (dbase--) {
|
||||
*dbp = *(dbp-1);
|
||||
--dbpq;
|
||||
if ( dbase < (MAX_DIR_BASE_ENTRIES/2) || !(*dbpq) || !(*dbpq)->locked) {
|
||||
*dbp = *dbpq;
|
||||
if (*dbp) (*dbp)->slot = dbase+1;
|
||||
--dbp;
|
||||
dbp=dbpq;
|
||||
aktbase=dbase;
|
||||
}
|
||||
dbase=0;
|
||||
dir_base[0] = dbe;
|
||||
dbe->slot = 0;
|
||||
}
|
||||
dbase = aktbase;
|
||||
dir_base[dbase] = dbe;
|
||||
dbe->slot = dbase;
|
||||
}
|
||||
XDPRINTF((4, 0, "touch_handle_entry return dbase=%d", dbase));
|
||||
return(dbase);
|
||||
@ -325,12 +345,12 @@ static int add_hpath_to_nwpath(N_NW_PATH *nwpath,
|
||||
} else { /* here is path (+ fn ) */
|
||||
int i=len;
|
||||
if (pp > nwpath->path) { /* not the first entry */
|
||||
*pp='/';
|
||||
*++pp='\0';
|
||||
*pp = '/';
|
||||
*++pp = '\0';
|
||||
}
|
||||
while (i--) {
|
||||
if (*p == 0xae) *pp++ = '.';
|
||||
else if (*p > 0x60 && *p < 0x7b) {
|
||||
else if (*p > 0x60 && *p < 0x7b && nwpath->namespace == NAME_DOS) {
|
||||
*pp++ = *p - 0x20; /* all is upshift */
|
||||
} else if (*p == 0xaa || *p == '*' ) {
|
||||
*pp++ = '*';
|
||||
@ -380,12 +400,12 @@ static int nwp_stat(N_NW_PATH *nwpath, char *debstr)
|
||||
return(result);
|
||||
}
|
||||
|
||||
static uint32 build_base_handle(N_NW_PATH *nwpath, int namespace)
|
||||
static uint32 name_2_base(N_NW_PATH *nwpath, int namespace, int no_stat)
|
||||
/* returns basehandle of path, or 0 if not exist !! */
|
||||
/* nwpath must be filled, namespace must be specified */
|
||||
{
|
||||
uint32 basehandle=0L;
|
||||
if (!nwp_stat(nwpath, "build_base_handle")) {
|
||||
if (no_stat || !nwp_stat(nwpath, "name_2_base")) {
|
||||
DEV_NAMESPACE_MAP dnm;
|
||||
dnm.dev = nwpath->statb.st_dev;
|
||||
dnm.namespace = namespace;
|
||||
@ -396,14 +416,39 @@ static uint32 build_base_handle(N_NW_PATH *nwpath, int namespace)
|
||||
return(basehandle);
|
||||
}
|
||||
|
||||
static int add_dbe_entry(int namspace, int volume,
|
||||
uint32 basehandle, uint8 *path)
|
||||
{
|
||||
DIR_BASE_ENTRY *dbe=allocate_dbe_p(namspace);
|
||||
if (dbe) {
|
||||
dbe->nwpath.volume = volume;
|
||||
dbe->basehandle = basehandle;
|
||||
if (path) {
|
||||
strcpy(dbe->nwpath.path, path);
|
||||
norm_nwpath_fn(&(dbe->nwpath));
|
||||
}
|
||||
return(touch_handle_entry_p(dbe));
|
||||
} else return(-0x9b);
|
||||
}
|
||||
|
||||
static int find_base_entry(int volume, uint32 basehandle)
|
||||
{
|
||||
int k=-1;
|
||||
DEV_NAMESPACE_MAP dnm;
|
||||
ino_t ino = nw_vol_handle_to_inode(volume, basehandle, &dnm);
|
||||
while (++k < anz_dbe) {
|
||||
DIR_BASE_ENTRY *e=dir_base[k];
|
||||
if ( (DIR_BASE_ENTRY*)NULL != e
|
||||
&& basehandle == e->basehandle
|
||||
&& volume == e->nwpath.volume) return(k);
|
||||
&& volume == e->nwpath.volume
|
||||
&& ( (basehandle == e->basehandle)
|
||||
|| (ino == e->nwpath.statb.st_ino)) )
|
||||
return(k);
|
||||
}
|
||||
/* now we test whether it is the root of volume */
|
||||
if (0 < (ino = nw_vol_handle_to_inode(volume, basehandle, &dnm))
|
||||
&& ino == get_volume_inode(volume) ) {
|
||||
/* its the handle of the volumes root */
|
||||
return(add_dbe_entry(dnm.namespace, volume, basehandle, NULL));
|
||||
}
|
||||
return(-0x9b);
|
||||
}
|
||||
@ -412,7 +457,7 @@ static int insert_get_base_entry(DIR_BASE_ENTRY *dbe,
|
||||
int namespace, int creatmode)
|
||||
{
|
||||
N_NW_PATH *nwpath = &(dbe->nwpath);
|
||||
uint32 basehandle = build_base_handle(nwpath, namespace);
|
||||
uint32 basehandle = name_2_base(nwpath, namespace, 0);
|
||||
|
||||
if (!basehandle && creatmode) { /* now creat the entry (file or dir) */
|
||||
int result = 0;
|
||||
@ -431,7 +476,7 @@ static int insert_get_base_entry(DIR_BASE_ENTRY *dbe,
|
||||
} else result=-0x84;
|
||||
}
|
||||
if (result) return(result);
|
||||
basehandle = build_base_handle(nwpath, namespace);
|
||||
basehandle = name_2_base(nwpath, namespace, 0);
|
||||
}
|
||||
|
||||
if (basehandle) {
|
||||
@ -453,48 +498,51 @@ static int insert_get_base_entry(DIR_BASE_ENTRY *dbe,
|
||||
return(-0xff); /* invalid path = -0x9c, -0xff no matching files */
|
||||
}
|
||||
|
||||
static int build_dos_base(NW_HPATH *nwp,
|
||||
static int build_base(int namespace,
|
||||
NW_HPATH *nwp,
|
||||
uint8 *pathes,
|
||||
DIR_BASE_ENTRY *dbe,
|
||||
int mode,
|
||||
uint8 *rets)
|
||||
|
||||
/* routine returns the actual dbe entry offset or */
|
||||
/* < 0 if error */
|
||||
/* if mode == 1, then last_path will be ignored and will be put */
|
||||
/* if mode == 1, then last path element will be ignored and will be put */
|
||||
/* into the rets variable */
|
||||
{
|
||||
N_NW_PATH *nwpath=&(dbe->nwpath);
|
||||
int result=0;
|
||||
if (!nwp->flag) { /* short handle */
|
||||
int dir_handle = nwp->base[0];
|
||||
if (dir_handle > 0 && --dir_handle < (int)used_dirs
|
||||
&& dirs[dir_handle].inode) {
|
||||
int llen = strlen(dirs[dir_handle].path);
|
||||
nwpath->volume = dirs[dir_handle].volume;
|
||||
memcpy(nwpath->path, dirs[dir_handle].path, llen+1);
|
||||
int dir_handle = (int)nwp->base[0];
|
||||
NW_DIR *dir = (dir_handle > 0 && dir_handle <= used_dirs)
|
||||
? &(dirs[dir_handle-1])
|
||||
: NULL;
|
||||
if (dir && dir->inode) {
|
||||
int llen = strlen(dir->path);
|
||||
nwpath->volume = dir->volume;
|
||||
memcpy(nwpath->path, dir->path, llen+1);
|
||||
if (llen && *(nwpath->path + llen -1) == '/')
|
||||
*(nwpath->path+llen-1) = '\0';
|
||||
result = (nwpath->volume > -1) ? 0 : -0x98;
|
||||
} else result = -0x9b;
|
||||
XDPRINTF((4, 0, "build_base with dir_handle=%d, result=x%x",
|
||||
dir_handle, result));
|
||||
} else if (nwp->flag == 1) { /* basehandle */
|
||||
uint32 basehandle = GET_32(nwp->base);
|
||||
int k = -1;
|
||||
result = -0x9b; /* here wrong dir_handle should mean wrong basehandle */
|
||||
while (++k < anz_dbe) {
|
||||
if (k != dbe->slot) {
|
||||
DIR_BASE_ENTRY *e=dir_base[k];
|
||||
if ( (DIR_BASE_ENTRY*)NULL != e
|
||||
&& e->nwpath.volume == nwp->volume
|
||||
&& e->basehandle == basehandle) {
|
||||
nwpath->volume = e->nwpath.volume;
|
||||
if (-1 < (result = find_base_entry(nwp->volume, GET_32(nwp->base)))) {
|
||||
DIR_BASE_ENTRY *e=dir_base[result];
|
||||
nwpath->volume = nwp->volume;
|
||||
strcpy(nwpath->path, e->nwpath.path);
|
||||
result = (nwpath->volume > -1) ? 0 : -0x98;
|
||||
break;
|
||||
}
|
||||
}
|
||||
result = 0;
|
||||
} else if (!GET_32(nwp->base)) {
|
||||
nwpath->volume = nwp->volume;
|
||||
nwpath->path[0]='\0';
|
||||
result = 0;
|
||||
}
|
||||
XDPRINTF((4, 0, "build_base with basehandle=%ld, result=x%x",
|
||||
GET_32(nwp->base), result));
|
||||
} else if (nwp->flag != 0xff) result=-0xff;
|
||||
if (!result) {
|
||||
nwpath->namespace = namespace;
|
||||
if ((result = add_hpath_to_nwpath(nwpath, nwp, pathes)) > -1) {
|
||||
char *pp=strrchr((char*)nwpath->path, '/');
|
||||
if (mode) {
|
||||
@ -508,7 +556,7 @@ static int build_dos_base(NW_HPATH *nwp,
|
||||
}
|
||||
}
|
||||
nwpath->fn = (pp) ? (uint8*)pp+1 : nwpath->path;
|
||||
result = insert_get_base_entry(dbe, NAME_DOS, 0);
|
||||
result = insert_get_base_entry(dbe, namespace, 0);
|
||||
}
|
||||
}
|
||||
return(result);
|
||||
@ -524,9 +572,13 @@ int nw_generate_dir_path(int namespace,
|
||||
DIR_BASE_ENTRY *dbe=allocate_dbe_p(namespace);
|
||||
int result = -0xfb;
|
||||
if (NULL != dbe) {
|
||||
if ((result = build_dos_base(nwp, nwp->pathes, dbe, 0, NULL)) > -1) {
|
||||
if ((result = build_base(namespace, nwp, nwp->pathes, dbe, 0, NULL)) > -1) {
|
||||
U32_TO_32(dbe->basehandle, ns_dir_base); /* LOW - HIGH */
|
||||
if (namespace != NAME_DOS) {
|
||||
U32_TO_32(name_2_base(&(dbe->nwpath), NAME_DOS, 1), dos_dir_base);
|
||||
} else {
|
||||
U32_TO_32(dbe->basehandle, dos_dir_base);
|
||||
}
|
||||
XDPRINTF((3, 0, "nw_generate_dir_path path=%s, result=%d, basehandle=0x%x",
|
||||
debug_nwpath_name(&(dbe->nwpath)), result, dbe->basehandle));
|
||||
result= dbe->nwpath.volume;
|
||||
@ -641,7 +693,7 @@ int nw_optain_file_dir_info(int namespace, NW_HPATH *nwp,
|
||||
DIR_BASE_ENTRY *dbe = allocate_dbe_p(namespace);
|
||||
int result = -0xfb;
|
||||
if (NULL != dbe) {
|
||||
if ((result = build_dos_base(nwp, nwp->pathes, dbe, 0, NULL)) > -1) {
|
||||
if ((result = build_base(namespace, nwp, nwp->pathes, dbe, 0, NULL)) > -1) {
|
||||
nwp_stat(&(dbe->nwpath), "nw_optain_file_dir_info");
|
||||
result = build_dir_info(dbe, infomask, responsedata);
|
||||
} else free_dbe_p(dbe);
|
||||
@ -654,12 +706,13 @@ int nw_optain_file_dir_info(int namespace, NW_HPATH *nwp,
|
||||
|
||||
static int nw_init_search(int namespace,
|
||||
NW_HPATH *nwp,
|
||||
uint8 *pathes,
|
||||
uint8 *responsedata)
|
||||
{
|
||||
DIR_BASE_ENTRY *dbe=allocate_dbe_p(namespace);
|
||||
int result = -0xfb;
|
||||
if (NULL != dbe) {
|
||||
if ((result = build_dos_base(nwp, nwp->pathes, dbe, 0, NULL)) > -1) {
|
||||
if ((result = build_base(namespace, nwp, pathes, dbe, 0, NULL)) > -1) {
|
||||
result = base_open_seek_dir(dbe, 0L);
|
||||
if (result > -1) {
|
||||
*responsedata++ = dbe->nwpath.volume;
|
||||
@ -680,7 +733,7 @@ static int nw_init_search(int namespace,
|
||||
|
||||
int get_add_new_entry(DIR_BASE_ENTRY *qbe, uint8 *path, int creatmode)
|
||||
{
|
||||
DIR_BASE_ENTRY *dbe=allocate_dbe_p(qbe->namespace);
|
||||
DIR_BASE_ENTRY *dbe=allocate_dbe_p(qbe->nwpath.namespace);
|
||||
if (NULL != dbe) {
|
||||
N_NW_PATH *nwpath=&(dbe->nwpath);
|
||||
int result = -0x9c;
|
||||
@ -692,13 +745,103 @@ int get_add_new_entry(DIR_BASE_ENTRY *qbe, uint8 *path, int creatmode)
|
||||
*(++nwpath->fn) = '\0';
|
||||
}
|
||||
strcpy(nwpath->fn, path);
|
||||
result = insert_get_base_entry(dbe, qbe->namespace, creatmode);
|
||||
result = insert_get_base_entry(dbe, qbe->nwpath.namespace, creatmode);
|
||||
if (result < 0) free_dbe_p(dbe);
|
||||
return(result);
|
||||
}
|
||||
return(-1);
|
||||
}
|
||||
|
||||
static int namespace_fn_match(uint8 *s, uint8 *p, int namespace)
|
||||
/* for other namespaces than DOS */
|
||||
{
|
||||
int pc, sc;
|
||||
uint state = 0;
|
||||
int anf, ende;
|
||||
int not = 0;
|
||||
uint found = 0;
|
||||
while ( (pc = *p++) != 0) {
|
||||
switch (state){
|
||||
case 0 :
|
||||
if (pc == 255) {
|
||||
switch (pc=*p++) {
|
||||
case 0xaa :
|
||||
case '*' : pc=3000; break; /* star */
|
||||
|
||||
case 0xae :
|
||||
case '.' : pc=1000; break; /* point */
|
||||
|
||||
case 0xbf :
|
||||
case '?' : pc=2000; break; /* ? */
|
||||
|
||||
default : pc=*(--p);
|
||||
break;
|
||||
}
|
||||
} else if (pc == '\\') continue;
|
||||
|
||||
switch (pc) {
|
||||
case 1000: if ('.' != *s++) return(0);
|
||||
break;
|
||||
|
||||
case 2000: if (!*s++) return(0);
|
||||
break;
|
||||
|
||||
case 3000 : if (!*p) return(1);
|
||||
while (*s){
|
||||
if (namespace_fn_match(s, p, namespace) == 1) return(1);
|
||||
++s;
|
||||
}
|
||||
return(0);
|
||||
|
||||
case '[' : if ( (*p == '!') || (*p == '^') ){
|
||||
++p;
|
||||
not = 1;
|
||||
}
|
||||
state = 1;
|
||||
continue;
|
||||
|
||||
default : if ( pc != *s &&
|
||||
( namespace != NAME_OS2
|
||||
|| (!isalpha(pc)) || (!isalpha(*s))
|
||||
|| (pc | 0x20) != (*s | 0x20) ) )
|
||||
return(0);
|
||||
++s;
|
||||
break;
|
||||
|
||||
} /* switch */
|
||||
break;
|
||||
|
||||
case 1 : /* Bereich von Zeichen */
|
||||
sc = *s++;
|
||||
found = not;
|
||||
if (!sc) return(0);
|
||||
do {
|
||||
if (pc == '\\') pc = *(p++);
|
||||
if (!pc) return(0);
|
||||
anf = pc;
|
||||
if (*p == '-' && *(p+1) != ']'){
|
||||
ende = *(++p);
|
||||
p++;
|
||||
}
|
||||
else ende = anf;
|
||||
if (found == not) { /* only if not found */
|
||||
if (anf == sc || (anf <= sc && sc <= ende))
|
||||
found = !not;
|
||||
}
|
||||
} while ((pc = *(p++)) != ']');
|
||||
if (! found ) return(0);
|
||||
not = 0;
|
||||
found = 0;
|
||||
state = 0;
|
||||
break;
|
||||
|
||||
default : break;
|
||||
} /* switch */
|
||||
} /* while */
|
||||
return ( (*s) ? 0 : 1);
|
||||
}
|
||||
|
||||
|
||||
int nw_search_file_dir(int namespace, int datastream,
|
||||
uint32 searchattrib, uint32 infomask,
|
||||
int volume, uint32 basehandle, uint32 sequence,
|
||||
@ -717,7 +860,8 @@ int nw_search_file_dir(int namespace, int datastream,
|
||||
int vol_options = get_volume_options(volume, 0);
|
||||
dbe->locked++;
|
||||
strmaxcpy(entry, path, min(255, len));
|
||||
if (vol_options & VOL_OPTION_DOWNSHIFT) downstr(entry);
|
||||
if (namespace == NAME_DOS && (vol_options & VOL_OPTION_DOWNSHIFT))
|
||||
downstr(entry);
|
||||
XDPRINTF((5,0,"nw_search_file_dir searchpath=%s", entry));
|
||||
while ((dirbuff = readdir(ds->fdir)) != (struct dirent*)NULL){
|
||||
if (dirbuff->d_ino) {
|
||||
@ -725,9 +869,11 @@ int nw_search_file_dir(int namespace, int datastream,
|
||||
XDPRINTF((10,0,"nw_search_file_dir Name=%s",
|
||||
name));
|
||||
if ( (name[0] != '.' && (
|
||||
(!strcmp(name, entry)) ||
|
||||
(entry[0] == '*' && entry[1] == '\0')
|
||||
|| fn_match(name, entry, vol_options)))) {
|
||||
(!strcmp(name, entry))
|
||||
|| (entry[0] == '*' && entry[1] == '\0' && namespace != NAME_DOS)
|
||||
|| (namespace == NAME_DOS)
|
||||
? fn_match(name, entry, vol_options)
|
||||
: namespace_fn_match(name, entry, namespace) ))) {
|
||||
strcpy(ds->kpath, name);
|
||||
XDPRINTF((5,0,"nw_search_file_dir Name found=%s unixname=%s",
|
||||
name, ds->unixname));
|
||||
@ -741,7 +887,8 @@ int nw_search_file_dir(int namespace, int datastream,
|
||||
}
|
||||
if (flag) {
|
||||
strcpy(entry, name);
|
||||
if (vol_options & VOL_OPTION_DOWNSHIFT) upstr(entry);
|
||||
if (namespace == NAME_DOS &&
|
||||
(vol_options & VOL_OPTION_DOWNSHIFT)) upstr(entry);
|
||||
if ((dest_entry = get_add_new_entry(dbe, entry, 0)) > -1)
|
||||
break;
|
||||
}
|
||||
@ -790,13 +937,18 @@ static int nw_open_creat_file_or_dir(int namespace,
|
||||
int exist=-1;
|
||||
uint8 last_part[258];
|
||||
*last_part='\0';
|
||||
if ((result = build_dos_base(nwp, pathes, dbe, 0, NULL)) > -1) {
|
||||
if ((result = build_base(namespace, nwp, pathes, dbe, 0, NULL)) > -1) {
|
||||
exist = result;
|
||||
} else if (opencreatmode & OPC_MODE_CREAT) {
|
||||
result = build_dos_base(nwp, pathes, dbe, 1, last_part);
|
||||
if (result > -1)
|
||||
result = build_base(namespace, nwp, pathes, dbe, 1, last_part);
|
||||
XDPRINTF((5, 0, "nw_open_c... result=%d, last_part='%s'",
|
||||
result, last_part));
|
||||
if (result > -1) {
|
||||
result = get_add_new_entry(dbe, last_part,
|
||||
(creatattrib & FILE_ATTR_DIR) ? FILE_ATTR_DIR : 1);
|
||||
if (result > -1)
|
||||
dbe = dir_base[result];
|
||||
}
|
||||
}
|
||||
if (result > -1) {
|
||||
uint32 fhandle=0L;
|
||||
@ -844,7 +996,7 @@ static int nw_delete_file_dir(int namespace, int searchattrib,
|
||||
DIR_BASE_ENTRY *dbe = allocate_dbe_p(namespace);
|
||||
int result = -0xfb;
|
||||
if (dbe != NULL) {
|
||||
if ((result = build_dos_base(nwp, nwp->pathes, dbe, 0, NULL)) > -1) {
|
||||
if ((result = build_base(namespace, nwp, nwp->pathes, dbe, 0, NULL)) > -1) {
|
||||
uint8 *unname=(uint8*)nwpath_2_unix(&(dbe->nwpath), 2);
|
||||
if (get_volume_options(dbe->nwpath.volume, 1) &
|
||||
VOL_OPTION_READONLY) result = -0x8a;
|
||||
@ -875,7 +1027,7 @@ static int nw_alloc_short_dir_handle(int namespace, int hmode,
|
||||
DIR_BASE_ENTRY *dbe=allocate_dbe_p(namespace);
|
||||
int result = -0xfb;
|
||||
if (NULL != dbe) {
|
||||
if ((result = build_dos_base(nwp, nwp->pathes, dbe, 0, NULL)) > -1) {
|
||||
if ((result = build_base(namespace, nwp, nwp->pathes, dbe, 0, NULL)) > -1) {
|
||||
if (S_ISDIR(dbe->nwpath.statb.st_mode)) {
|
||||
result=xinsert_new_dir(dbe->nwpath.volume, dbe->nwpath.path,
|
||||
dbe->nwpath.statb.st_ino, 300, hmode, task);
|
||||
@ -896,11 +1048,11 @@ static int nw_rename_file_dir(int namespace,
|
||||
DIR_BASE_ENTRY *dbe_d = (NULL != dbe_s) ? allocate_dbe_p(namespace) : NULL;
|
||||
int result = -0xfb;
|
||||
if (dbe_d &&
|
||||
(result = build_dos_base(nwps, pathes_s, dbe_s, 0, NULL)) > -1) {
|
||||
(result = build_base(namespace, nwps, pathes_s, dbe_s, 0, NULL)) > -1) {
|
||||
uint8 last_part[258];
|
||||
uint8 *unname_s=
|
||||
(uint8*)nwpath_2_unix1(&(dbe_s->nwpath), 2, 1);
|
||||
if ((result = build_dos_base(nwpd, pathes_d, dbe_d,
|
||||
if ((result = build_base(namespace, nwpd, pathes_d, dbe_d,
|
||||
1, last_part)) > -1) {
|
||||
uint8 *unname_d =
|
||||
(uint8*)nwpath_2_unix2(&(dbe_d->nwpath), 0, 1, last_part);
|
||||
@ -941,7 +1093,8 @@ static int nw_rename_file_dir(int namespace,
|
||||
int handle_func_0x57(uint8 *p, uint8 *responsedata, int task)
|
||||
{
|
||||
int result = -0xfb; /* unknown request */
|
||||
int ufunc = (int) *p++; /* now p locates at 4 byte boundary */
|
||||
int ufunc = (int) *p++;
|
||||
/* now p locates at 4 byte boundary ! */
|
||||
int namespace = (int) *p; /* for most calls */
|
||||
XDPRINTF((3, 0, "0x57 call ufunc=0x%x namespace=%d", ufunc, namespace));
|
||||
switch (ufunc) {
|
||||
@ -965,8 +1118,12 @@ int handle_func_0x57(uint8 *p, uint8 *responsedata, int task)
|
||||
case 0x02 : /* Initialize Search */
|
||||
{
|
||||
/* NW PATH STRUC */
|
||||
NW_HPATH *nwpathstruct = (NW_HPATH *) (p+2);
|
||||
result = nw_init_search(namespace, nwpathstruct, responsedata);
|
||||
NW_HPATH nwpathstruct;
|
||||
memcpy(&nwpathstruct, p+2, sizeof(nwpathstruct));
|
||||
result = nw_init_search(namespace,
|
||||
&nwpathstruct,
|
||||
p+9,
|
||||
responsedata);
|
||||
}
|
||||
break;
|
||||
|
||||
@ -1099,8 +1256,16 @@ int handle_func_0x57(uint8 *p, uint8 *responsedata, int task)
|
||||
} *xdata= (struct OUTPUT*)responsedata;
|
||||
result=get_volume_options(volume, 0);
|
||||
if (result >-1) {
|
||||
xdata->anz_name_spaces = (uint8) 1;
|
||||
xdata->name_space_list[0] = (uint8) NAME_DOS;
|
||||
xdata->anz_name_spaces = (uint8) 0;
|
||||
if (result & VOL_NAMESPACE_DOS)
|
||||
xdata->name_space_list[xdata->anz_name_spaces++]
|
||||
= (uint8) NAME_DOS;
|
||||
if (result & VOL_NAMESPACE_OS2)
|
||||
xdata->name_space_list[xdata->anz_name_spaces++]
|
||||
= (uint8) NAME_OS2;
|
||||
if (result & VOL_NAMESPACE_NFS)
|
||||
xdata->name_space_list[xdata->anz_name_spaces++]
|
||||
= (uint8) NAME_NFS;
|
||||
result=xdata->anz_name_spaces+1;
|
||||
}
|
||||
}
|
||||
@ -1135,26 +1300,56 @@ int handle_func_0x56(uint8 *p, uint8 *responsedata, int task)
|
||||
int ufunc = (int) *p++; /* now p locates at 4 byte boundary */
|
||||
XDPRINTF((3, 0, "0x56 call ufunc=0x%x", ufunc));
|
||||
switch (ufunc) {
|
||||
#if 0
|
||||
#if 1
|
||||
case 0x01 : /* close extended attribute handle */
|
||||
{
|
||||
uint32 ea_handle=GET_BE32(p+2);
|
||||
result=0; /* dummy */
|
||||
}
|
||||
break;
|
||||
|
||||
case 0x02 : /* write extended attribute handle */
|
||||
{
|
||||
result=0; /* dummy */
|
||||
}
|
||||
break;
|
||||
|
||||
case 0x03 : /* read extended attribute */
|
||||
{
|
||||
int flags = GET_BE16(p);
|
||||
int flags = GET_16(p); /* LOW-HIGH */
|
||||
/* next 2 entries only if flags bits 0-1 = 00 */
|
||||
/* (~(flags & 3)) volume + basehandle */
|
||||
/* ( flag s & 2) eahandle + basehandle */
|
||||
int volume = (int)GET_32(p+2);
|
||||
uint32 basehandle = (int)GET_32(p+6);
|
||||
|
||||
uint32 readpos = GET_32(p+10);
|
||||
uint32 size = GET_32(p+14);
|
||||
uint16 keylen = GET_16(p+18); /* LOW-HIGH */
|
||||
struct OUTPUT {
|
||||
uint8 errorcode[4]; /* ???? */
|
||||
uint8 ttl_v_length[4]; /* ???? */
|
||||
uint8 errorcode[4]; /* LOW-HIGH */
|
||||
uint8 ttl_v_length[4]; /* LOW-HIGH */
|
||||
uint8 ea_handle[4]; /* ???? */
|
||||
uint8 access[4]; /* ???? */
|
||||
uint8 value_length[2]; /* ???? */
|
||||
uint8 value_length[2]; /* LOW-HIGH */
|
||||
uint8 value[2];
|
||||
} *xdata= (struct OUTPUT*)responsedata;
|
||||
memset(xdata, 0, sizeof(struct OUTPUT));
|
||||
/* U32_TO_BE32(1, xdata->errorcode); */
|
||||
U32_TO_32(0xc9, xdata->errorcode); /* NO extended Attributes */
|
||||
result = sizeof(struct OUTPUT);
|
||||
}
|
||||
break;
|
||||
|
||||
case 0x04 : /* enumerate extended attributes */
|
||||
{
|
||||
}
|
||||
break;
|
||||
|
||||
case 0x05 : /* duplicate extended attributes */
|
||||
{
|
||||
}
|
||||
break;
|
||||
|
||||
#endif
|
||||
default : result = -0xfb; /* unknown request */
|
||||
} /* switch */
|
||||
|
14
ncpserv.c
14
ncpserv.c
@ -34,6 +34,7 @@ static int ipx_out_fd=-1;
|
||||
|
||||
static int tells_server_version=0;
|
||||
static int sock_nwbind=-1;
|
||||
static int sock_echo =-1;
|
||||
|
||||
|
||||
static int get_ini(void)
|
||||
@ -309,6 +310,7 @@ static int find_get_conn_nr(ipxAddr_t *addr)
|
||||
char connstr[20];
|
||||
char addrstr[100];
|
||||
char nwbindsock[20];
|
||||
char echosock[20];
|
||||
|
||||
int j = 3;
|
||||
#if !CALL_NWCONN_OVER_SOCKET
|
||||
@ -327,9 +329,9 @@ static int find_get_conn_nr(ipxAddr_t *addr)
|
||||
sprintf(connstr, "%d", connection);
|
||||
ipx_addr_to_adr(addrstr, addr);
|
||||
sprintf(nwbindsock, "%04x", sock_nwbind);
|
||||
|
||||
sprintf(echosock, "%04x", sock_echo);
|
||||
execl(get_exec_path(pathname, progname), progname,
|
||||
pidstr, addrstr, connstr, nwbindsock, NULL);
|
||||
pidstr, addrstr, connstr, nwbindsock, echosock, NULL);
|
||||
|
||||
exit(1); /* normaly not reached */
|
||||
}
|
||||
@ -632,7 +634,7 @@ static void handle_ncp_request(void)
|
||||
&& IPXCMPNET (from_addr.net, my_addr.net)) {
|
||||
/* comes from nwserv */
|
||||
handle_ctrl();
|
||||
#if _MAR_TESTS_
|
||||
#ifdef _MAR_TESTS_xx
|
||||
} else if (type == 0xc000) {
|
||||
/* rprinter */
|
||||
int connection = (int)ncprequest->connection;
|
||||
@ -651,8 +653,8 @@ static void handle_ncp_request(void)
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
init_tools(NCPSERV, 0);
|
||||
if (argc != 4) {
|
||||
errorp(1, "Usage:", "ncpserv nwname address nwbindsock");
|
||||
if (argc != 5) {
|
||||
errorp(1, "Usage:", "%s: nwname address nwbindsock echosocket", argv[0]);
|
||||
return(1);
|
||||
}
|
||||
get_ini();
|
||||
@ -660,6 +662,8 @@ int main(int argc, char *argv[])
|
||||
my_nwname[47] = '\0';
|
||||
adr_to_ipx_addr(&my_addr, argv[2]);
|
||||
sscanf(argv[3], "%x", &sock_nwbind);
|
||||
sscanf(argv[4], "%x", &sock_echo);
|
||||
|
||||
#ifdef LINUX
|
||||
set_emu_tli();
|
||||
#endif
|
||||
|
12
net.h
12
net.h
@ -237,17 +237,14 @@ extern int errno;
|
||||
# define IPX_MAX_DATA 546
|
||||
#endif
|
||||
|
||||
#ifndef SOCK_EXTERN
|
||||
# define SOCK_EXTERN 0 /* no external SOCKET */
|
||||
#endif
|
||||
|
||||
#ifndef DO_TESTING
|
||||
# define DO_TESTING 0
|
||||
#endif
|
||||
|
||||
#if !DO_TESTING
|
||||
# undef _MAR_TESTS_
|
||||
#endif
|
||||
|
||||
#ifndef _MAR_TESTS_
|
||||
# define _MAR_TESTS_ 0
|
||||
#endif
|
||||
|
||||
#ifdef LINUX
|
||||
# ifdef IN_NWROUTED
|
||||
@ -403,6 +400,7 @@ typedef struct S_OWN_DATA OWN_DATA;
|
||||
#define SOCK_PSERVER 0x8060 /* Print Server's Socket */
|
||||
#define SOCK_NVT 0x8063 /* NVT (Network Virtual Terminal) */
|
||||
|
||||
|
||||
/* PACKET TYPES */
|
||||
#define PACKT_0 0 /* unknown */
|
||||
#define PACKT_ROUTE 1 /* Routing Information */
|
||||
|
2
nwbind.c
2
nwbind.c
@ -1312,7 +1312,7 @@ static int xread(IPX_DATA *ipxd, int *offs, uint8 *data, int size)
|
||||
}
|
||||
|
||||
static void handle_ctrl(void)
|
||||
/* reads stdin pipe or packets from nwserv/ncpserv */
|
||||
/* reads packets from nwserv/ncpserv */
|
||||
{
|
||||
IPX_DATA ipxd;
|
||||
int what;
|
||||
|
12
nwclient.c
12
nwclient.c
@ -356,7 +356,7 @@ static int allocate_dir_handle(int dirhandle,
|
||||
if (!handle_event()) return((int) *responsedata);
|
||||
return(-1);
|
||||
}
|
||||
|
||||
#if 0
|
||||
static void scan_irgendwas(int dirhandle, int attrib, char *name)
|
||||
{
|
||||
uint8 *p = requestdata;
|
||||
@ -409,7 +409,7 @@ static int get_dir_path(int dirhandle)
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
|
||||
#endif
|
||||
static void get_connection_info(int conn)
|
||||
/* liefert Connection INFO */
|
||||
{
|
||||
@ -521,7 +521,7 @@ static void send_console_broadcast(char *message)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#if 0
|
||||
|
||||
static int get_bindery_object_name(uint32 id)
|
||||
{
|
||||
@ -536,7 +536,7 @@ static int get_bindery_object_name(uint32 id)
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
static int get_volume_restriction_for_obj(uint32 id, int volnr)
|
||||
{
|
||||
@ -576,7 +576,7 @@ static int login_object(int type, char *name, char *password)
|
||||
return(0);
|
||||
}
|
||||
|
||||
|
||||
#if 0
|
||||
static void test_xx()
|
||||
{
|
||||
uint8 data[] = {0x0,0x1c,0xf,0xff,0xff,0x0,0x0,0x16,'S','Y','S',':','S','Y','S','T','E','M','\\','N','E','T','$','O','B','J','.','O','L','D'} ;
|
||||
@ -585,7 +585,7 @@ static void test_xx()
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
static int open_datei(int dirhandle, int attrib, int ext_attrib, char *name)
|
||||
|
47
nwconn.c
47
nwconn.c
@ -1,4 +1,4 @@
|
||||
/* nwconn.c 04-May-96 */
|
||||
/* nwconn.c 13-Jul-96 */
|
||||
/* one process / connection */
|
||||
|
||||
/* (C)opyright (C) 1993,1996 Martin Stover, Marburg, Germany
|
||||
@ -52,6 +52,7 @@ static NCPREQUEST *ncprequest = (NCPREQUEST*)readbuff;
|
||||
static uint8 *requestdata = readbuff + sizeof(NCPREQUEST);
|
||||
static int ncp_type;
|
||||
static int sock_nwbind=-1;
|
||||
static int sock_echo =-1;
|
||||
|
||||
static int req_printed=0;
|
||||
|
||||
@ -359,6 +360,7 @@ static int handle_ncp_serv(void)
|
||||
if (code) completition = (uint8) -code;
|
||||
} else if (*p == 0xd){ /* Add Trustees to DIR */
|
||||
/******** AddTrustesstoDir ***************/
|
||||
#if 0
|
||||
struct INPUT {
|
||||
uint8 header[7]; /* Requestheader */
|
||||
uint8 div[3]; /* 0x0, dlen, typ */
|
||||
@ -369,6 +371,7 @@ static int handle_ncp_serv(void)
|
||||
uint8 path;
|
||||
} *input = (struct INPUT *) (ncprequest);
|
||||
/* TODO !!!!!!!!!!!!!!!!!!!! */
|
||||
#endif
|
||||
do_druck++;
|
||||
} else if (*p == 0xf){ /* rename dir */
|
||||
/******** Rename DIR *********************/
|
||||
@ -451,6 +454,7 @@ static int handle_ncp_serv(void)
|
||||
}
|
||||
completition = (uint8)-result;
|
||||
} else if (*p == 0x19){ /* Set Directory Information */
|
||||
#if 0
|
||||
struct INPUT {
|
||||
uint8 header[7]; /* Requestheader */
|
||||
uint8 div[3]; /* 0x0, dlen, typ */
|
||||
@ -460,9 +464,11 @@ static int handle_ncp_serv(void)
|
||||
uint8 pathlen;
|
||||
uint8 path;
|
||||
} *input = (struct INPUT *) (ncprequest);
|
||||
#endif
|
||||
/* No REPLY */
|
||||
completition = 0xfb; /* !!!!! TODO !!!! */
|
||||
} else if (*p == 0x1a){ /* Get Pathname of A Volume Dir Pair */
|
||||
#if 0
|
||||
struct INPUT {
|
||||
uint8 header[7]; /* Requestheader */
|
||||
uint8 div[3]; /* 0x0, dlen, typ */
|
||||
@ -473,6 +479,7 @@ static int handle_ncp_serv(void)
|
||||
uint8 pathlen;
|
||||
uint8 pathname;
|
||||
} *xdata = (struct XDATA*)responsedata;
|
||||
#endif
|
||||
completition = 0xfb; /* !!!!! TODO !!!! */
|
||||
} else if (*p == 0x1e){
|
||||
/* SCAN a Directory */
|
||||
@ -566,6 +573,7 @@ static int handle_ncp_serv(void)
|
||||
} else completition = 0x9c; /* no more trustees */
|
||||
} else completition = (uint8) (-result);
|
||||
} else if (*p == 0x27) { /* Add Trustees to DIR ?? */
|
||||
#if 0
|
||||
struct INPUT {
|
||||
uint8 header[7]; /* Requestheader */
|
||||
uint8 div[3]; /* 0x0, dlen, typ */
|
||||
@ -577,6 +585,7 @@ static int handle_ncp_serv(void)
|
||||
uint8 path;
|
||||
} *input = (struct INPUT *) (ncprequest);
|
||||
/* TODO !!!!!!!!!!!!!!!!!!!! */
|
||||
#endif
|
||||
do_druck++;
|
||||
} else if (*p == 0x29){
|
||||
/* read volume restrictions for an object */
|
||||
@ -895,14 +904,13 @@ static int handle_ncp_serv(void)
|
||||
} else completition = (uint8) -rights;
|
||||
} break;
|
||||
|
||||
|
||||
case 0x3f : { /* file search continue */
|
||||
/* Dir_id is from file search init */
|
||||
struct INPUT {
|
||||
uint8 header[7]; /* Requestheader */
|
||||
uint8 volume; /* Volume ID */
|
||||
uint8 dir_id[2]; /* von File Search Init */
|
||||
uint8 searchsequence[2]; /* FRAGE Sequence FFFF ertster Eintrag */
|
||||
uint8 searchsequence[2]; /* sequence FFFF = first entry */
|
||||
uint8 search_attrib; /* Attribute */
|
||||
/* 0 none,
|
||||
2 HIDDEN,
|
||||
@ -916,7 +924,7 @@ static int handle_ncp_serv(void)
|
||||
int len=input->len ; /* FN Length */
|
||||
|
||||
struct OUTPUT {
|
||||
uint8 searchsequence[2]; /* FRAGE Sequence */
|
||||
uint8 searchsequence[2]; /* same as request sequence */
|
||||
uint8 dir_id[2]; /* Direktory ID */
|
||||
/* is correct !! */
|
||||
union {
|
||||
@ -1318,12 +1326,26 @@ static int handle_ncp_serv(void)
|
||||
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
case 0x61 : { /* Negotiate Buffer Size, Packetsize new ??? */
|
||||
#ifdef _MAR_TESTS_
|
||||
case 0x61 : { /* Negotiate Buffer Size, Packetsize new ? */
|
||||
/* > 3.11 */
|
||||
/* similar request as 0x21 */
|
||||
int wantsize = GET_BE16((uint8*)ncprequest);
|
||||
/* wantsize is here normally 1500 */
|
||||
/* 1 byte unknown ( zero ) */
|
||||
struct OUTPUT {
|
||||
uint8 getsize[2];
|
||||
uint8 socket[2]; /* socket for echo ?? */
|
||||
uint8 unknown; /* zero */
|
||||
} *xdata= (struct OUTPUT*)responsedata;
|
||||
memset(xdata, 0, sizeof(*xdata));
|
||||
wantsize = min(1500, wantsize);
|
||||
U16_TO_BE16(wantsize, xdata->getsize);
|
||||
U16_TO_BE16(sock_echo, xdata->socket);
|
||||
data_len = sizeof(*xdata);
|
||||
XDPRINTF((5,0, "Negotiate Buffer (new) =0x%04x,(%d)",
|
||||
(int) wantsize, (int) wantsize));
|
||||
}
|
||||
|
||||
break;
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
@ -1376,7 +1398,6 @@ static void handle_after_bind()
|
||||
switch (ncprequest->function) {
|
||||
case 0x17 : { /* FILE SERVER ENVIRONMENT */
|
||||
uint8 ufunc = *(requestdata+2);
|
||||
uint8 *rdata = requestdata+3;
|
||||
switch (ufunc) {
|
||||
case 0x14: /* Login Objekt, unencrypted passwords */
|
||||
case 0x18: { /* crypt_keyed LOGIN */
|
||||
@ -1486,12 +1507,15 @@ static void set_sig(void)
|
||||
signal(SIGINT, sig_quit);
|
||||
signal(SIGPIPE, sig_pipe);
|
||||
signal(SIGHUP, sig_hup);
|
||||
#if USE_MMAP
|
||||
signal(SIGBUS, sig_bus_mmap); /* in nwfile.c */
|
||||
#endif
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
if (argc != 5) {
|
||||
fprintf(stderr, "usage nwconn PID FROM_ADDR Connection nwbindsock\n");
|
||||
if (argc != 6) {
|
||||
fprintf(stderr, "usage nwconn PID FROM_ADDR Connection nwbindsock echosock\n");
|
||||
exit(1);
|
||||
} else father_pid = atoi(*(argv+1));
|
||||
setuid(0);
|
||||
@ -1509,6 +1533,7 @@ int main(int argc, char **argv)
|
||||
act_pid = getpid();
|
||||
|
||||
sscanf(argv[4], "%x", &sock_nwbind);
|
||||
sscanf(argv[5], "%x", &sock_echo);
|
||||
|
||||
#ifdef LINUX
|
||||
set_emu_tli();
|
||||
|
@ -119,6 +119,9 @@ static buf32 encryptkeys =
|
||||
0xF4,0x47,0xDC,0xA7,0xEC,0xCF,0x50,0xC0};
|
||||
|
||||
#include "nwcrypt.h"
|
||||
|
||||
extern void memset(void* p, int c, int size);
|
||||
|
||||
static void
|
||||
shuffle1(buf32 temp, unsigned char *target)
|
||||
{
|
||||
|
4
nwdbm.c
4
nwdbm.c
@ -1445,7 +1445,7 @@ int nw_fill_standard(char *servername, ipxAddr_t *adr)
|
||||
uint32 ngr_id = 0x0C000001;
|
||||
uint32 ps1_id = 0x0D000001;
|
||||
#endif
|
||||
#if _MAR_TESTS_
|
||||
#ifdef _MAR_TESTS_1
|
||||
uint32 pserv_id = 0L;
|
||||
#endif
|
||||
FILE *f = open_nw_ini();
|
||||
@ -1546,7 +1546,7 @@ int nw_fill_standard(char *servername, ipxAddr_t *adr)
|
||||
"NET_ADDRESS", P_FL_ITEM | P_FL_DYNA, 0x40,
|
||||
(char*)adr, sizeof(ipxAddr_t));
|
||||
|
||||
#if _MAR_TESTS_
|
||||
#ifdef _MAR_TESTS_1
|
||||
nw_new_obj_prop(pserv_id, serverna, 0x47, O_FL_DYNA, 0x31,
|
||||
"NET_ADDRESS", P_FL_ITEM | P_FL_DYNA, 0x40,
|
||||
(char*)adr, sizeof(ipxAddr_t));
|
||||
|
37
nwfile.c
37
nwfile.c
@ -1,4 +1,4 @@
|
||||
/* nwfile.c 11-May-96 */
|
||||
/* nwfile.c 16-Jul-96 */
|
||||
/* (C)opyright (C) 1993,1996 Martin Stover, Marburg, Germany
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@ -29,6 +29,13 @@
|
||||
#include "nwconn.h"
|
||||
#if USE_MMAP
|
||||
# include <sys/mman.h>
|
||||
static got_sig_bus=0;
|
||||
void sig_bus_mmap(int rsig)
|
||||
{
|
||||
got_sig_bus++;
|
||||
XDPRINTF((2,0, "Got sig_bus"));
|
||||
signal(SIGBUS, sig_bus_mmap);
|
||||
}
|
||||
#endif
|
||||
|
||||
static FILE_HANDLE file_handles[MAX_FILE_HANDLES_CONN];
|
||||
@ -116,7 +123,9 @@ void init_file_module(void)
|
||||
int file_creat_open(int volume, uint8 *unixname, struct stat *stbuff,
|
||||
int attrib, int access, int creatmode)
|
||||
/*
|
||||
* creatmode: 0 = open | 1 = creat | 2 = creatnew & 4 == save handle
|
||||
* creatmode: 0 = open | 1 = creat (ever) | 2 = creatnew ( creat if not exist )
|
||||
* & 4 == save handle (creat)
|
||||
* & 8 == ignore rights (create ever)
|
||||
* attrib ??
|
||||
*
|
||||
* access: 0x1=read,
|
||||
@ -181,7 +190,17 @@ int file_creat_open(int volume, uint8 *unixname, struct stat *stbuff,
|
||||
XDPRINTF((5,0,"CREAT FILE, ever with attrib:0x%x, access:0x%x, fh->fname:%s: handle:%d",
|
||||
attrib, access, fh->fname, fhandle));
|
||||
fh->fd = open(fh->fname, O_CREAT|O_TRUNC|O_RDWR, 0777);
|
||||
if (fh->fd < 0) completition = -0x85; /* no delete /create Rights */
|
||||
if (fh->fd < 0) {
|
||||
if (creatmode & 0x8) {
|
||||
if ( (!seteuid(0)) && (-1 < (fh->fd =
|
||||
open(fh->fname, O_CREAT|O_TRUNC|O_RDWR, 0777)))) {
|
||||
chown(fh->fname, act_uid, act_gid);
|
||||
}
|
||||
set_guid(act_gid, act_uid);
|
||||
}
|
||||
if (fh->fd < 0)
|
||||
completition = -0x85; /* no delete /create Rights */
|
||||
}
|
||||
}
|
||||
if (fh->fd > -1) {
|
||||
close(fh->fd);
|
||||
@ -342,11 +361,21 @@ int nw_read_datei(int fhandle, uint8 *data, int size, uint32 offset)
|
||||
} else {
|
||||
#if USE_MMAP
|
||||
if (fh->p_mmap) {
|
||||
while (1) {
|
||||
if (offset < fh->size_mmap) {
|
||||
if (size + offset > fh->size_mmap)
|
||||
size = fh->size_mmap - offset;
|
||||
memcpy(data, fh->p_mmap+offset, size);
|
||||
} else size=-1;
|
||||
if (got_sig_bus) {
|
||||
fh->size_mmap = lseek(fh->fd, 0L, SEEK_END);
|
||||
got_sig_bus = 0;
|
||||
} else
|
||||
break;
|
||||
} else {
|
||||
size=-1;
|
||||
break;
|
||||
}
|
||||
} /* while */
|
||||
} else {
|
||||
#endif
|
||||
if (fh->offd != (long)offset) {
|
||||
|
2
nwfile.h
2
nwfile.h
@ -24,6 +24,8 @@ typedef struct {
|
||||
#define FH_DO_NOT_REUSE 0x04
|
||||
#define FH_IS_READONLY 0x20
|
||||
|
||||
extern void sig_bus_mmap(int rsig);
|
||||
|
||||
extern void init_file_module(void);
|
||||
|
||||
extern int file_creat_open(int volume, uint8 *unixname,
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* nwconn.c 04-May-96 */
|
||||
/* nwconn.c 16-Jul-96 */
|
||||
/* (C)opyright (C) 1993,1996 Martin Stover, Marburg, Germany
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@ -273,7 +273,7 @@ static int create_queue_file(uint8 *job_file_name,
|
||||
if (result > -1)
|
||||
result = nw_creat_open_file(result, job_file_name+1,
|
||||
(int) *job_file_name,
|
||||
&fnfo, 0x6, 0x6, 1 | 4);
|
||||
&fnfo, 0x6, 0x6, 1 | 4 | 8);
|
||||
|
||||
XDPRINTF((5,0,"creat queue file bez=`%s` handle=%d",
|
||||
job_bez, result));
|
||||
|
95
nwserv.c
95
nwserv.c
@ -39,15 +39,23 @@ int wdogs_till_tics = 0; /* send wdogs to all */
|
||||
int anz_net_devices=0;
|
||||
NW_NET_DEVICE *net_devices[MAX_NET_DEVICES];
|
||||
|
||||
uint16 ipx_sock_nummern[]={ SOCK_AUTO /* WDOG */
|
||||
#ifdef PSERVER_SLOT
|
||||
,SOCK_PSERVER
|
||||
#endif
|
||||
#if !IN_NWROUTED
|
||||
uint16 ipx_sock_nummern[]={ SOCK_AUTO /* WDOG */
|
||||
# ifdef EXTERN_SLOT
|
||||
,SOCK_EXTERN /* Xmarsmon */
|
||||
# endif
|
||||
|
||||
#if INTERNAL_RIP_SAP
|
||||
# ifdef PSERVER_SLOT
|
||||
,SOCK_PSERVER
|
||||
# endif
|
||||
|
||||
# if INTERNAL_RIP_SAP
|
||||
,SOCK_SAP
|
||||
#else
|
||||
# else
|
||||
,SOCK_AUTO
|
||||
# endif
|
||||
#else
|
||||
uint16 ipx_sock_nummern[]={SOCK_SAP
|
||||
#endif
|
||||
|
||||
#ifdef RIP_SLOT
|
||||
@ -70,6 +78,7 @@ uint16 ipx_sock_nummern[]={ SOCK_AUTO /* WDOG */
|
||||
};
|
||||
|
||||
#define NEEDED_SOCKETS (sizeof(ipx_sock_nummern) / sizeof(uint16))
|
||||
|
||||
#if IN_NWROUTED
|
||||
# define NEEDED_POLLS (NEEDED_SOCKETS+1)
|
||||
#else
|
||||
@ -247,6 +256,7 @@ static int start_ncpserv(char *nwname, ipxAddr_t *addr)
|
||||
char addrstr[100];
|
||||
char pathname[300];
|
||||
char nwbindsock[20];
|
||||
char echosock[20];
|
||||
int j = FD_NWSERV;
|
||||
close(fds_in[0]); /* no need to read */
|
||||
dup2(fds_in[1], FD_NWSERV); /* becommes fd FD_NWSERV */
|
||||
@ -255,8 +265,9 @@ static int start_ncpserv(char *nwname, ipxAddr_t *addr)
|
||||
U16_TO_BE16(SOCK_NCP, addr->sock);
|
||||
ipx_addr_to_adr(addrstr, addr);
|
||||
sprintf(nwbindsock, "%04x", sock_nwbind);
|
||||
sprintf(echosock, "%04x", sock_nummern[WDOG_SLOT]);
|
||||
execl(get_exec_path(pathname, progname), progname,
|
||||
nwname, addrstr, nwbindsock, NULL);
|
||||
nwname, addrstr, nwbindsock, echosock, NULL);
|
||||
exit(1);
|
||||
}
|
||||
break;
|
||||
@ -322,7 +333,6 @@ static int start_nwbind(char *nwname, ipxAddr_t *addr)
|
||||
U16_TO_BE16(SOCK_NCP, addr->sock);
|
||||
ipx_addr_to_adr(addrstr, addr);
|
||||
sprintf(nwbindsock, "%04x", sock_nwbind);
|
||||
|
||||
execl(get_exec_path(pathname, progname), progname,
|
||||
nwname, addrstr, nwbindsock, NULL);
|
||||
exit(1);
|
||||
@ -363,7 +373,6 @@ static int start_nwclient(void)
|
||||
}
|
||||
return(0); /* OK */
|
||||
}
|
||||
#endif
|
||||
|
||||
/* =========================== WDOG =============================== */
|
||||
#ifndef _WDOG_TESTING_
|
||||
@ -497,6 +506,8 @@ static void send_bcasts(int conn)
|
||||
send_bcast_packet(&adr, conn+1, '!'); /* notify */
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
void get_server_data(char *name,
|
||||
ipxAddr_t *adr,
|
||||
@ -720,6 +731,25 @@ static void handle_diag(int fd, int ipx_pack_typ,
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef EXTERN_SLOT
|
||||
ipxAddr_t auth_addr;
|
||||
int is_auth=0;
|
||||
|
||||
static void handle_extern_call(int fd,
|
||||
int ipx_pack_typ,
|
||||
int data_len,
|
||||
IPX_DATA *ipxdata,
|
||||
ipxAddr_t *from_addr)
|
||||
{
|
||||
if (memcmp(&auth_addr, from_addr, sizeof(ipxAddr_t))){
|
||||
memcpy(&auth_addr, from_addr, sizeof(ipxAddr_t));
|
||||
is_auth=0;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
static void handle_event(int fd, uint16 socknr, int slot)
|
||||
{
|
||||
struct t_unitdata ud;
|
||||
@ -766,8 +796,11 @@ static void handle_event(int fd, uint16 socknr, int slot)
|
||||
IPXCMPNET (source_adr.net, my_server_adr.net)) {
|
||||
|
||||
int source_sock = (int) GET_BE16(source_adr.sock);
|
||||
if ( source_sock == sock_nummern[WDOG_SLOT]
|
||||
|| source_sock == SOCK_SAP
|
||||
if (
|
||||
#if !IN_NWROUTED
|
||||
source_sock == sock_nummern[WDOG_SLOT] ||
|
||||
#endif
|
||||
source_sock == SOCK_SAP
|
||||
|| source_sock == SOCK_RIP) {
|
||||
XDPRINTF((2,0,"OWN Packet from sock:0x%04x, ignored", source_sock));
|
||||
return;
|
||||
@ -781,6 +814,29 @@ static void handle_event(int fd, uint16 socknr, int slot)
|
||||
#endif
|
||||
|
||||
switch (slot) {
|
||||
#ifdef WDOG_SLOT
|
||||
case WDOG_SLOT :
|
||||
|
||||
if (2 == ud.udata.len) {
|
||||
XDPRINTF((2,0, "WDOG Packet len=%d connid=%d, status=%d",
|
||||
(int)ud.udata.len, (int) ipx_data_buff.wdog.connid,
|
||||
(int)ipx_data_buff.wdog.status));
|
||||
if ('Y' == ipx_data_buff.wdog.status)
|
||||
modify_wdog_conn(ipx_data_buff.wdog.connid, 0);
|
||||
} else if ( 2 < ud.udata.len
|
||||
&& ipx_data_buff.data[0] == 0x11
|
||||
&& ipx_data_buff.data[1] == 0x11 ) {
|
||||
/* now we make an echo of this data */
|
||||
send_ipx_data(sockfd[WDOG_SLOT],
|
||||
17, ud.udata.len, ud.udata.buf, &source_adr, "ECHO");
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
|
||||
#ifdef EXTERN_SLOT
|
||||
case EXTERN_SLOT : handle_extern_call(fd, (int) ipx_pack_typ, ud.udata.len, &ipx_data_buff, &source_adr); break;
|
||||
#endif
|
||||
|
||||
case SAP_SLOT : handle_sap( fd, (int) ipx_pack_typ, ud.udata.len, &ipx_data_buff, &source_adr); break;
|
||||
#ifdef RIP_SLOT
|
||||
case RIP_SLOT : handle_rip( fd, (int) ipx_pack_typ, ud.udata.len, &ipx_data_buff, &source_adr); break;
|
||||
@ -790,16 +846,7 @@ static void handle_event(int fd, uint16 socknr, int slot)
|
||||
case DIAG_SLOT : handle_diag(fd, (int) ipx_pack_typ, ud.udata.len, &ipx_data_buff, &source_adr); break;
|
||||
#endif
|
||||
|
||||
default :
|
||||
if (WDOG_SLOT == slot) { /* this is a watchdog packet */
|
||||
XDPRINTF((2,0, "WDOG Packet len=%d connid=%d, status=%d",
|
||||
(int)ud.udata.len, (int) ipx_data_buff.wdog.connid,
|
||||
(int)ipx_data_buff.wdog.status));
|
||||
if (2 == ud.udata.len) {
|
||||
if ('Y' == ipx_data_buff.wdog.status)
|
||||
modify_wdog_conn(ipx_data_buff.wdog.connid, 0);
|
||||
}
|
||||
} else {
|
||||
default : {
|
||||
uint8 *p = (uint8*)&ipx_data_buff;
|
||||
int k = 0;
|
||||
XDPRINTF((1, 2, "UNKNOWN"));
|
||||
@ -1241,6 +1288,7 @@ int main(int argc, char **argv)
|
||||
else handle_event(p->fd, sock_nummern[j], j);
|
||||
} else { /* fd_ncpserv_in */
|
||||
XDPRINTF((2, 0, "POLL %d, fh=%d", p->revents, p->fd));
|
||||
#if !IN_NWROUTED
|
||||
if (p->revents & ~POLLIN)
|
||||
errorp(0, "STREAM error", "revents=0x%x", p->revents );
|
||||
else {
|
||||
@ -1308,6 +1356,7 @@ int main(int argc, char **argv)
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
if (! --anz_poll) break;
|
||||
} /* if */
|
||||
@ -1333,10 +1382,14 @@ int main(int argc, char **argv)
|
||||
bsecs=server_broadcast_secs;
|
||||
broadmillisecs = bsecs*1000+10;
|
||||
}
|
||||
#if !IN_NWROUTED
|
||||
send_wdogs();
|
||||
#endif
|
||||
broadtime = akttime_stamp;
|
||||
} else {
|
||||
#if !IN_NWROUTED
|
||||
if (call_wdog) send_wdogs(1);
|
||||
#endif
|
||||
if (client_mode && difftime > 5) get_servers(); /* Here more often */
|
||||
}
|
||||
}
|
||||
|
26
nwserv.h
26
nwserv.h
@ -1,4 +1,4 @@
|
||||
/* nwserv.h 26-Apr-96 */
|
||||
/* nwserv.h 16-Jul-96 */
|
||||
/* (C)opyright (C) 1993,1995 Martin Stover, Marburg, Germany
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@ -40,8 +40,28 @@ extern int anz_net_devices;
|
||||
extern NW_NET_DEVICE *net_devices[];
|
||||
|
||||
/* <======== SOCKETS =========> */
|
||||
#define WDOG_SLOT 0 /* Watchdog send + recv */
|
||||
#define SAP_SLOT 1 /* SAP wellkwon or dynamic */
|
||||
#if !IN_NWROUTED
|
||||
# define WDOG_SLOT 0 /* Watchdog send + recv */
|
||||
|
||||
# if SOCK_EXTERN
|
||||
# define EXTERN_SLOT (WDOG_SLOT+1)
|
||||
# ifdef _MAR_TESTS_1
|
||||
# define PSERVER_SLOT (EXTERN_SLOT+1)
|
||||
# define SAP_SLOT (PSERVER_SLOT+1)
|
||||
# else
|
||||
# define SAP_SLOT (EXTERN_SLOT+1)
|
||||
# endif
|
||||
# else
|
||||
# ifdef _MAR_TESTS_1
|
||||
# define PSERVER_SLOT (WDOG_SLOT+1)
|
||||
# define SAP_SLOT (PSERVER_SLOT+1)
|
||||
# else
|
||||
# define SAP_SLOT (WDOG_SLOT+1)
|
||||
# endif
|
||||
# endif
|
||||
#else
|
||||
# define SAP_SLOT 0
|
||||
#endif
|
||||
|
||||
#if INTERNAL_RIP_SAP
|
||||
# define RIP_SLOT (SAP_SLOT +1)
|
||||
|
26
nwvolume.c
26
nwvolume.c
@ -1,4 +1,4 @@
|
||||
/* nwvolume.c 11-May-96 */
|
||||
/* nwvolume.c 14-Jul-96 */
|
||||
/* (C)opyright (C) 1993,1996 Martin Stover, Marburg, Germany
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@ -63,7 +63,7 @@ void nw_init_volumes(FILE *f)
|
||||
int founds = sscanf((char*)buff, "%s %s %s",sysname, unixname, optionstr);
|
||||
if (founds > 1) {
|
||||
NW_VOL *vol=&(nw_volumes[used_nw_volumes]);
|
||||
vol->options = 0;
|
||||
vol->options = VOL_NAMESPACE_DOS;
|
||||
new_str(vol->sysname, sysname);
|
||||
if (1 == (len = strlen((char*)unixname)) && unixname[0] == '~') {
|
||||
vol->options |= VOL_OPTION_IS_HOME;
|
||||
@ -98,6 +98,14 @@ void nw_init_volumes(FILE *f)
|
||||
|= VOL_OPTION_READONLY;
|
||||
break;
|
||||
|
||||
case 'O' : vol->options
|
||||
|= VOL_NAMESPACE_OS2;
|
||||
break;
|
||||
|
||||
case 'N' : vol->options
|
||||
|= VOL_NAMESPACE_NFS;
|
||||
break;
|
||||
|
||||
default : break;
|
||||
}
|
||||
}
|
||||
@ -311,3 +319,17 @@ int get_volume_options(int volnr, int mode)
|
||||
return(result);
|
||||
}
|
||||
|
||||
int get_volume_inode(int volnr)
|
||||
/* returns inode if OK, else errocode < 0 */
|
||||
{
|
||||
int result = -0x98; /* Volume not exist */;
|
||||
if (volnr > -1 && volnr < used_nw_volumes) {
|
||||
struct stat statb;
|
||||
result = stat(nw_volumes[volnr].unixname, &statb);
|
||||
if (result == -1) result=-0x98;
|
||||
else result=statb.st_ino;
|
||||
}
|
||||
XDPRINTF((5,0,"get_volume_inode of VOLNR:%d, result=0x%x", volnr, result));
|
||||
return(result);
|
||||
}
|
||||
|
||||
|
20
nwvolume.h
20
nwvolume.h
@ -1,4 +1,4 @@
|
||||
/* nwvolume.h 11-May-96 */
|
||||
/* nwvolume.h 14-Jul-96 */
|
||||
/* (C)opyright (C) 1993,1995 Martin Stover, Marburg, Germany
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@ -42,12 +42,17 @@ typedef struct {
|
||||
int options; /* see defines below */
|
||||
} NW_VOL;
|
||||
|
||||
#define VOL_OPTION_DOWNSHIFT 0x01 /* All downshift */
|
||||
#define VOL_OPTION_IS_PIPE 0x02 /* Volume contains pipes */
|
||||
#define VOL_OPTION_REMOUNT 0x04 /* Volume can be remounted (cdroms) */
|
||||
#define VOL_OPTION_IS_HOME 0x08 /* Volume is USERS HOME */
|
||||
#define VOL_OPTION_ONE_DEV 0x10 /* Volume has only one filesys */
|
||||
#define VOL_OPTION_READONLY 0x20 /* Volume is readonly */
|
||||
/* vol options */
|
||||
#define VOL_OPTION_DOWNSHIFT 0x0001 /* All downshift */
|
||||
#define VOL_OPTION_IS_PIPE 0x0002 /* Volume contains pipes */
|
||||
#define VOL_OPTION_REMOUNT 0x0004 /* Volume can be remounted (cdroms) */
|
||||
#define VOL_OPTION_IS_HOME 0x0008 /* Volume is USERS HOME */
|
||||
#define VOL_OPTION_ONE_DEV 0x0010 /* Volume has only one filesys */
|
||||
#define VOL_OPTION_READONLY 0x0020 /* Volume is readonly */
|
||||
/* namespaces */
|
||||
#define VOL_NAMESPACE_DOS 0x1000
|
||||
#define VOL_NAMESPACE_OS2 0x2000
|
||||
#define VOL_NAMESPACE_NFS 0x4000
|
||||
|
||||
/* stolen from GNU-fileutils */
|
||||
/* Space usage statistics for a filesystem. Blocks are 512-byte. */
|
||||
@ -68,6 +73,7 @@ extern int nw_get_volume_number(uint8 *volname, int namelen);
|
||||
extern int nw_get_volume_name(int volnr, uint8 *volname);
|
||||
extern int nw_get_fs_usage(uint8 *volname, struct fs_usage *fsu);
|
||||
extern int get_volume_options(int volnr, int mode);
|
||||
extern int get_volume_inode(int volnr);
|
||||
|
||||
extern uint32 nw_vol_inode_to_handle(int volume, ino_t inode,
|
||||
DEV_NAMESPACE_MAP *dnm);
|
||||
|
Loading…
Reference in New Issue
Block a user