fs.c revision 3f54fd611f536639ec30dd53c48e5ec1897cc7d9
/***********************************************************************
* *
* 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 mounted fs support
*
* NOTE: be vewwwy careful with errno
*/
#include "3d.h"
#if FS
#include <cs.h>
#define MNTFD "path\n"
/*
* initialize mount channel and return fs fd for mp
*/
int
{
register int fd;
return -1;
return -1;
return fd;
}
/*
* generate phony monitor open for fd inherited from parent
*/
static void
{
register ssize_t n;
int nd;
char buf[64];
*buf = 0;
{
buf[n - 1] = 0;
}
if (*buf)
{
}
}
/*
* return real fd for up under mount mp to be accessed by call
* return value stuck in tail portion of state.path.name
*/
char*
{
register char* s = dev;
register int n;
register int fd;
int lz;
int pz;
n = sfsprintf(s, sizeof(dev) - 1, "%s %-*s %s%s%-*s pwd=%s%s%s", msgname(call), lz, mp->logical, up, pz ? " physical=" : "", pz, mp->physical ? mp->physical : "", state.pwd, mp->fs->attr, mp->attr);
s[n] = 0;
message((-2, "fs: %s: real: service=%-*s request=\"%s\"", fs->special, fs->servicesize, fs->service, s));
s[n++] = '\n';
return 0;
{
return 0;
}
if (n <= 1)
return 0;
s[n - 1] = 0;
if (s[0] >= 'A' && s[0] <= 'Z' && s[1] == ' ')
{
return 0;
}
return s;
}
/*
* do fs call
* -1 returned if not mounted
* 0 returned if mounted with state.ret call return value
* state.path.monitor set if monitor or name service mount
*/
int
{
register int retry;
register int tries;
const char* up;
const char* sp;
int cd;
int fd;
int oerrno;
int m;
long n;
void** xp;
void* xv[2];
int* ip;
initialize();
return -1;
up = 0;
/* proto workaround */
if (!mp)
{
sp = 0;
{
case MSG_ARG_file:
goto nope;
{
{
if ((!(fs->flags & FS_REGULAR) || (fp->flags & FILE_REGULAR)) && (!(fs->flags & FS_WRITE) || (fp->flags & FILE_WRITE)) && ((mp->flags & MOUNT_PRIMARY) || fd > 2) && !(fp->open & (1<<(mp-state.mount))))
}
break;
case MSG_ARG_string:
break;
}
goto nope;
{
{
{
{
}
}
}
goto nope;
}
}
goto nope;
goto nope;
{
goto nope;
{
goto nope;
goto nope;
goto nope;
if ((fs->flags & FS_REGULAR) && !(fp->flags & FILE_REGULAR) || (fs->flags & FS_WRITE) && !(fp->flags & FILE_WRITE))
goto nope;
if (fssys(mp, MSG_open) && ((mp->flags & MOUNT_PRIMARY) || fd > 2) && !(fp->open & (1<<(mp-state.mount))))
}
{
goto nope;
{
goto nope;
}
}
{
}
}
{
int oflag;
int mode;
int level;
{
const char* ep;
{
goto unlock;
}
if (*ep)
{
goto unlock;
}
{
goto unlock;
}
n &= O_ACCMODE;
{
goto unlock;
}
}
{
/*
* /#<id>/[#]<path> for active fd's
* /#<id>\n written back to initialize
*/
{
{
up = 0;
}
else
{
sp += 2;
}
}
else up = 0;
{
cd = -1;
}
{
*((char*)up + m++) = '\n';
fd = -1;
else
{
}
}
}
goto unlock;
}
else
rp = 0;
{
{
}
goto nope;
}
goto nope;
{
for (;;)
{
tries += MSG_ARG_TYPE;
{
case 0:
break;
case MSG_ARG_output:
/*FALLTHROUGH*/
case MSG_ARG_input:
case MSG_ARG_vector:
continue;
default:
continue;
}
break;
}
}
{
call |= MSG_RETURN;
}
else retry = 0;
tries = 1;
for (;;)
{
{
goto unlock;
}
{
case MSG_ARG_file:
break;
case MSG_ARG_string:
{
goto unlock;
}
break;
case MSG_ARG_output:
{
for (n = 0; n < 2; n++)
{
}
}
break;
default:
xp = 0;
break;
}
if (xp)
{
*xp = 0;
}
if (n != -1)
break;
{
break;
}
break;
}
{
if ((state.ret = n) > 0 && (fs->flags & (FS_ACTIVE|FS_INTERACTIVE|FS_MONITOR)) == (FS_ACTIVE|FS_INTERACTIVE|FS_MONITOR) && (fs->ack & MSG_MASK(call)))
{
{
buf[n - 1] = 0;
}
}
}
{
}
{
}
return 0;
nope:
return -1;
}
#endif
/*
* initialize mounted fs and return device service fd
*/
int
{
int n;
int oerrno;
if (fd < 0 && (fs->flags & (FS_BOUND|FS_ERROR|FS_INIT|FS_ON)) != (FS_BOUND|FS_ON) || state.kernel && (fs->flags & FS_GLOBAL))
return -1;
{
{
char* svc;
if (n = fs->servicesize)
{
svc[n] = 0;
}
#if FS
{
{
}
}
#endif
}
{
}
else
{
if (fd < 0)
message((-3, "fs: %s: init#3: service=%-*s fd=%d cache=%d", fs->special, fs->servicesize ? fs->servicesize : strlen(fs->service), fs->service, fs->fd, state.cache));
}
}
}
/*
* drop internal 3d mount
* if clear!=0 then path binding also cleared
*/
void
{
int oerrno;
{
}
if (clear)
{
#if FS
{
register int n;
register int m;
{
{
if (n != m)
m++;
}
}
{
{
}
}
}
#endif
else
{
{
}
}
}
}