diff --git a/admin b/admin index 3519774..4b8871f 160000 --- a/admin +++ b/admin @@ -1 +1 @@ -Subproject commit 3519774d92f3344e9322b59a48e3e8bd7b8e9da1 +Subproject commit 4b8871fadc446dcb2312fcd31569cadc7c4212b4 diff --git a/include/namedos.h b/include/namedos.h index fd1bdd2..8306afe 100644 --- a/include/namedos.h +++ b/include/namedos.h @@ -1,34 +1,14 @@ +/* + * namedos.h: 08-Aug-96 + * + * (C)opyright (C) 1993,1996 Martin Stover, Marburg, Germany + */ #ifndef _NAMEDOS_H_ #define _NAMEDOS_H_ +#if WITH_NAME_SPACE_CALLS -/* - * namedos.h - * - * Centralized DOS 8.3 short-name support for MARS_NWE. - */ - -#include "net.h" -#include "nwvolume.h" - -#define DOS83_NAME_MAX 13 /* 8 + '.' + 3 + NUL */ - -int dos83_is_valid_name(const uint8 *name, int options); -int dos83_build_name_in_dir(const char *dir_unix, - const uint8 *src, - uint8 *out, - int out_size, - int options); -int dos83_match_name_in_dir(const char *dir_unix, - const uint8 *unix_name, - const uint8 *dos_pattern, - int options, - uint8 *out_dos_name, - int out_dos_name_size); -int dos83_resolve_component(const char *dir_unix, - const uint8 *dos_name, - uint8 *resolved_name, - int resolved_size, - int options); -void mangle_dos_name(NW_VOL *vol, uint8 *unixname, uint8 *pp); +extern void mangle_dos_name(NW_VOL *vol, uint8 *unixname, uint8 *pp, int len); +extern int fn_dos_match(uint8 *s, uint8 *p, int soptions); #endif +#endif diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 5c60a2f..a1ce040 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -57,7 +57,7 @@ ELSE(ENABLE_INTERNAL_RIP_SAP) ENDIF(ENABLE_INTERNAL_RIP_SAP) add_executable(nwserv nwserv.c net1.c tools.c ${EMUTLI} ${EMUTLI1} ${NWROUTE_0} ) -add_executable(nwconn nwconn.c net1.c tools.c connect.c namspace.c nwvolume.c nwfile.c unxfile.c nwqconn.c nameos2.c namedos.c nwfname.c nwshare.c extpipe.c nwattrib.c trustee.c ${EMUTLI} ) +add_executable(nwconn nwconn.c net1.c tools.c connect.c namspace.c nwvolume.c nwfile.c unxfile.c nwqconn.c nameos2.c nwfname.c nwshare.c extpipe.c nwattrib.c trustee.c ${EMUTLI} ) add_executable(ncpserv ncpserv.c net1.c tools.c ${EMUTLI} ) add_executable(nwclient nwclient.c net1.c tools.c ${EMUTLI} ) add_executable(nwbind nwbind.c net1.c tools.c nwdbm.c nwcrypt.c unxlog.c sema.c nwqueue.c unxfile.c ${EMUTLI} ) diff --git a/src/connect.c b/src/connect.c index 1e17fa6..fd5fb81 100644 --- a/src/connect.c +++ b/src/connect.c @@ -59,7 +59,6 @@ static int act_umode_file=0; #include "nwconn.h" #include "namspace.h" #include "connect.h" -#include "namedos.h" typedef struct { @@ -144,166 +143,6 @@ static char *build_unix_name(NW_PATH *nwpath, int modus) return(unixname); } -static int resolve_dos_component_in_dir(const char *dir_unix, - const uint8 *dos_component, - uint8 *resolved_name, - int resolved_name_size, - int options) -{ - DIR *d; - struct dirent *dirbuff; - - d = opendir(dir_unix); - if (!d) { - if (seteuid(0)) {} - d = opendir(dir_unix); - reseteuid(); - } - if (!d) { - XDPRINTF((2, 0, - "OPEN RESOLVE opendir failed dir='%s' component='%s'", - dir_unix ? dir_unix : "(null)", - dos_component ? (char *)dos_component : "(null)")); - return 0; - } - - while ((dirbuff = readdir(d)) != NULL) { - uint8 dosname[DOS83_NAME_MAX + 1]; - - if (!dirbuff->d_ino) - continue; - if (!strcmp(dirbuff->d_name, ".") || !strcmp(dirbuff->d_name, "..")) - continue; - - if (dos83_match_name_in_dir(dir_unix, - (uint8 *)dirbuff->d_name, - dos_component, - options, - dosname, - sizeof(dosname))) { - strncpy((char *)resolved_name, dirbuff->d_name, resolved_name_size - 1); - resolved_name[resolved_name_size - 1] = '\0'; - XDPRINTF((2, 0, - "OPEN RESOLVE MATCH dir='%s' component='%s' unix='%s' alias='%s'", - dir_unix ? dir_unix : "(null)", - dos_component ? (char *)dos_component : "(null)", - dirbuff->d_name, - dosname)); - closedir(d); - return 1; - } - } - - XDPRINTF((2, 0, - "OPEN RESOLVE MISS dir='%s' component='%s'", - dir_unix ? dir_unix : "(null)", - dos_component ? (char *)dos_component : "(null)")); - closedir(d); - return 0; -} - -static int resolve_dos_nwpath_in_place(NW_VOL *v, uint8 *nw_path, uint8 *nw_fn) -{ - char dir_unix[1024]; - uint8 resolved_path[256]; - uint8 component[256]; - uint8 resolved_name[256]; - uint8 fncopy[256]; - uint8 *src; - uint8 *dst; - int had_leading_slash = (nw_path && nw_path[0] == '/'); - - if (!v || !nw_path || !nw_fn) - return -0x9c; - - strncpy(dir_unix, (const char *)v->unixname, sizeof(dir_unix) - 1); - dir_unix[sizeof(dir_unix) - 1] = '\0'; - - resolved_path[0] = '\0'; - dst = resolved_path; - - if (had_leading_slash) - *dst++ = '/'; - - src = nw_path; - if (*src == '/') - src++; - - while (*src) { - uint8 *c = component; - - while (*src == '/') - src++; - - if (!*src) - break; - - while (*src && *src != '/') - *c++ = *src++; - *c = '\0'; - - if (!resolve_dos_component_in_dir(dir_unix, - component, - resolved_name, - sizeof(resolved_name), - v->options)) { - XDPRINTF((2, 0, - "OPEN RESOLVE PATH FAIL dir='%s' component='%s'", - dir_unix, - component)); - return -0x9c; - } - - if (strlen(dir_unix) + 1 + strlen((char *)resolved_name) < sizeof(dir_unix) - 1) { - if (dir_unix[strlen(dir_unix) - 1] != '/') - strcat(dir_unix, "/"); - strcat(dir_unix, (char *)resolved_name); - } else - return -0x9c; - - strncpy((char *)dst, (const char *)resolved_name, - sizeof(resolved_path) - (int)(dst - resolved_path) - 2); - dst += strlen((char *)dst); - *dst++ = '/'; - *dst = '\0'; - } - - if (resolved_path[0]) { - unix2doscharset(resolved_path); - strmaxcpy(nw_path, (char *)resolved_path, 255); - } else - nw_path[0] = '\0'; - - strmaxcpy(fncopy, (char *)nw_fn, sizeof(fncopy) - 1); - if (fncopy[0]) { - if (!resolve_dos_component_in_dir(dir_unix, - fncopy, - resolved_name, - sizeof(resolved_name), - v->options)) { - XDPRINTF((2, 0, - "OPEN RESOLVE FN FAIL dir='%s' fn='%s'", - dir_unix, - fncopy)); - return -0x9c; - } - - unix2doscharset(resolved_name); - strmaxcpy(nw_fn, (char *)resolved_name, 255); - - XDPRINTF((2, 0, - "OPEN RESOLVE FINAL path='%s' fn='%s'", - nw_path, - nw_fn)); - } else { - XDPRINTF((2, 0, - "OPEN RESOLVE FINAL path='%s' fn=''", - nw_path)); - } - - return 0; -} - static int new_dir_handle(struct stat *stb, NW_PATH *nwpath) /* @@ -753,52 +592,30 @@ static int func_search_entry(NW_PATH *nwpath, int attrib, if (f != (DIR*)NULL) { char *kpath=xkpath+strlen(xkpath); *kpath++ = '/'; - *kpath = '\0'; while ((dirbuff = readdir(f)) != (struct dirent*)NULL){ okflag = 0; if (dirbuff->d_ino) { - uint8 *name = (uint8 *)(dirbuff->d_name); - uint8 dosname[DOS83_NAME_MAX + 1]; - - okflag = 0; - - if (name[0] != '.') { - okflag = dos83_match_name_in_dir(xkpath, - name, - entry, - soptions, - dosname, - sizeof(dosname)); - XDPRINTF((2,0, - "CONNECT func_search_entry dir='%s' entry='%s' unix='%s' alias='%s' ok=%d", - xkpath, - entry, - name, - dosname, - okflag)); - } - + uint8 *name=(uint8*)(dirbuff->d_name); + uint8 dname[256]; + xstrcpy(dname, name); + unix2doscharset(dname); + okflag = (name[0] != '.' && + ( (!strcmp((char*)dname, (char*)entry)) + || fn_dos_match(dname, entry, soptions))); if (okflag) { *kpath = '\0'; - strmaxcpy(kpath, (char *)name, sizeof(xkpath) - (int)(kpath - xkpath) - 1); - + strmaxcpy(kpath, (char*)name, sizeof(xkpath) - (int)(kpath-xkpath) -1 ); if (!s_stat(xkpath, &(fs->statb), NULL)) { - okflag = ((((fs->statb.st_mode & S_IFMT) == S_IFDIR) && (attrib & 0x10)) - || (((fs->statb.st_mode & S_IFMT) != S_IFDIR) && !(attrib & 0x10))); - - if (okflag) { - /* Return the DOS-visible alias instead of the raw long name. */ - xstrcpy(nwpath->fn, (char *)dosname); - XDPRINTF((5,0,"FOUND DOS alias=:%s: attrib=0x%x", nwpath->fn, fs->statb.st_mode)); + okflag = ( ( ( (fs->statb.st_mode & S_IFMT) == S_IFDIR) && (attrib & 0x10)) + || ( ( (fs->statb.st_mode & S_IFMT) != S_IFDIR) && !(attrib & 0x10))); + if (okflag){ + xstrcpy(nwpath->fn, (char*)dname); + XDPRINTF((5,0,"FOUND=:%s: attrib=0x%x", nwpath->fn, fs->statb.st_mode)); result = (*fs_func)(nwpath, fs); - if (result < 0) - break; - else - result = 1; + if (result < 0) break; + else result=1; } - } else { - okflag = 0; - } + } else okflag = 0; } XDPRINTF((6,0, "NAME=:%s: OKFLAG %d", name, okflag)); } /* if */ @@ -846,7 +663,6 @@ static int get_dir_entry(NW_PATH *nwpath, if (f != (DIR*)NULL) { char *kpath=xkpath+strlen(xkpath); *kpath++ = '/'; - *kpath = '\0'; if (*sequence == MAX_U16) *sequence = 0; while (akt_sequence++ < *sequence) { @@ -860,44 +676,29 @@ static int get_dir_entry(NW_PATH *nwpath, okflag = -0xff; (*sequence)++; if (dirbuff->d_ino) { - uint8 *name = (uint8 *)(dirbuff->d_name); - uint8 dosname[DOS83_NAME_MAX + 1]; - - okflag = -0xff; - - if (name[0] != '.') { - okflag = dos83_match_name_in_dir(xkpath, - name, - entry, - soptions, - dosname, - sizeof(dosname)) ? 0 : -0xff; - XDPRINTF((2,0, - "CONNECT get_dir_entry dir='%s' entry='%s' unix='%s' alias='%s' ok=%d", - xkpath, - entry, - name, - dosname, - okflag == 0 ? 1 : 0)); - } - + uint8 *name=(uint8*)(dirbuff->d_name); + uint8 dname[256]; + xstrcpy(dname, name); + unix2doscharset(dname); + okflag = ((name[0] != '.' && + ( (!strcmp((char*)dname, (char*)entry)) + || fn_dos_match(dname, entry, soptions)))) ? 0 : -0xff; if (!okflag) { *kpath = '\0'; - strmaxcpy(kpath, (char *)name, sizeof(xkpath) - (int)(kpath - xkpath) - 1); + strmaxcpy(kpath, (char*)name, sizeof(xkpath) - (int)(kpath-xkpath) -1); if (!s_stat(xkpath, statb, NULL)) { - okflag = ((((statb->st_mode & S_IFMT) == S_IFDIR) && (attrib & 0x10)) - || (((statb->st_mode & S_IFMT) != S_IFDIR) && !(attrib & 0x10))) + okflag = (( ( ( (statb->st_mode & S_IFMT) == S_IFDIR) && (attrib & 0x10)) + || ( ( (statb->st_mode & S_IFMT) != S_IFDIR) && !(attrib & 0x10)))) ? 0 : -0xff; if (!okflag){ - if ((!no_search_trustee) || + if ( (!no_search_trustee) || !tru_eff_rights_exists(volume, xkpath, statb, TRUSTEE_T)) { if (soptions & VOL_OPTION_IS_PIPE) { - statb->st_size = 0x70000000 | (statb->st_mtime & 0xfffffff); + statb->st_size = 0x70000000|(statb->st_mtime&0xfffffff); } - /* Return the generated DOS-visible short name. */ - xstrcpy(nwpath->fn, (char *)dosname); - XDPRINTF((5,0,"FOUND DOS alias=:%s: attrib=0x%x", nwpath->fn, statb->st_mode)); + xstrcpy(nwpath->fn, (char*)dname); + XDPRINTF((5,0,"FOUND=:%s: attrib=0x%x", nwpath->fn, statb->st_mode)); break; /* ready */ } else okflag = -0xff; @@ -979,16 +780,12 @@ static int get_dh_entry(DIR_HANDLE *dh, dh->sequence++; if (dirbuff->d_ino) { uint8 *name=(uint8*)(dirbuff->d_name); - uint8 dosname[DOS83_NAME_MAX + 1]; - - if (name[0] != '.') { - okflag = dos83_match_name_in_dir(dh->unixname, - name, - entry, - dh->vol_options, - dosname, - sizeof(dosname)); - } + uint8 dname[256]; + xstrcpy(dname, name); + unix2doscharset(dname); + okflag = (name[0] != '.' && + ( (!strcmp((char*)dname, (char*)entry)) + || fn_dos_match(dname, entry, dh->vol_options))); if (okflag) { strmaxcpy(dh->kpath, (char*)name, @@ -1008,8 +805,7 @@ static int get_dh_entry(DIR_HANDLE *dh, if (okflag){ if (unixname) strmaxcpy(unixname, dh->unixname, size_unixname-1); - /* Return the DOS-visible alias instead of the raw name. */ - strmaxcpy((char*)search, (char*)dosname, size_search-1); + strmaxcpy((char*)search, (char*)dname, size_search-1); break; /* ready */ } } else okflag = 0; @@ -1152,12 +948,6 @@ static int build_dir_name(NW_PATH *nwpath, /* gets complete path */ uint8 *p=searchpath; uint8 *ppp=nwpath->path; int completition=0; - XDPRINTF((2,0, - "BUILD_DIR ENTER volume=%d path='%s' fn='%s' dirhandle=%d", - nwpath ? nwpath->volume : -1, - (nwpath && nwpath->path) ? (char *)nwpath->path : "(null)", - (nwpath && nwpath->fn) ? (char *)nwpath->fn : "(null)", - dir_handle)); xstrcpy(searchpath, (char*)ppp); /* save path */ @@ -1248,70 +1038,26 @@ static int build_dir_name(NW_PATH *nwpath, /* gets complete path */ up_fn(ppp); up_fn(nwpath->fn); } - XDPRINTF((2,0, - "BUILD_DIR OPTIONS volume=%d options=0x%x IGNCASE=%d path='%s' fn='%s'", - nwpath->volume, - v->options, - !!(v->options & VOL_OPTION_IGNCASE), - nwpath->path, - nwpath->fn)); if (v->options & VOL_OPTION_IGNCASE) { uint8 unixname[1024]; /* should be enough */ uint8 *pp=unixname+v->unixnamlen; + int offset = ppp - nwpath->path; int pathlen = strlen(nwpath->path); int fnlen = strlen(nwpath->fn); - int resolve_result; - memcpy(unixname, v->unixname, v->unixnamlen); strmaxcpy(pp, nwpath->path, sizeof(unixname) - v->unixnamlen-1); if (fnlen) strmaxcpy(pp+pathlen, nwpath->fn, sizeof(unixname) - v->unixnamlen - pathlen-1 ); dos2unixcharset(pp); - - XDPRINTF((2, 0, - "OPEN RESOLVE START volume=%d path='%s' fn='%s' unix='%s'", - nwpath->volume, - nwpath->path, - nwpath->fn, - unixname)); - - resolve_result = resolve_dos_nwpath_in_place(v, nwpath->path, nwpath->fn); - - if (resolve_result) { - XDPRINTF((2, 0, - "OPEN RESOLVE FALLBACK result=0x%x path='%s' fn='%s'", - resolve_result, - nwpath->path, - nwpath->fn)); - - /* Keep the old path mangling as fallback for comparison/debugging. */ - { - int offset = ppp - nwpath->path; - uint8 *pp_old = unixname + v->unixnamlen; - int pathlen_old = strlen(nwpath->path); - int fnlen_old = strlen(nwpath->fn); - - strmaxcpy(pp_old, nwpath->path, sizeof(unixname) - v->unixnamlen-1); - if (fnlen_old) - strmaxcpy(pp_old+pathlen_old, nwpath->fn, - sizeof(unixname) - v->unixnamlen - pathlen_old-1 ); - dos2unixcharset(pp_old); - pp_old += offset; - pathlen_old -= offset; - mangle_dos_name(v, unixname, pp_old); - unix2doscharset(pp_old); - XDPRINTF((2, 0, "OPEN RESOLVE FALLBACK MANGLED unix='%s'", unixname)); - memcpy(ppp, pp_old, pathlen_old); - if (fnlen_old) - memcpy(nwpath->fn, pp_old+pathlen_old, fnlen_old); - } - } else { - XDPRINTF((2, 0, - "OPEN RESOLVE APPLIED path='%s' fn='%s'", - nwpath->path, - nwpath->fn)); - } + pp += offset; + pathlen -= offset; + mangle_dos_name(v, unixname, pp); + unix2doscharset(pp); + XDPRINTF((5, 0, "Mangled DOS/unixname=%s", unixname)); + memcpy(ppp, pp, pathlen); + if (fnlen) + memcpy(nwpath->fn, pp+pathlen, fnlen); } } else return(-0x98); /* wrong volume */ completition = nw_path_directory_is_ok(nwpath, stbuff); @@ -1327,12 +1073,6 @@ static int conn_get_kpl_path(NW_PATH *nwpath, struct stat *stbuff, */ { int completition = build_path(nwpath, data, len, only_dir); - XDPRINTF((2,0, - "KPL ENTER dirhandle=%d len=%d only_dir=%d data0=0x%x", - dirhandle, - len, - only_dir, - data ? (unsigned int)data[0] : 0)); XDPRINTF((5, 0, "compl=0x%x, conn_get_kpl_path %s", completition, conn_get_nwpath_name(nwpath))); if (!completition) completition = build_dir_name(nwpath, stbuff, dirhandle); @@ -2590,38 +2330,13 @@ int nw_creat_open_file(int dir_handle, uint8 *data, int len, { NW_PATH nwpath; struct stat stbuff; - char reqname[300]; - - if (len < 0) len = 0; - if (len >= (int)sizeof(reqname)) len = sizeof(reqname) - 1; - memcpy(reqname, data, len); - reqname[len] = '\0'; - - XDPRINTF((2,0, - "CONNECT nw_creat_open_file ENTER dir_handle=%d attrib=0x%x access=0x%x creatmode=0x%x task=%d req='%s'", - dir_handle, attrib, access, creatmode, task, reqname)); - int completition = conn_get_kpl_path(&nwpath, &stbuff, dir_handle, data, len, 0); - - XDPRINTF((2,0, - "CONNECT nw_creat_open_file KPL result=0x%x req='%s'", - completition, reqname)); - if (completition > -1) { char unixname[300]; xstrcpy(unixname, build_unix_name(&nwpath, 0)); - - XDPRINTF((2,0, - "CONNECT nw_creat_open_file UNIX path='%s' nwpath.path='%s' nwpath.fn='%s' volume=%d", - unixname, nwpath.path, nwpath.fn, nwpath.volume)); - completition=file_creat_open(nwpath.volume, (uint8*)unixname, &stbuff, attrib, access, creatmode, task); - XDPRINTF((2,0, - "CONNECT nw_creat_open_file OPEN result=0x%x unix='%s'", - completition, unixname)); - if (completition > -1) get_file_attrib(info, unixname, &stbuff, &nwpath); } @@ -2964,7 +2679,13 @@ static int get_match(uint8 *unixname, uint8 *p) return(0); } -/* mangle_dos_name() moved to dosmangle.c */ +void mangle_dos_name(NW_VOL *vol, uint8 *unixname, uint8 *pp) +{ + struct stat stb; + if (!s_stat(unixname, &stb, NULL)) /* path is ok I hope */ + return; + get_match(unixname, pp-1); +} int nw_add_trustee(int dir_handle, uint8 *data, int len, diff --git a/src/namedos.c b/src/namedos.c index ef50f01..7ec0c72 100644 --- a/src/namedos.c +++ b/src/namedos.c @@ -1,519 +1,291 @@ -/* - * namedos.c +/* nameos2.c 14-May-97 : NameSpace DOS Services, mars_nwe */ +/* (C)opyright (C) 1993,1996 Martin Stover, Marburg, Germany * - * Centralized DOS 8.3 short-name support. + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "net.h" - #include +#include +#ifndef LINUX #include -#include -#include -#include +#endif #include "nwfname.h" #include "nwvolume.h" #include "connect.h" +#include "nwfile.h" +#include "unxfile.h" #include "namedos.h" -static int dos83_valid_char(int c) +#if WITH_NAME_SPACE_CALLS + +#define MAX_NAME_DOS_CACHE 0 + +#if MAX_NAME_DOS_CACHE +typedef struct { + uint8 *cache[MAX_NAME_DOS_CACHE]; +} DOSBUF; + +static void init_dosbuf(NW_VOL *vol) { - if (c >= 'A' && c <= 'Z') return 1; - if (c >= 'a' && c <= 'z') return 1; - if (c >= '0' && c <= '9') return 1; - if (c == '_' || c == '-') return 1; - return 0; + vol->dosbuf = xcmalloc(sizeof(DOSBUF)); } -static char dos83_upchar(int c) +static int vgl_name(uint8 *s, uint8 *p) { - if (c >= 'a' && c <= 'z') - return (char)(c - 'a' + 'A'); - return (char)c; -} - -static void dos83_split_name(const uint8 *src, - char *base, int base_sz, - char *ext, int ext_sz) -{ - const char *dot = strrchr((const char *)src, '.'); - int len; - - if (base_sz > 0) base[0] = '\0'; - if (ext_sz > 0) ext[0] = '\0'; - - if (dot && dot != (const char *)src) { - len = (int)(dot - (const char *)src); - if (len >= base_sz) len = base_sz - 1; - memcpy(base, src, len); - base[len] = '\0'; - - strncpy(ext, dot + 1, ext_sz - 1); - ext[ext_sz - 1] = '\0'; - } else { - strncpy(base, (const char *)src, base_sz - 1); - base[base_sz - 1] = '\0'; - } -} - -static void dos83_normalize_part(const char *src, char *dst, int dst_sz, int maxlen) -{ - int di = 0; - - while (*src && di < dst_sz - 1 && di < maxlen) { - unsigned char c = (unsigned char)*src++; - if (c == ' ') - continue; - if (dos83_valid_char(c)) - dst[di++] = dos83_upchar(c); - } - dst[di] = '\0'; -} - -static void dos83_normalize_part_full(const char *src, char *dst, int dst_sz) -{ - int di = 0; - - while (*src && di < dst_sz - 1) { - unsigned char c = (unsigned char)*src++; - if (c == ' ') - continue; - if (dos83_valid_char(c)) - dst[di++] = dos83_upchar(c); - } - dst[di] = '\0'; -} - -int dos83_is_valid_name(const uint8 *name, int options) -{ - const uint8 *ss = name; - int len = 0; - int pf = 0; - - for (; *ss; ss++) { - if (*ss == '.') { - if (pf++) return 0; - len = 0; - } else { - ++len; - if ((pf && len > 3) || len > 8) - return 0; - - if (!(options & VOL_OPTION_IGNCASE)) { - if (options & VOL_OPTION_DOWNSHIFT) { - if (*ss >= 'A' && *ss <= 'Z') - return 0; - } else { - if (*ss >= 'a' && *ss <= 'z') - return 0; - } - } - - if (!dos83_valid_char(*ss)) - return 0; + int hit=0; + if (!s) return(0); + for (; *s && *p; s++,p++) { + if (*s == *p) { + if (*s == '/') + ++hit; + } else if ((!isalpha(*p)) || (!isalpha(*s)) + || (*p | 0x20) != (*s | 0x20)) { + return(hit); } } - return (*name != '\0'); + return((*s == *p) ? -1 : hit); +} +#endif + +static int my_match(uint8 *s, uint8 *p) +{ + int len=0; + for (; *s && *p; s++,p++) { + if (!ufn_imatch(*s, *p)) + return(0); + ++len; + } + return( ((!*s) && (*p=='/' || *p == '\0')) ? len : 0); } -static void dos83_build_alias_candidate(const uint8 *src, int seq, - uint8 *out, int out_size) +static int get_match(uint8 *unixname, uint8 *p) { - char base[260], ext[260]; - char nbase_full[260], next[4]; - char stem[9]; - char seqbuf[16]; - int stem_len; - - dos83_split_name(src, base, sizeof(base), ext, sizeof(ext)); - dos83_normalize_part_full(base, nbase_full, sizeof(nbase_full)); - dos83_normalize_part(ext, next, sizeof(next), 3); - - if (!*nbase_full) - strcpy(nbase_full, "FILE"); - - sprintf(seqbuf, "~%d", seq); - - stem_len = 8 - (int)strlen(seqbuf); - if (stem_len > 6) stem_len = 6; - if (stem_len < 1) stem_len = 1; - if (stem_len > (int)strlen(nbase_full)) - stem_len = (int)strlen(nbase_full); - - memcpy(stem, nbase_full, stem_len); - stem[stem_len] = '\0'; - - if (*next) - snprintf((char *)out, out_size, "%s%s.%s", stem, seqbuf, next); - else - snprintf((char *)out, out_size, "%s%s", stem, seqbuf); -} - -static void dos83_build_plain_alias(const uint8 *src, uint8 *out, int out_size) -{ - char base[260], ext[260]; - char nbase[9], next[4]; - - dos83_split_name(src, base, sizeof(base), ext, sizeof(ext)); - dos83_normalize_part(base, nbase, sizeof(nbase), 8); - dos83_normalize_part(ext, next, sizeof(next), 3); - - if (!*nbase) - strcpy(nbase, "FILE"); - - if (*next) - snprintf((char *)out, out_size, "%s.%s", nbase, next); - else - snprintf((char *)out, out_size, "%s", nbase); -} - -static int dos83_same_plain_family(const uint8 *a, const uint8 *b) -{ - uint8 aa[DOS83_NAME_MAX + 1]; - uint8 bb[DOS83_NAME_MAX + 1]; - - dos83_build_plain_alias(a, aa, sizeof(aa)); - dos83_build_plain_alias(b, bb, sizeof(bb)); - return !strcmp((char *)aa, (char *)bb); -} - -static int dos83_compute_family_rank(const char *dir_unix, - const uint8 *src, - int options) -{ - DIR *d; - struct dirent *dirbuff; - int rank = 0; - - if (!dir_unix) - return 0; - - d = opendir(dir_unix); - if (!d) { - if (seteuid(0)) {} - d = opendir(dir_unix); - reseteuid(); - } - if (!d) - return 0; - - while ((dirbuff = readdir(d)) != NULL) { - if (!dirbuff->d_ino) - continue; - if (!strcmp(dirbuff->d_name, ".") || !strcmp(dirbuff->d_name, "..")) - continue; - if (!strcmp(dirbuff->d_name, (const char *)src)) - break; - - if (!dos83_is_valid_name((uint8 *)dirbuff->d_name, options) && - dos83_same_plain_family((uint8 *)dirbuff->d_name, src)) - rank++; - } - - closedir(d); - return rank; -} - -static void dos83_build_ranked_alias(const uint8 *src, - int rank, - uint8 *out, - int out_size) -{ - if (rank <= 0) - dos83_build_plain_alias(src, out, out_size); - else - dos83_build_alias_candidate(src, rank, out, out_size); -} - -static int dos83_alias_used_in_dir(const char *dir_unix, - const uint8 *src, - const uint8 *candidate, - int options) -{ - DIR *d; - struct dirent *dirbuff; - int src_rank = dos83_compute_family_rank(dir_unix, src, options); - - d = opendir(dir_unix); - if (!d) { - if (seteuid(0)) {} - d = opendir(dir_unix); - reseteuid(); - } - if (!d) - return 0; - - XDPRINTF((2,0, - "DOS83 COLLISION CHECK dir='%s' src='%s' candidate='%s' src_rank=%d", - dir_unix ? dir_unix : "(null)", - src ? (char *)src : "(null)", - candidate ? (char *)candidate : "(null)", - src_rank)); - - while ((dirbuff = readdir(d)) != NULL) { - uint8 other[DOS83_NAME_MAX + 1]; - - if (!dirbuff->d_ino) - continue; - if (!strcmp(dirbuff->d_name, ".") || !strcmp(dirbuff->d_name, "..")) - continue; - if (!strcmp(dirbuff->d_name, (const char *)src)) - continue; - - if (dos83_is_valid_name((uint8 *)dirbuff->d_name, options)) { - strncpy((char *)other, dirbuff->d_name, sizeof(other) - 1); - other[sizeof(other) - 1] = '\0'; - up_fn(other); - - XDPRINTF((2,0, - "DOS83 COLLISION EXISTING8 raw='%s' alias='%s' candidate='%s'", - dirbuff->d_name, - other, - candidate)); - - if (!strcmp((char *)other, (const char *)candidate)) { - closedir(d); - return 1; - } - continue; - } - - if (dos83_same_plain_family((uint8 *)dirbuff->d_name, src)) { - int other_rank = dos83_compute_family_rank(dir_unix, - (uint8 *)dirbuff->d_name, - options); - dos83_build_ranked_alias((uint8 *)dirbuff->d_name, - other_rank, - other, - sizeof(other)); - - XDPRINTF((2,0, - "DOS83 COLLISION FAMILY raw='%s' alias='%s' candidate='%s' other_rank=%d", - dirbuff->d_name, - other, - candidate, - other_rank)); - - if (!strcmp((char *)other, (const char *)candidate)) { - closedir(d); - return 1; - } - } - } - - closedir(d); - return 0; -} - -int dos83_build_name_in_dir(const char *dir_unix, - const uint8 *src, - uint8 *out, - int out_size, - int options) -{ - int rank; - - if (!src || !*src || !out || out_size <= 0) - return 0; - - if (dos83_is_valid_name(src, options)) { - strncpy((char *)out, (const char *)src, out_size - 1); - out[out_size - 1] = '\0'; - up_fn(out); - XDPRINTF((2,0, - "DOS83 BUILD dir='%s' src='%s' out='%s' valid=%d", - dir_unix ? dir_unix : "(null)", - src ? (char *)src : "(null)", - out ? (char *)out : "(null)", - dos83_is_valid_name(src, options))); - return (int)strlen((char *)out); - } - - rank = dos83_compute_family_rank(dir_unix, src, options); - dos83_build_ranked_alias(src, rank, out, out_size); - - XDPRINTF((2,0, - "DOS83 BUILD dir='%s' src='%s' out='%s' valid=%d rank=%d", - dir_unix ? dir_unix : "(null)", - src ? (char *)src : "(null)", - out ? (char *)out : "(null)", - dos83_is_valid_name(src, options), - rank)); - - if (dir_unix && dos83_alias_used_in_dir(dir_unix, src, out, options)) { - int seq = rank > 0 ? rank : 1; - do { - seq++; - dos83_build_alias_candidate(src, seq, out, out_size); - XDPRINTF((2,0, - "DOS83 BUILD retry dir='%s' src='%s' out='%s' seq=%d", - dir_unix ? dir_unix : "(null)", - src ? (char *)src : "(null)", - out ? (char *)out : "(null)", - seq)); - } while (seq < 1000000 && dos83_alias_used_in_dir(dir_unix, src, out, options)); - } - - return (int)strlen((char *)out); -} - -static int dos83_strip_magic(const uint8 *in, uint8 *out, int out_size) -{ - const uint8 *p = in; - uint8 *q = out; - - while (*p && (q - out) < out_size - 1) { - if (*p != 0xff) - *q++ = *p; - p++; - } - *q = '\0'; - return (int)(q - out); -} - -static int dos83_x_str_match(const uint8 *s, const uint8 *p, int soptions) -{ - uint8 pbuf[256]; - - dos83_strip_magic(p, pbuf, sizeof(pbuf)); - return fn_dos_match((uint8 *)s, pbuf, soptions); -} - -int dos83_match_name_in_dir(const char *dir_unix, - const uint8 *unix_name, - const uint8 *dos_pattern, - int options, - uint8 *out_dos_name, - int out_dos_name_size) -{ - uint8 dos_name[DOS83_NAME_MAX + 1]; - - if (!unix_name || !dos_pattern) - return 0; - - dos83_build_name_in_dir(dir_unix, unix_name, dos_name, sizeof(dos_name), options); - - if (out_dos_name && out_dos_name_size > 0) { - strncpy((char *)out_dos_name, (const char *)dos_name, out_dos_name_size - 1); - out_dos_name[out_dos_name_size - 1] = '\0'; - } - - { - int match_result = dos83_x_str_match(dos_name, dos_pattern, options); - XDPRINTF((2,0, - "DOS83 MATCH dir='%s' unix='%s' pattern='%s' alias='%s' result=%d", - dir_unix ? dir_unix : "(null)", - unix_name ? (char *)unix_name : "(null)", - dos_pattern ? (char *)dos_pattern : "(null)", - dos_name, - match_result)); - return match_result; - } -} - -int dos83_resolve_component(const char *dir_unix, - const uint8 *dos_name, - uint8 *resolved_name, - int resolved_size, - int options) -{ - DIR *d; - struct dirent *dirbuff; - uint8 clean_name[256]; - - if (!dir_unix || !dos_name || !*dos_name || !resolved_name || resolved_size <= 0) - return 0; - - dos83_strip_magic(dos_name, clean_name, sizeof(clean_name)); - up_fn(clean_name); - - d = opendir(dir_unix); - if (!d) { - if (seteuid(0)) {} - d = opendir(dir_unix); - reseteuid(); - } - if (!d) - return 0; - - while ((dirbuff = readdir(d)) != NULL) { - uint8 dos_alias[DOS83_NAME_MAX + 1]; - - if (!dirbuff->d_ino) - continue; - - dos83_build_name_in_dir(dir_unix, - (uint8 *)dirbuff->d_name, - dos_alias, - sizeof(dos_alias), - options); - - if (!strcmp((char *)dos_alias, (const char *)clean_name)) { - strncpy((char *)resolved_name, dirbuff->d_name, resolved_size - 1); - resolved_name[resolved_size - 1] = '\0'; - closedir(d); - return 1; - } - } - - closedir(d); - return 0; -} - -static int dos83_get_match(uint8 *unixname, uint8 *p, int options) -{ - DIR *d; - - if (!p || !*p) - return 1; - - *p = '\0'; - - d = opendir((char *)unixname); - if (!d) { - if (seteuid(0)) {} - d = opendir((char *)unixname); - reseteuid(); - } - - if (d) { + DIR *d; + if (!p || !*p) return(1); + *p = '\0'; + if (NULL != (d=opendir(unixname))) { struct dirent *dirbuff; - *p = '/'; - - while ((dirbuff = readdir(d)) != NULL) { + XDPRINTF((10, 0, "opendir OK unixname='%s' p='%s'", unixname, p+1)); + *p = '/'; + while ((dirbuff = readdir(d)) != (struct dirent*)NULL){ int len; - uint8 resolved[256]; - - if (!dirbuff->d_ino) - continue; - - if (dos83_resolve_component((char *)unixname, - p + 1, - resolved, - sizeof(resolved), - options)) { - strncpy((char *)(p + 1), (const char *)resolved, 255); - closedir(d); - - len = (int)strlen((char *)(p + 1)); - return dos83_get_match(unixname, p + 1 + len, options); + if (dirbuff->d_ino) { + XDPRINTF((10, 0, "get match found d_name='%s'", dirbuff->d_name)); + if (0 != (len=my_match(dirbuff->d_name, p+1))) { + memcpy(p+1, dirbuff->d_name, len); + XDPRINTF((10, 0, "get match, match OK")); + closedir(d); + return(get_match(unixname, p+1+len)); + } } } closedir(d); } else { - *p = '/'; + XDPRINTF((2, 0, "dos get_match opendir failed unixname='%s'", unixname)); + *p='/'; } - - return 0; + return(0); } -void mangle_dos_name(NW_VOL *vol, uint8 *unixname, uint8 *pp) +#if MAX_NAME_DOS_CACHE +static int get_name(uint8 *s, uint8 *unixname, int hit, uint8 *p) { - struct stat stbuff; - - if (!stat((char *)unixname, &stbuff)) - return; - - dos83_get_match(unixname, pp - 1, vol->options); + if (hit && s) { + for (; *s && *p; s++,p++) { + if (*s=='/') { + if (!--hit) break; + } else *p=*s; + } + } else + --p; /* to get last '/' */ + return(get_match(unixname, p)); } +#endif + +void mangle_dos_name(NW_VOL *vol, uint8 *unixname, uint8 *pp, int len) +{ +#if MAX_NAME_DOS_CACHE + int k = -1; + int besthit = -1; + int maxhits = 0; + DOSBUF *b; + if (!vol->dosbuf) init_dosbuf(vol); + b= (DOSBUF*)vol->dosbuf; + + while (++k < MAX_NAME_DOS_CACHE) { + int hits=vgl_name(b->cache[k], pp); + if (hits < 0) { + besthit=k; + break; + } else if (hits > maxhits) { + besthit=k; + maxhits =hits; + } + } + if (maxhits > -1) { + /* do not completely match */ + if (get_name(maxhits ? b->cache[besthit] : NULL, + unixname, maxhits, pp)) { + int k=MAX_NAME_DOS_CACHE-1; + xfree(b->cache[k]); + while (k--) { + b->cache[k+1] = b->cache[k]; + } + b->cache[0] = NULL; + new_str(b->cache[0], pp); + } + } else { + strncpy(pp, b->cache[besthit], len-1); + if (besthit > 2) { + uint8 *sp=b->cache[besthit]; + while (besthit--) { + b->cache[besthit+1] = b->cache[besthit]; + } + b->cache[0] = sp; + } + } +#else + get_match(unixname, pp-1); +#endif +} + +static inline int get_n_p(uint8 **p) +{ + int pc=**p; + (*p)++; + if (pc == '\\') { + pc=**p; + (*p)++; + } else if (pc == 255) { + pc=**p; + (*p)++; + switch (pc) { + case 0xaa : + case '*' : return(3000); /* star */ + + case 0xae : + case '.' : return(1000); /* point */ + + case 0xbf : + case '?' : return(2000); /* ? */ + + default : break; + } + } + return(pc); +} + +int fn_dos_match(uint8 *s, uint8 *p, int soptions) +/* OS/2 name matching routine */ +{ + int pc, sc; + uint state = 0; + int anf, ende; + int not = 0; + uint found = 0; + while ( (pc = get_n_p(&p)) != 0) { + if (!(soptions & VOL_OPTION_IGNCASE)) { + if (soptions & VOL_OPTION_DOWNSHIFT){ /* only downshift chars */ + if (*s >= 'A' && *s <= 'Z') return(0); + } else { + if (*s >= 'a' && *s <= 'z') return(0); + } + } + switch (state){ + case 0 : + switch (pc) { + case '.' : + case 1000: if (*s && ('.' != *s++)) + return(0); + break; + + case '?' : + case 2000: if (!*s) return(0); + ++s; + break; + + case '*' : + case 3000: { + uint8 *pp; + int np; + if (!*p) return(1); /* last star */ + while (*s) { + if (fn_dos_match(s, p, soptions) == 1) return(1); + else if (*s=='.') { + pp=p; + if (!get_n_p(&p) || !get_n_p(&p)) + return(0); + p=pp; + } + ++s; + } + pp=p; + np=get_n_p(&p); + p=pp; + if (np == '.' || np == 1000) + return(fn_dos_match(s, p, soptions)); + } + return(0); + + case '[' : if ( (*p == '!') || (*p == '^') ){ + ++p; + not = 1; + } + state = 1; + continue; + + default : if (soptions & VOL_OPTION_IGNCASE) { + if (!dfn_imatch(*s, pc)) + return(0); + } else if (pc != *s) 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 */ + if (*s=='.' && *(s+1)=='\0') return(1); + return ( (*s) ? 0 : 1); +} +#endif diff --git a/src/namspace.c b/src/namspace.c index 561fa44..8f68b77 100644 --- a/src/namspace.c +++ b/src/namspace.c @@ -45,16 +45,11 @@ #include "unxfile.h" #include "namspace.h" #include "nameos2.h" -#include "namedos.h" #if WITH_NAME_SPACE_CALLS #define NW_PATH /* */ -static int ns06_fallback_obtain_info(int namespace, NW_HPATH *nwp, - int destnamspace, int searchattrib, - uint32 infomask, uint8 *responsedata); - typedef struct { int volume; /* Volume Number */ int has_wild; /* fn has wildcards */ @@ -911,48 +906,48 @@ static int build_base(int namespace, return(result); } -/* - * Build the DOS-visible short name for one namespace directory entry. - * - * This wrapper delegates all DOS short-name generation to dosmangle.c so - * that DOS namespace listings use the same naming rules as DOS path lookup - * and DOS wildcard matching. - */ static int build_dos_name(DIR_BASE_ENTRY *e, uint8 *fname, int size_fname) { - char dir_unix[1024]; - char *slash; - uint8 *unixname; - int options; - - if (!e || !fname || size_fname <= 0) - return 0; - - options = get_volume_options(e->nwpath.volume); - - /* - * Convert the full entry path to Unix form, then strip the last component. - * dosmangle.c uses the containing directory to check for alias collisions. - */ - unixname = alloc_nwpath2unix(&(e->nwpath), 2); - if (!unixname) - return 0; - - strncpy(dir_unix, (char *)unixname, sizeof(dir_unix) - 1); - dir_unix[sizeof(dir_unix) - 1] = '\0'; - xfree(unixname); - - slash = strrchr(dir_unix, '/'); - if (slash) - *slash = '\0'; - else - strcpy(dir_unix, "."); - - return dos83_build_name_in_dir(dir_unix, - e->nwpath.fn, - fname, - size_fname, - options); + uint8 *ss=e->nwpath.fn; + int len=0; + int pf=0; + int is_ok=1; + int options=get_volume_options(e->nwpath.volume); + for (; *ss; ss++){ + if (*ss == '.') { + if (pf++) { /* no 2. point */ + is_ok=0; + break; + } + len=0; + } else { + ++len; + if ((pf && len > 3) || len > 8) { + is_ok=0; + break; + } + if (!(options & VOL_OPTION_IGNCASE)){ + if (options & VOL_OPTION_DOWNSHIFT){ /* only downshift chars */ + if (*ss >= 'A' && *ss <= 'Z') { + is_ok=0; + break; + } + } else { /* only upshift chars */ + if (*ss >= 'a' && *ss <= 'z') { + is_ok=0; + break; + } + } + } + } + } + if (is_ok) { + strmaxcpy(fname, e->nwpath.fn, size_fname-1); + up_fn(fname); + return(strlen(fname)); + } else { + return(sprintf(fname, "%ld.___", (long)e->nwpath.statb.st_ino)); + } } #if 0 @@ -1035,7 +1030,7 @@ int nw_generate_dir_path(int namespace, DIR_BASE_ENTRY *dbe=dir_base[result]; U32_TO_32(dbe->basehandle, ns_dir_base); /* LOW - HIGH */ if (namespace != NAME_DOS) { - U32_TO_32(dbe->basehandle, dos_dir_base); + U32_TO_32(name_2_base(&(dbe->nwpath), NAME_DOS, 1), dos_dir_base); } else { U32_TO_32(dbe->basehandle, dos_dir_base); } @@ -1136,7 +1131,7 @@ static int build_dir_info(DIR_BASE_ENTRY *dbe, #if 0 U32_TO_32(dbe->basehandle, p); #else - U32_TO_32(dbe->basehandle, p); + U32_TO_32(name_2_base(nwpath, NAME_DOS, 1), p); #endif p +=4; U32_TO_32(nwpath->volume, p); @@ -1195,11 +1190,7 @@ int nw_optain_file_dir_info(int namespace, NW_HPATH *nwp, nwp_stat(&(dbe->nwpath), "nw_optain_file_dir_info"); result = build_dir_info(dbe, unixname, destnamspace, infomask, responsedata); xfree(unixname); - } else if ((result == -0xff || result == -0x9c) && - (namespace == NAME_DOS || namespace == NAME_OS2)) { - result = ns06_fallback_obtain_info(namespace, nwp, destnamspace, - searchattrib, infomask, responsedata); - } + } if (result < 0) { XDPRINTF((3, 0, "nw_optain_file_dir_info NOT OK result=-0x%x", -result)); } @@ -1526,49 +1517,7 @@ static int search_match(struct dirent *dirbuff, XDPRINTF((8,0,"search_match, Name='%s' dname='%s'", name, dname)); if (!inode_search) { if (namespace == NAME_DOS) { - char saved_dir[1024]; - char *slash; - uint8 dos_alias[DOS83_NAME_MAX + 1]; - - if (*name == '.') { - flag = 0; - } else { - /* - * Keep dname as the real name used later by get_add_new_entry(). - * Build the DOS-visible alias only for matching against the DOS - * namespace wildcard pattern. - */ - strncpy(saved_dir, (char *)ds->unixname, sizeof(saved_dir) - 1); - saved_dir[sizeof(saved_dir) - 1] = '\0'; - - slash = strrchr(saved_dir, '/'); - if (slash) - *slash = '\0'; - else - strcpy(saved_dir, "."); - - dos83_build_name_in_dir(saved_dir, - name, - dos_alias, - sizeof(dos_alias), - vol_options); - - XDPRINTF((2,0, - "NS search_match DOS alias entry='%s' raw='%s' alias='%s' namespace=%d", - entry, - name, - dos_alias, - namespace)); - - flag = fn_dos_match_old(dos_alias, entry, vol_options); - - XDPRINTF((2,0, - "NS search_match DOS alias result=%d entry='%s' raw='%s' alias='%s'", - flag, - entry, - name, - dos_alias)); - } + flag = (*name != '.' && fn_dos_match_old(dname, entry, vol_options)); } else if (namespace == NAME_OS2) { flag = (*name != '.' || (*(name+1) != '.' && *(name+1) != '\0' )) && fn_os2_match(dname, entry, vol_options); @@ -1965,74 +1914,6 @@ typedef struct { int searchattrib; uint8 *ubuf; /* userbuff */ } FUNC_SEARCH; -typedef struct { - FUNC_SEARCH base; - int destnamspace; - uint32 infomask; - uint8 *responsedata; - int build_result; -} NS06_OBTAIN_INFO_SEARCH; - -static int ns06_obtain_info_cb(DIR_BASE_ENTRY *dbe, FUNC_SEARCH *fs) -{ - NS06_OBTAIN_INFO_SEARCH *ois = (NS06_OBTAIN_INFO_SEARCH *)fs; - char *unixname = alloc_nwpath2unix(&(dbe->nwpath), 2); - - nwp_stat(&(dbe->nwpath), "ns06_obtain_info_cb"); - ois->build_result = build_dir_info(dbe, unixname, - ois->destnamspace, - ois->infomask, - ois->responsedata); - xfree(unixname); - return(ois->build_result); -} - -static int func_search_entry(DIR_BASE_ENTRY *dbe, int namespace, - uint8 *path, int len, int searchattrib, - int (*fs_func)(DIR_BASE_ENTRY *dbe, FUNC_SEARCH *fs), FUNC_SEARCH *fs); - -static int ns06_fallback_obtain_info(int namespace, NW_HPATH *nwp, - int destnamspace, int searchattrib, - uint32 infomask, uint8 *responsedata) -{ - uint8 search_entry[258]; - int parent_result; - NS06_OBTAIN_INFO_SEARCH ois; - - if (!nwp || nwp->components <= 0) - return(-0xff); - - memset(&ois, 0, sizeof(ois)); - ois.base.ubuf = responsedata; - ois.destnamspace = destnamspace; - ois.infomask = infomask; - ois.responsedata = responsedata; - ois.build_result = -0xff; - - parent_result = build_base(namespace, nwp, nwp->pathes, 1, - search_entry, sizeof(search_entry)); - - XDPRINTF((2, 0, - "NS06 FALLBACK namespace=%d parent_result=0x%x search='%s'", - namespace, parent_result, search_entry)); - - if (parent_result > -1) { - DIR_BASE_ENTRY *parent_dbe = dir_base[parent_result]; - int search_res = func_search_entry(parent_dbe, namespace, - search_entry, - strlen((char *)search_entry), - searchattrib, - ns06_obtain_info_cb, - (FUNC_SEARCH *)&ois); - XDPRINTF((2, 0, - "NS06 FALLBACK SEARCH search_res=0x%x build_result=0x%x search='%s'", - search_res, ois.build_result, search_entry)); - if (search_res == 0 && ois.build_result > -1) - return(ois.build_result); - } - return(-0xff); -} - static int func_search_entry(DIR_BASE_ENTRY *dbe, int namespace, uint8 *path, int len, int searchattrib, diff --git a/src/nwconn.c b/src/nwconn.c index 8cd4b05..62b252e 100644 --- a/src/nwconn.c +++ b/src/nwconn.c @@ -147,20 +147,6 @@ static int ncp_response(int sequence, int task, (int)completition, (int)ncpresponse->task, visable_ipx_adr((ipxAddr_t *) ud.addr.buf))); } - if (ncprequest->function == 0x57) { - int sub1 = (requestlen > 0) ? requestdata[0] : -1; - int sub2 = (requestlen > 1) ? requestdata[1] : -1; - int sub3 = (requestlen > 2) ? requestdata[2] : -1; - XDPRINTF((2,0, - "NS57S06 RESP compl=0x%x data_len=%d seq=%d task=%d sub1=0x%02x sub2=0x%02x sub3=0x%02x", - (int)completition, data_len, (int)sequence, (int)task, - sub1 & 0xff, sub2 & 0xff, sub3 & 0xff)); - if (sub1 == 0x06) { - XDPRINTF((2,0, - "NS57S06 TARGET RESP compl=0x%x data_len=%d sub2=0x%02x sub3=0x%02x", - (int)completition, data_len, sub2 & 0xff, sub3 & 0xff)); - } - } ud.udata.len = ud.udata.maxlen = sizeof(NCPRESPONSE) + data_len; if (t_sndudata(FD_NCP_OUT, &ud) < 0){ if (nw_debug) t_error("t_sndudata in NWCONN !OK"); @@ -205,51 +191,6 @@ static int call_nwbind(int mode) return(0); } - -static void debug_ns57_sub06_focus(uint8 *data, int len) -{ - int sub1 = (len > 0) ? data[0] : -1; - int sub2 = (len > 1) ? data[1] : -1; - int sub3 = (len > 2) ? data[2] : -1; - char ascii[260]; - int i, shown = len; - - if (shown > 200) - shown = 200; - if (shown < 0) - shown = 0; - - for (i = 0; i < shown && i < (int)sizeof(ascii) - 1; i++) { - int c = data ? data[i] : 0; - ascii[i] = (c >= 32 && c < 127) ? (char)c : '.'; - } - ascii[(shown < (int)sizeof(ascii) - 1) ? shown : ((int)sizeof(ascii) - 1)] = '\0'; - - XDPRINTF((2,0, - "NS57S06 ENTER len=%d sub1=0x%02x sub2=0x%02x sub3=0x%02x task=%d ascii='%s'", - len, sub1 & 0xff, sub2 & 0xff, sub3 & 0xff, - (int)ncprequest->task, ascii)); - - if (data && len > 0) { - int j = len; - uint8 *p = data; - XDPRINTF((2,2,"NS57S06 HEX len %d, DATA:", j)); - while (j--) { - int c = *p++; - if (c > 32 && c < 127) - XDPRINTF((2,3,",\'%c\'", (char)c)); - else - XDPRINTF((2,3,",0x%x", c)); - } - XDPRINTF((2,1,NULL)); - } - - if (sub1 == 0x06) { - XDPRINTF((2,0, - "NS57S06 TARGET len=%d sub2=0x%02x sub3=0x%02x", - len, sub2 & 0xff, sub3 & 0xff)); - } -} static void pr_debug_request() { if (req_printed++) return; @@ -367,10 +308,6 @@ static int handle_ncp_serv(void) if (nw_debug > 5) pr_debug_request(); - if (function == 0x57) { - debug_ns57_sub06_focus(requestdata, requestlen); - } - if (ncp_type == 0x2222) { switch (function) { @@ -1574,7 +1511,7 @@ static int handle_ncp_serv(void) uint8 *getsize=responsedata; int buffer_size = (int) (GET_BE16((uint8*)requestdata)); /* Der Novell-Client der PAM's Net/E-Ethernetkarte - f�r Atari ST/TT meldet ein Packetsize von 0 wenn + für Atari ST/TT meldet ein Packetsize von 0 wenn nwserv NACH dem Novell Client NET_S1.PRG gestartet wird. Da 0 in jedem Falle ein unsinniger Wert ist, wird rw_buffer_size nicht verwendet. @@ -1742,13 +1679,6 @@ static int handle_ncp_serv(void) uint8 reserved[2]; /* reserved by novell */ NW_FILE_INFO fileinfo; } *xdata= (struct XDATA*)responsedata; - input->data[input->len] = '\0'; - XDPRINTF((2,0, - "NWC OPEN41 dirhandle=%d len=%d name='%s' task=%d", - (int)input->dirhandle, - (int)input->len, - input->data, - (int)(ncprequest->task))); int fhandle=nw_creat_open_file((int)input->dirhandle, input->data, input->len, &(xdata->fileinfo), @@ -1756,11 +1686,6 @@ static int handle_ncp_serv(void) 0x1, /* read access */ 0, (int)(ncprequest->task)); - XDPRINTF((2,0, - "NWC OPEN41 RESULT fhandle=%d compl_if_err=0x%x name='%s'", - fhandle, - (fhandle < 0) ? -fhandle : 0, - input->data)); if (fhandle > -1){ U32_TO_32(fhandle, xdata->fhandle); @@ -2048,26 +1973,12 @@ static int handle_ncp_serv(void) uint8 reserved[2]; /* reserved by Novell */ NW_FILE_INFO fileinfo; } *xdata= (struct XDATA*)responsedata; - input->data[input->len] = '\0'; - XDPRINTF((2,0, - "NWC OPEN4C dirhandle=%d attrib=0x%x access=0x%x len=%d name='%s' task=%d", - (int)input->dirhandle, - (int)input->attrib, - (int)input->access, - (int)input->len, - input->data, - (int)(ncprequest->task))); int fhandle=nw_creat_open_file((int)input->dirhandle, input->data, input->len, &(xdata->fileinfo), (int)input->attrib, (int)input->access, 0, (int)(ncprequest->task)); - XDPRINTF((2,0, - "NWC OPEN4C RESULT fhandle=%d compl_if_err=0x%x name='%s'", - fhandle, - (fhandle < 0) ? -fhandle : 0, - input->data)); if (fhandle > -1){ U32_TO_32 (fhandle, xdata->fhandle);