/***********************************************************************
* *
* This software is part of the ast package *
* Copyright (c) 1989-2011 AT&T Intellectual Property *
* and is licensed under the *
* Eclipse Public License, Version 1.0 *
* by AT&T Intellectual Property *
* *
* A copy of the License is available at *
* (with md5 checksum b35adb5213ca9657e911e9befb180842) *
* *
* Information and Software Systems Research *
* AT&T Research *
* Florham Park NJ *
* *
* Glenn Fowler <gsf@research.att.com> *
* David Korn <dgk@research.att.com> *
* Eduardo Krell <ekrell@adexus.cl> *
* *
***********************************************************************/
#pragma prototyped
/*
* 3d file system library implementation
*
* debug level n enables tracing for all levels less than or equal to n
*
* level trace
* 0 no trace
* 1 basic calls
* 2 mounted fs
* 3 fs control
* 4 pathcanon
* 5 pathreal
* 6 pathnext
* 7 *unused*
* 8 *unused*
* 9 *unused*
* 10 getkey
*/
#include "3d.h"
#include <cs.h>
/*
* keep 3d tables from buf,siz in state.table.fd
* if force!=0 then state.table.fd set to TABLE_FD
* 0 returned if state.table.fd is ok
*/
int
{
int n;
{
return(-1);
}
{
return(0);
}
#if _stream_peek || _socket_peek
{
#if _socket_peek
#else
#endif
{
#if _pipe_rw || _lib_socketpair
#else
#endif
}
if (!n)
{
else
{
}
if (n)
{
return(0);
}
}
}
#else
{
else
{
CLOSE(n);
}
{
return(0);
}
}
#endif
return(-1);
}
/*
* allows state transitions without changing the tables
*/
int
{
register int po;
register int n;
init(1, 0, 0);
else
switch (n)
{
case FS3D_OP_INIT:
case FS3D_OP_TEST:
break;
case FS3D_OP_LIMIT:
n = TABSIZE;
break;
case FS3D_OP_OFF:
po = -1;
else
{
}
break;
case FS3D_OP_ON:
break;
default:
po = -1;
break;
}
return po;
}
/*
* for code that includes <fs3d.h>
*/
int
{
}
/*
* return 6 char lower case hash of key
* end is end of key string
* 0 returned at end of keys
* state.key.value is set to key value
* if `no<key>' then state.key.invert gets value and state.key.value=""
* otherwise state.key.invert=0
* state.key.next is set to next key if any
*/
unsigned long
{
register const char* val;
register unsigned long x = 0;
register int invert;
register int c;
#if DEBUG
const char* beg;
#endif
if (key)
{
#if DEBUG
#endif
{
key += 2;
invert = 1;
}
else invert = 0;
{
{
key++;
}
key++;
}
{
}
else
{
key++;
}
key++;
key++;
if (invert)
{
}
message((-10, "getkey: key=%-*s hash=%x value=%-*s next=%-*s", end - beg, beg, x, state.key.valsize, state.key.value, state.key.next ? end - state.key.next : 6, state.key.next));
}
return(x);
}
#if FS
/*
* return mount pointer for path
* under is set to the part of the path under the mount
*/
{
int n;
int oerrno;
if (!(map = search(&state.vmount, path, strlen(path), NiL, T_PREFIX)) || ((Mount_t*)map->val)->fs == state.fs)
return(0);
if (under)
{
else
{
if (n) return(0);
}
}
}
#endif
int
nosys(void)
{
return(-1);
}
/*
* copy t into s, return a pointer to the end of s ('\0')
*/
char*
strcopy(register char* s, register const char* t)
{
if (!t) return(s);
while (*s++ = *t++);
return(--s);
}
/*
* return map for <key,keysize> in tab
* if val!=0 then key=val inserted if not already entered
* valsize==0 causes string val to be malloc'd on insertion
* key is malloc'd on insertion if (valsize|T_ALLOCATE)
* valsize==T_DELETE for deletion
* valsize==T_PREFIX for longest path prefix search and val==visit_mask
*/
{
register const char* sp;
register const char* se;
register const char* tp;
register const char* te;
int n;
{
mid = 0;
{
message((-12, "T_PREFIX: %-*s: key=%-*s mid=%-*s", keysize, key, lo->keysize, lo->key, mid ? mid->keysize : 1, mid ? mid->key : "-"));
for (;;)
{
{
{
goto prefix;
}
break;
}
goto prefix;
if (n > 0)
{
goto prefix;
break;
}
}
lo++;
}
return(mid);
}
{
{
for (;;)
{
{
{
return(mid);
#if FS
else
#endif
return(0);
}
break;
}
{
break;
}
if (n > 0)
{
break;
}
}
}
}
return(0);
return(lo);
}
/*
* iterate fun over tab
* terminates on first negative return from fun
*/
int
{
register int n;
register int sum;
sum = 0;
{
return(0);
sum += n;
}
return(sum);
}
#if FS
/*
* initialize open file info
*/
int
{
register File_t* f;
int ffd;
int ffl;
if (!force && (f->flags & FILE_ERROR) || !st && FSTAT(fd, st = &sb) || (ffd = FCNTL(fd, F_GETFD, NiL)) == -1 || (ffl = FCNTL(fd, F_GETFL, NiL)) == -1)
{
f->flags = FILE_ERROR;
return -1;
}
f->open = 0;
f->flags |= FILE_REGULAR;
if (ffd & FD_CLOEXEC)
f->flags |= FILE_CLOEXEC;
f->flags |= FILE_WRITE;
return 0;
}
#endif