2007-03-04 08:59:00 +03:00
|
|
|
/* $NetBSD: coda_venus.c,v 1.25 2007/03/04 06:01:12 christos Exp $ */
|
1998-08-30 01:26:45 +04:00
|
|
|
|
1998-09-08 21:12:46 +04:00
|
|
|
/*
|
2005-02-27 01:58:54 +03:00
|
|
|
*
|
1998-09-08 21:12:46 +04:00
|
|
|
* Coda: an Experimental Distributed File System
|
|
|
|
* Release 3.1
|
2005-02-27 01:58:54 +03:00
|
|
|
*
|
1998-09-08 21:12:46 +04:00
|
|
|
* Copyright (c) 1987-1998 Carnegie Mellon University
|
|
|
|
* All Rights Reserved
|
2005-02-27 01:58:54 +03:00
|
|
|
*
|
1998-09-08 21:12:46 +04:00
|
|
|
* Permission to use, copy, modify and distribute this software and its
|
|
|
|
* documentation is hereby granted, provided that both the copyright
|
|
|
|
* notice and this permission notice appear in all copies of the
|
|
|
|
* software, derivative works or modified versions, and any portions
|
|
|
|
* thereof, and that both notices appear in supporting documentation, and
|
|
|
|
* that credit is given to Carnegie Mellon University in all documents
|
|
|
|
* and publicity pertaining to direct or indirect use of this code or its
|
|
|
|
* derivatives.
|
2005-02-27 01:58:54 +03:00
|
|
|
*
|
1998-09-08 21:12:46 +04:00
|
|
|
* CODA IS AN EXPERIMENTAL SOFTWARE SYSTEM AND IS KNOWN TO HAVE BUGS,
|
|
|
|
* SOME OF WHICH MAY HAVE SERIOUS CONSEQUENCES. CARNEGIE MELLON ALLOWS
|
|
|
|
* FREE USE OF THIS SOFTWARE IN ITS "AS IS" CONDITION. CARNEGIE MELLON
|
|
|
|
* DISCLAIMS ANY LIABILITY OF ANY KIND FOR ANY DAMAGES WHATSOEVER
|
|
|
|
* RESULTING DIRECTLY OR INDIRECTLY FROM THE USE OF THIS SOFTWARE OR OF
|
|
|
|
* ANY DERIVATIVE WORK.
|
2005-02-27 01:58:54 +03:00
|
|
|
*
|
1998-09-08 21:12:46 +04:00
|
|
|
* Carnegie Mellon encourages users of this software to return any
|
|
|
|
* improvements or extensions that they make, and to grant Carnegie
|
|
|
|
* Mellon the rights to redistribute these changes without encumbrance.
|
2005-02-27 01:58:54 +03:00
|
|
|
*
|
|
|
|
* @(#) coda/coda_venus.c,v 1.1.1.1 1998/08/29 21:26:45 rvb Exp $
|
1998-09-08 21:12:46 +04:00
|
|
|
*/
|
1998-08-30 01:26:45 +04:00
|
|
|
|
2001-11-13 02:08:56 +03:00
|
|
|
#include <sys/cdefs.h>
|
2007-03-04 08:59:00 +03:00
|
|
|
__KERNEL_RCSID(0, "$NetBSD: coda_venus.c,v 1.25 2007/03/04 06:01:12 christos Exp $");
|
2001-11-13 02:08:56 +03:00
|
|
|
|
1998-08-30 01:26:45 +04:00
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/systm.h>
|
|
|
|
#include <sys/malloc.h>
|
|
|
|
#include <sys/proc.h>
|
|
|
|
#include <sys/select.h>
|
|
|
|
#include <sys/ioctl.h>
|
|
|
|
/* for CNV_OFLAGS below */
|
|
|
|
#include <sys/fcntl.h>
|
2006-05-15 01:19:33 +04:00
|
|
|
#include <sys/kauth.h>
|
1998-08-30 01:26:45 +04:00
|
|
|
|
1998-09-15 06:02:55 +04:00
|
|
|
#include <coda/coda.h>
|
|
|
|
#include <coda/cnode.h>
|
|
|
|
#include <coda/coda_venus.h>
|
|
|
|
#include <coda/coda_pioctl.h>
|
1998-08-30 01:26:45 +04:00
|
|
|
|
2003-08-28 09:55:19 +04:00
|
|
|
#ifdef _KERNEL_OPT
|
2003-08-27 21:49:48 +04:00
|
|
|
#include "opt_coda_compat.h"
|
2003-08-28 09:55:19 +04:00
|
|
|
#endif
|
2003-08-27 21:49:48 +04:00
|
|
|
|
2006-03-15 17:30:56 +03:00
|
|
|
/*
|
|
|
|
* Isize and Osize are the sizes of the input and output arguments.
|
|
|
|
* SEMI-INVARIANT: name##_size (e.g. coda_readlink_size) is the max of
|
|
|
|
* the input and output. This invariant is not well maintained, but
|
|
|
|
* should be true after ALLOC_*. Isize is modified after allocation
|
|
|
|
* by STRCPY below - this is in general unsafe and needs fixing.
|
|
|
|
*/
|
|
|
|
|
1998-08-30 01:26:45 +04:00
|
|
|
#define DECL_NO_IN(name) \
|
1998-09-12 19:05:47 +04:00
|
|
|
struct coda_in_hdr *inp; \
|
1998-08-30 01:26:45 +04:00
|
|
|
struct name ## _out *outp; \
|
1998-09-12 19:05:47 +04:00
|
|
|
int name ## _size = sizeof (struct coda_in_hdr); \
|
|
|
|
int Isize = sizeof (struct coda_in_hdr); \
|
1998-08-30 01:26:45 +04:00
|
|
|
int Osize = sizeof (struct name ## _out); \
|
|
|
|
int error
|
|
|
|
|
|
|
|
#define DECL(name) \
|
|
|
|
struct name ## _in *inp; \
|
|
|
|
struct name ## _out *outp; \
|
|
|
|
int name ## _size = sizeof (struct name ## _in); \
|
|
|
|
int Isize = sizeof (struct name ## _in); \
|
|
|
|
int Osize = sizeof (struct name ## _out); \
|
|
|
|
int error
|
|
|
|
|
|
|
|
#define DECL_NO_OUT(name) \
|
|
|
|
struct name ## _in *inp; \
|
1998-09-12 19:05:47 +04:00
|
|
|
struct coda_out_hdr *outp; \
|
1998-08-30 01:26:45 +04:00
|
|
|
int name ## _size = sizeof (struct name ## _in); \
|
|
|
|
int Isize = sizeof (struct name ## _in); \
|
1998-09-12 19:05:47 +04:00
|
|
|
int Osize = sizeof (struct coda_out_hdr); \
|
1998-08-30 01:26:45 +04:00
|
|
|
int error
|
|
|
|
|
|
|
|
#define ALLOC_NO_IN(name) \
|
|
|
|
if (Osize > name ## _size) \
|
|
|
|
name ## _size = Osize; \
|
1998-09-12 19:05:47 +04:00
|
|
|
CODA_ALLOC(inp, struct coda_in_hdr *, name ## _size);\
|
1998-08-30 01:26:45 +04:00
|
|
|
outp = (struct name ## _out *) inp
|
|
|
|
|
|
|
|
#define ALLOC(name) \
|
|
|
|
if (Osize > name ## _size) \
|
|
|
|
name ## _size = Osize; \
|
1998-09-12 19:05:47 +04:00
|
|
|
CODA_ALLOC(inp, struct name ## _in *, name ## _size);\
|
1998-08-30 01:26:45 +04:00
|
|
|
outp = (struct name ## _out *) inp
|
|
|
|
|
|
|
|
#define ALLOC_NO_OUT(name) \
|
|
|
|
if (Osize > name ## _size) \
|
|
|
|
name ## _size = Osize; \
|
1998-09-12 19:05:47 +04:00
|
|
|
CODA_ALLOC(inp, struct name ## _in *, name ## _size);\
|
|
|
|
outp = (struct coda_out_hdr *) inp
|
1998-08-30 01:26:45 +04:00
|
|
|
|
|
|
|
#define STRCPY(struc, name, len) \
|
|
|
|
bcopy(name, (char *)inp + (int)inp->struc, len); \
|
|
|
|
((char*)inp + (int)inp->struc)[len++] = 0; \
|
|
|
|
Isize += len
|
2006-03-15 17:30:56 +03:00
|
|
|
/* XXX verify that Isize has not overrun available storage */
|
1998-08-30 01:26:45 +04:00
|
|
|
|
2003-08-27 21:49:48 +04:00
|
|
|
#ifdef CODA_COMPAT_5
|
|
|
|
|
1998-08-30 01:26:45 +04:00
|
|
|
#define INIT_IN(in, op, ident, p) \
|
|
|
|
(in)->opcode = (op); \
|
|
|
|
(in)->pid = p ? p->p_pid : -1; \
|
|
|
|
(in)->pgid = p ? p->p_pgid : -1; \
|
2003-08-27 21:49:48 +04:00
|
|
|
(in)->sid = (p && p->p_session && p->p_session->s_leader) ? \
|
|
|
|
(p->p_session->s_leader->p_pid) : -1; \
|
2006-03-15 17:30:56 +03:00
|
|
|
KASSERT(cred != NULL); \
|
|
|
|
KASSERT(cred != FSCRED); \
|
1998-08-30 01:26:45 +04:00
|
|
|
if (ident != NOCRED) { \
|
2006-05-15 01:19:33 +04:00
|
|
|
(in)->cred.cr_uid = kauth_cred_geteuid(ident); \
|
|
|
|
(in)->cred.cr_groupid = kauth_cred_getegid(ident); \
|
1998-08-30 01:26:45 +04:00
|
|
|
} else { \
|
2001-07-18 20:12:31 +04:00
|
|
|
memset(&((in)->cred), 0, sizeof(struct coda_cred)); \
|
1998-08-30 01:26:45 +04:00
|
|
|
(in)->cred.cr_uid = -1; \
|
|
|
|
(in)->cred.cr_groupid = -1; \
|
|
|
|
} \
|
|
|
|
|
2003-08-27 21:49:48 +04:00
|
|
|
#else
|
|
|
|
|
|
|
|
#define INIT_IN(in, op, ident, p) \
|
|
|
|
(in)->opcode = (op); \
|
|
|
|
(in)->pid = p ? p->p_pid : -1; \
|
|
|
|
(in)->pgid = p ? p->p_pgid : -1; \
|
2006-03-15 17:30:56 +03:00
|
|
|
KASSERT(cred != NULL); \
|
|
|
|
KASSERT(cred != FSCRED); \
|
2003-08-27 21:49:48 +04:00
|
|
|
if (ident != NOCRED) { \
|
2006-05-15 01:19:33 +04:00
|
|
|
(in)->uid = kauth_cred_geteuid(ident); \
|
2003-08-27 21:49:48 +04:00
|
|
|
} else { \
|
|
|
|
(in)->uid = -1; \
|
|
|
|
} \
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2006-03-15 17:30:56 +03:00
|
|
|
#define INIT_IN_L(in, op, ident, l) \
|
|
|
|
INIT_IN(in, op, ident, (l ? l->l_proc : NULL))
|
|
|
|
|
1998-08-30 01:26:45 +04:00
|
|
|
#define CNV_OFLAG(to, from) \
|
|
|
|
do { \
|
|
|
|
to = 0; \
|
|
|
|
if (from & FREAD) to |= C_O_READ; \
|
|
|
|
if (from & FWRITE) to |= C_O_WRITE; \
|
|
|
|
if (from & O_TRUNC) to |= C_O_TRUNC; \
|
|
|
|
if (from & O_EXCL) to |= C_O_EXCL; \
|
1998-10-28 22:54:47 +03:00
|
|
|
if (from & O_CREAT) to |= C_O_CREAT; \
|
2002-11-02 10:17:31 +03:00
|
|
|
} while (/*CONSTCOND*/ 0)
|
1998-08-30 01:26:45 +04:00
|
|
|
|
|
|
|
#define CNV_VV2V_ATTR(top, fromp) \
|
|
|
|
do { \
|
|
|
|
(top)->va_type = (fromp)->va_type; \
|
|
|
|
(top)->va_mode = (fromp)->va_mode; \
|
|
|
|
(top)->va_nlink = (fromp)->va_nlink; \
|
|
|
|
(top)->va_uid = (fromp)->va_uid; \
|
|
|
|
(top)->va_gid = (fromp)->va_gid; \
|
|
|
|
(top)->va_fsid = VNOVAL; \
|
|
|
|
(top)->va_fileid = (fromp)->va_fileid; \
|
|
|
|
(top)->va_size = (fromp)->va_size; \
|
|
|
|
(top)->va_blocksize = (fromp)->va_blocksize; \
|
|
|
|
(top)->va_atime = (fromp)->va_atime; \
|
|
|
|
(top)->va_mtime = (fromp)->va_mtime; \
|
|
|
|
(top)->va_ctime = (fromp)->va_ctime; \
|
|
|
|
(top)->va_gen = (fromp)->va_gen; \
|
|
|
|
(top)->va_flags = (fromp)->va_flags; \
|
|
|
|
(top)->va_rdev = (fromp)->va_rdev; \
|
|
|
|
(top)->va_bytes = (fromp)->va_bytes; \
|
|
|
|
(top)->va_filerev = (fromp)->va_filerev; \
|
|
|
|
(top)->va_vaflags = VNOVAL; \
|
|
|
|
(top)->va_spare = VNOVAL; \
|
2002-11-02 10:17:31 +03:00
|
|
|
} while (/*CONSTCOND*/ 0)
|
1998-08-30 01:26:45 +04:00
|
|
|
|
|
|
|
#define CNV_V2VV_ATTR(top, fromp) \
|
|
|
|
do { \
|
|
|
|
(top)->va_type = (fromp)->va_type; \
|
|
|
|
(top)->va_mode = (fromp)->va_mode; \
|
|
|
|
(top)->va_nlink = (fromp)->va_nlink; \
|
|
|
|
(top)->va_uid = (fromp)->va_uid; \
|
|
|
|
(top)->va_gid = (fromp)->va_gid; \
|
|
|
|
(top)->va_fileid = (fromp)->va_fileid; \
|
|
|
|
(top)->va_size = (fromp)->va_size; \
|
|
|
|
(top)->va_blocksize = (fromp)->va_blocksize; \
|
|
|
|
(top)->va_atime = (fromp)->va_atime; \
|
|
|
|
(top)->va_mtime = (fromp)->va_mtime; \
|
|
|
|
(top)->va_ctime = (fromp)->va_ctime; \
|
|
|
|
(top)->va_gen = (fromp)->va_gen; \
|
|
|
|
(top)->va_flags = (fromp)->va_flags; \
|
|
|
|
(top)->va_rdev = (fromp)->va_rdev; \
|
|
|
|
(top)->va_bytes = (fromp)->va_bytes; \
|
|
|
|
(top)->va_filerev = (fromp)->va_filerev; \
|
2002-11-02 10:17:31 +03:00
|
|
|
} while (/*CONSTCOND*/ 0)
|
1998-08-30 01:26:45 +04:00
|
|
|
|
|
|
|
|
1998-11-11 22:22:08 +03:00
|
|
|
int coda_kernel_version = CODA_KERNEL_VERSION;
|
|
|
|
|
1998-08-30 01:26:45 +04:00
|
|
|
int
|
|
|
|
venus_root(void *mdp,
|
2006-05-15 01:19:33 +04:00
|
|
|
kauth_cred_t cred, struct proc *p,
|
2003-08-27 21:49:48 +04:00
|
|
|
/*out*/ CodaFid *VFid)
|
1998-08-30 01:26:45 +04:00
|
|
|
{
|
1998-09-12 19:05:47 +04:00
|
|
|
DECL_NO_IN(coda_root); /* sets Isize & Osize */
|
|
|
|
ALLOC_NO_IN(coda_root); /* sets inp & outp */
|
1998-08-30 01:26:45 +04:00
|
|
|
|
|
|
|
/* send the open to venus. */
|
2005-02-27 01:58:54 +03:00
|
|
|
INIT_IN(inp, CODA_ROOT, cred, p);
|
1998-08-30 01:26:45 +04:00
|
|
|
|
1998-09-12 19:05:47 +04:00
|
|
|
error = coda_call(mdp, Isize, &Osize, (char *)inp);
|
1998-08-30 01:26:45 +04:00
|
|
|
if (!error)
|
2003-08-27 21:49:48 +04:00
|
|
|
*VFid = outp->Fid;
|
1998-08-30 01:26:45 +04:00
|
|
|
|
1998-09-12 19:05:47 +04:00
|
|
|
CODA_FREE(inp, coda_root_size);
|
1998-08-30 01:26:45 +04:00
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2003-08-27 21:49:48 +04:00
|
|
|
venus_open(void *mdp, CodaFid *fid, int flag,
|
2006-05-15 01:19:33 +04:00
|
|
|
kauth_cred_t cred, struct lwp *l,
|
1998-08-30 01:26:45 +04:00
|
|
|
/*out*/ dev_t *dev, ino_t *inode)
|
|
|
|
{
|
|
|
|
int cflag;
|
1998-09-12 19:05:47 +04:00
|
|
|
DECL(coda_open); /* sets Isize & Osize */
|
|
|
|
ALLOC(coda_open); /* sets inp & outp */
|
1998-08-30 01:26:45 +04:00
|
|
|
|
|
|
|
/* send the open to venus. */
|
2006-03-15 17:30:56 +03:00
|
|
|
INIT_IN_L(&inp->ih, CODA_OPEN, cred, l);
|
2003-08-27 21:49:48 +04:00
|
|
|
inp->Fid = *fid;
|
1998-08-30 01:26:45 +04:00
|
|
|
CNV_OFLAG(cflag, flag);
|
|
|
|
inp->flags = cflag;
|
|
|
|
|
1998-09-12 19:05:47 +04:00
|
|
|
error = coda_call(mdp, Isize, &Osize, (char *)inp);
|
2006-03-15 17:30:56 +03:00
|
|
|
KASSERT(outp != NULL);
|
1998-08-30 01:26:45 +04:00
|
|
|
if (!error) {
|
|
|
|
*dev = outp->dev;
|
|
|
|
*inode = outp->inode;
|
|
|
|
}
|
|
|
|
|
1998-09-12 19:05:47 +04:00
|
|
|
CODA_FREE(inp, coda_open_size);
|
1998-08-30 01:26:45 +04:00
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2003-08-27 21:49:48 +04:00
|
|
|
venus_close(void *mdp, CodaFid *fid, int flag,
|
2006-05-15 01:19:33 +04:00
|
|
|
kauth_cred_t cred, struct lwp *l)
|
1998-08-30 01:26:45 +04:00
|
|
|
{
|
|
|
|
int cflag;
|
1998-09-12 19:05:47 +04:00
|
|
|
DECL_NO_OUT(coda_close); /* sets Isize & Osize */
|
|
|
|
ALLOC_NO_OUT(coda_close); /* sets inp & outp */
|
1998-08-30 01:26:45 +04:00
|
|
|
|
2006-03-15 17:30:56 +03:00
|
|
|
INIT_IN_L(&inp->ih, CODA_CLOSE, cred, l);
|
2003-08-27 21:49:48 +04:00
|
|
|
inp->Fid = *fid;
|
1998-08-30 01:26:45 +04:00
|
|
|
CNV_OFLAG(cflag, flag);
|
|
|
|
inp->flags = cflag;
|
|
|
|
|
1998-09-12 19:05:47 +04:00
|
|
|
error = coda_call(mdp, Isize, &Osize, (char *)inp);
|
1998-08-30 01:26:45 +04:00
|
|
|
|
1998-09-12 19:05:47 +04:00
|
|
|
CODA_FREE(inp, coda_close_size);
|
1998-08-30 01:26:45 +04:00
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* these two calls will not exist!!! the container file is read/written
|
|
|
|
* directly.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
venus_read(void)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
venus_write(void)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* this is a bit sad too. the ioctl's are for the control file, not for
|
|
|
|
* normal files.
|
|
|
|
*/
|
|
|
|
int
|
2003-08-27 21:49:48 +04:00
|
|
|
venus_ioctl(void *mdp, CodaFid *fid,
|
2007-03-04 08:59:00 +03:00
|
|
|
int com, int flag, void *data,
|
2006-05-15 01:19:33 +04:00
|
|
|
kauth_cred_t cred, struct lwp *l)
|
1998-08-30 01:26:45 +04:00
|
|
|
{
|
1998-09-12 19:05:47 +04:00
|
|
|
DECL(coda_ioctl); /* sets Isize & Osize */
|
1998-08-30 01:26:45 +04:00
|
|
|
struct PioctlData *iap = (struct PioctlData *)data;
|
|
|
|
int tmp;
|
|
|
|
|
1998-09-12 19:05:47 +04:00
|
|
|
coda_ioctl_size = VC_MAXMSGSIZE;
|
|
|
|
ALLOC(coda_ioctl); /* sets inp & outp */
|
1998-08-30 01:26:45 +04:00
|
|
|
|
2006-03-15 17:30:56 +03:00
|
|
|
INIT_IN_L(&inp->ih, CODA_IOCTL, cred, l);
|
2003-08-27 21:49:48 +04:00
|
|
|
inp->Fid = *fid;
|
1998-08-30 01:26:45 +04:00
|
|
|
|
2005-02-27 01:58:54 +03:00
|
|
|
/* command was mutated by increasing its size field to reflect the
|
1998-08-30 01:26:45 +04:00
|
|
|
* path and follow args. we need to subtract that out before sending
|
|
|
|
* the command to venus.
|
|
|
|
*/
|
|
|
|
inp->cmd = (com & ~(IOCPARM_MASK << 16));
|
|
|
|
tmp = ((com >> 16) & IOCPARM_MASK) - sizeof (char *) - sizeof (int);
|
|
|
|
inp->cmd |= (tmp & IOCPARM_MASK) << 16;
|
|
|
|
|
2006-04-12 04:59:56 +04:00
|
|
|
if (iap->vi.in_size < 0 || iap->vi.in_size > VC_MAXMSGSIZE) {
|
|
|
|
CODA_FREE(inp, coda_ioctl_size);
|
2001-08-05 15:22:33 +04:00
|
|
|
return (EINVAL);
|
2006-04-12 04:59:56 +04:00
|
|
|
}
|
2001-08-05 15:22:33 +04:00
|
|
|
|
1998-08-30 01:26:45 +04:00
|
|
|
inp->rwflag = flag;
|
|
|
|
inp->len = iap->vi.in_size;
|
1998-09-12 19:05:47 +04:00
|
|
|
inp->data = (char *)(sizeof (struct coda_ioctl_in));
|
1998-08-30 01:26:45 +04:00
|
|
|
|
2005-02-27 01:58:54 +03:00
|
|
|
error = copyin(iap->vi.in, (char*)inp + (int)(long)inp->data,
|
1998-08-30 01:26:45 +04:00
|
|
|
iap->vi.in_size);
|
|
|
|
if (error) {
|
1998-09-12 19:05:47 +04:00
|
|
|
CODA_FREE(inp, coda_ioctl_size);
|
1998-08-30 01:26:45 +04:00
|
|
|
return(error);
|
|
|
|
}
|
|
|
|
|
|
|
|
Osize = VC_MAXMSGSIZE;
|
1998-09-12 19:05:47 +04:00
|
|
|
error = coda_call(mdp, Isize + iap->vi.in_size, &Osize, (char *)inp);
|
1998-08-30 01:26:45 +04:00
|
|
|
|
|
|
|
/* copy out the out buffer. */
|
|
|
|
if (!error) {
|
|
|
|
if (outp->len > iap->vi.out_size) {
|
|
|
|
error = EINVAL;
|
|
|
|
} else {
|
2005-02-27 01:58:54 +03:00
|
|
|
error = copyout((char *)outp + (int)(long)outp->data,
|
1998-08-30 01:26:45 +04:00
|
|
|
iap->vi.out, iap->vi.out_size);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1998-09-12 19:05:47 +04:00
|
|
|
CODA_FREE(inp, coda_ioctl_size);
|
1998-08-30 01:26:45 +04:00
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2003-08-27 21:49:48 +04:00
|
|
|
venus_getattr(void *mdp, CodaFid *fid,
|
2006-05-15 01:19:33 +04:00
|
|
|
kauth_cred_t cred, struct lwp *l,
|
1998-08-30 01:26:45 +04:00
|
|
|
/*out*/ struct vattr *vap)
|
|
|
|
{
|
1998-09-12 19:05:47 +04:00
|
|
|
DECL(coda_getattr); /* sets Isize & Osize */
|
|
|
|
ALLOC(coda_getattr); /* sets inp & outp */
|
1998-08-30 01:26:45 +04:00
|
|
|
|
|
|
|
/* send the open to venus. */
|
2006-03-15 17:30:56 +03:00
|
|
|
INIT_IN_L(&inp->ih, CODA_GETATTR, cred, l);
|
2003-08-27 21:49:48 +04:00
|
|
|
inp->Fid = *fid;
|
1998-08-30 01:26:45 +04:00
|
|
|
|
1998-09-12 19:05:47 +04:00
|
|
|
error = coda_call(mdp, Isize, &Osize, (char *)inp);
|
1998-08-30 01:26:45 +04:00
|
|
|
if (!error) {
|
|
|
|
CNV_VV2V_ATTR(vap, &outp->attr);
|
|
|
|
}
|
|
|
|
|
1998-09-12 19:05:47 +04:00
|
|
|
CODA_FREE(inp, coda_getattr_size);
|
1998-08-30 01:26:45 +04:00
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2003-08-27 21:49:48 +04:00
|
|
|
venus_setattr(void *mdp, CodaFid *fid, struct vattr *vap,
|
2006-05-15 01:19:33 +04:00
|
|
|
kauth_cred_t cred, struct lwp *l)
|
1998-08-30 01:26:45 +04:00
|
|
|
{
|
1998-09-12 19:05:47 +04:00
|
|
|
DECL_NO_OUT(coda_setattr); /* sets Isize & Osize */
|
|
|
|
ALLOC_NO_OUT(coda_setattr); /* sets inp & outp */
|
1998-08-30 01:26:45 +04:00
|
|
|
|
|
|
|
/* send the open to venus. */
|
2006-03-15 17:30:56 +03:00
|
|
|
INIT_IN_L(&inp->ih, CODA_SETATTR, cred, l);
|
2003-08-27 21:49:48 +04:00
|
|
|
inp->Fid = *fid;
|
1998-08-30 01:26:45 +04:00
|
|
|
CNV_V2VV_ATTR(&inp->attr, vap);
|
|
|
|
|
1998-09-12 19:05:47 +04:00
|
|
|
error = coda_call(mdp, Isize, &Osize, (char *)inp);
|
1998-08-30 01:26:45 +04:00
|
|
|
|
1998-09-12 19:05:47 +04:00
|
|
|
CODA_FREE(inp, coda_setattr_size);
|
1998-08-30 01:26:45 +04:00
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2003-08-27 21:49:48 +04:00
|
|
|
venus_access(void *mdp, CodaFid *fid, int mode,
|
2006-05-15 01:19:33 +04:00
|
|
|
kauth_cred_t cred, struct lwp *l)
|
1998-08-30 01:26:45 +04:00
|
|
|
{
|
1998-09-12 19:05:47 +04:00
|
|
|
DECL_NO_OUT(coda_access); /* sets Isize & Osize */
|
|
|
|
ALLOC_NO_OUT(coda_access); /* sets inp & outp */
|
1998-08-30 01:26:45 +04:00
|
|
|
|
|
|
|
/* send the open to venus. */
|
2006-03-15 17:30:56 +03:00
|
|
|
INIT_IN_L(&inp->ih, CODA_ACCESS, cred, l);
|
2003-08-27 21:49:48 +04:00
|
|
|
inp->Fid = *fid;
|
1998-08-30 01:26:45 +04:00
|
|
|
inp->flags = mode;
|
|
|
|
|
1998-09-12 19:05:47 +04:00
|
|
|
error = coda_call(mdp, Isize, &Osize, (char *)inp);
|
1998-08-30 01:26:45 +04:00
|
|
|
|
1998-09-12 19:05:47 +04:00
|
|
|
CODA_FREE(inp, coda_access_size);
|
1998-08-30 01:26:45 +04:00
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2003-08-27 21:49:48 +04:00
|
|
|
venus_readlink(void *mdp, CodaFid *fid,
|
2006-05-15 01:19:33 +04:00
|
|
|
kauth_cred_t cred, struct lwp *l,
|
1998-08-30 01:26:45 +04:00
|
|
|
/*out*/ char **str, int *len)
|
|
|
|
{
|
1998-09-12 19:05:47 +04:00
|
|
|
DECL(coda_readlink); /* sets Isize & Osize */
|
2006-03-15 17:30:56 +03:00
|
|
|
/* XXX coda_readlink_size should not be set here */
|
1998-09-12 19:05:47 +04:00
|
|
|
coda_readlink_size += CODA_MAXPATHLEN;
|
2006-03-15 17:30:56 +03:00
|
|
|
Osize += CODA_MAXPATHLEN;
|
1998-09-12 19:05:47 +04:00
|
|
|
ALLOC(coda_readlink); /* sets inp & outp */
|
1998-08-30 01:26:45 +04:00
|
|
|
|
|
|
|
/* send the open to venus. */
|
2006-03-15 17:30:56 +03:00
|
|
|
INIT_IN_L(&inp->ih, CODA_READLINK, cred, l);
|
2003-08-27 21:49:48 +04:00
|
|
|
inp->Fid = *fid;
|
1998-08-30 01:26:45 +04:00
|
|
|
|
1998-09-12 19:05:47 +04:00
|
|
|
error = coda_call(mdp, Isize, &Osize, (char *)inp);
|
2006-03-15 17:30:56 +03:00
|
|
|
KASSERT(outp != NULL);
|
2006-04-04 17:11:08 +04:00
|
|
|
if (error != 0)
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
/* Check count for reasonableness */
|
|
|
|
if (outp->count <= 0 || outp->count > CODA_MAXPATHLEN) {
|
|
|
|
printf("venus_readlink: bad count %d\n", outp->count);
|
|
|
|
error = EINVAL;
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Check data pointer for reasonableness. It must point after
|
|
|
|
* itself, and within the allocated region.
|
|
|
|
*/
|
2006-04-05 10:55:26 +04:00
|
|
|
if ((intptr_t) outp->data < sizeof(struct coda_readlink_out) ) {
|
|
|
|
printf("venus_readlink: data pointer %lld too low\n",
|
|
|
|
(long long)((intptr_t) outp->data));
|
2006-04-04 17:11:08 +04:00
|
|
|
error = EINVAL;
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
2006-04-05 10:55:26 +04:00
|
|
|
if ((intptr_t) outp->data + outp->count >
|
2006-04-04 17:11:08 +04:00
|
|
|
sizeof(struct coda_readlink_out) + CODA_MAXPATHLEN) {
|
2006-04-05 10:55:26 +04:00
|
|
|
printf("venus_readlink: data pointer %lld too high\n",
|
|
|
|
(long long)((intptr_t) outp->data));
|
2006-04-04 17:11:08 +04:00
|
|
|
error = EINVAL;
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
1998-08-30 01:26:45 +04:00
|
|
|
if (!error) {
|
1998-09-12 19:05:47 +04:00
|
|
|
CODA_ALLOC(*str, char *, outp->count);
|
1998-08-30 01:26:45 +04:00
|
|
|
*len = outp->count;
|
1998-11-18 06:09:20 +03:00
|
|
|
bcopy((char *)outp + (int)(long)outp->data, *str, *len);
|
1998-08-30 01:26:45 +04:00
|
|
|
}
|
|
|
|
|
2006-04-04 17:11:08 +04:00
|
|
|
out:
|
1998-09-12 19:05:47 +04:00
|
|
|
CODA_FREE(inp, coda_readlink_size);
|
1998-08-30 01:26:45 +04:00
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2003-08-27 21:49:48 +04:00
|
|
|
venus_fsync(void *mdp, CodaFid *fid,
|
2006-05-15 01:19:33 +04:00
|
|
|
kauth_cred_t cred, struct lwp *l)
|
1998-08-30 01:26:45 +04:00
|
|
|
{
|
1998-09-12 19:05:47 +04:00
|
|
|
DECL_NO_OUT(coda_fsync); /* sets Isize & Osize */
|
|
|
|
ALLOC_NO_OUT(coda_fsync); /* sets inp & outp */
|
1998-08-30 01:26:45 +04:00
|
|
|
|
|
|
|
/* send the open to venus. */
|
2006-03-15 17:30:56 +03:00
|
|
|
INIT_IN_L(&inp->ih, CODA_FSYNC, cred, l);
|
2003-08-27 21:49:48 +04:00
|
|
|
inp->Fid = *fid;
|
1998-08-30 01:26:45 +04:00
|
|
|
|
1998-09-12 19:05:47 +04:00
|
|
|
error = coda_call(mdp, Isize, &Osize, (char *)inp);
|
1998-08-30 01:26:45 +04:00
|
|
|
|
1998-09-12 19:05:47 +04:00
|
|
|
CODA_FREE(inp, coda_fsync_size);
|
1998-08-30 01:26:45 +04:00
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2003-08-27 21:49:48 +04:00
|
|
|
venus_lookup(void *mdp, CodaFid *fid,
|
1998-08-30 01:26:45 +04:00
|
|
|
const char *nm, int len,
|
2006-05-15 01:19:33 +04:00
|
|
|
kauth_cred_t cred, struct lwp *l,
|
2003-08-27 21:49:48 +04:00
|
|
|
/*out*/ CodaFid *VFid, int *vtype)
|
1998-08-30 01:26:45 +04:00
|
|
|
{
|
1998-09-12 19:05:47 +04:00
|
|
|
DECL(coda_lookup); /* sets Isize & Osize */
|
|
|
|
coda_lookup_size += len + 1;
|
|
|
|
ALLOC(coda_lookup); /* sets inp & outp */
|
1998-08-30 01:26:45 +04:00
|
|
|
|
|
|
|
/* send the open to venus. */
|
2006-03-15 17:30:56 +03:00
|
|
|
INIT_IN_L(&inp->ih, CODA_LOOKUP, cred, l);
|
2003-08-27 21:49:48 +04:00
|
|
|
inp->Fid = *fid;
|
1998-08-30 01:26:45 +04:00
|
|
|
|
1998-11-11 22:22:08 +03:00
|
|
|
/* NOTE:
|
|
|
|
* Between version 1 and version 2 we have added an extra flag field
|
|
|
|
* to this structure. But because the string was at the end and because
|
2001-08-20 16:20:01 +04:00
|
|
|
* of the weird way we represent strings by having the slot point to
|
1998-11-11 22:22:08 +03:00
|
|
|
* where the string characters are in the "heap", we can just slip the
|
|
|
|
* flag parameter in after the string slot pointer and veni that don't
|
|
|
|
* know better won't see this new flag field ...
|
|
|
|
* Otherwise we'd need two different venus_lookup functions.
|
|
|
|
*/
|
1998-08-30 01:26:45 +04:00
|
|
|
inp->name = Isize;
|
1998-11-11 22:22:08 +03:00
|
|
|
inp->flags = CLU_CASE_SENSITIVE; /* doesn't really matter for BSD */
|
2006-03-15 17:30:56 +03:00
|
|
|
/* This is safe because we preallocated len+1 extra. */
|
1998-08-30 01:26:45 +04:00
|
|
|
STRCPY(name, nm, len); /* increments Isize */
|
|
|
|
|
1998-09-12 19:05:47 +04:00
|
|
|
error = coda_call(mdp, Isize, &Osize, (char *)inp);
|
2006-03-15 17:30:56 +03:00
|
|
|
KASSERT(outp != NULL);
|
1998-08-30 01:26:45 +04:00
|
|
|
if (!error) {
|
2003-08-27 21:49:48 +04:00
|
|
|
*VFid = outp->Fid;
|
1998-08-30 01:26:45 +04:00
|
|
|
*vtype = outp->vtype;
|
|
|
|
}
|
|
|
|
|
1998-09-12 19:05:47 +04:00
|
|
|
CODA_FREE(inp, coda_lookup_size);
|
1998-08-30 01:26:45 +04:00
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2003-08-27 21:49:48 +04:00
|
|
|
venus_create(void *mdp, CodaFid *fid,
|
1998-08-30 01:26:45 +04:00
|
|
|
const char *nm, int len, int exclusive, int mode, struct vattr *va,
|
2006-05-15 01:19:33 +04:00
|
|
|
kauth_cred_t cred, struct lwp *l,
|
2003-08-27 21:49:48 +04:00
|
|
|
/*out*/ CodaFid *VFid, struct vattr *attr)
|
1998-08-30 01:26:45 +04:00
|
|
|
{
|
1998-09-12 19:05:47 +04:00
|
|
|
DECL(coda_create); /* sets Isize & Osize */
|
|
|
|
coda_create_size += len + 1;
|
|
|
|
ALLOC(coda_create); /* sets inp & outp */
|
1998-08-30 01:26:45 +04:00
|
|
|
|
|
|
|
/* send the open to venus. */
|
2006-03-15 17:30:56 +03:00
|
|
|
INIT_IN_L(&inp->ih, CODA_CREATE, cred, l);
|
2003-08-27 21:49:48 +04:00
|
|
|
inp->Fid = *fid;
|
1998-08-30 01:26:45 +04:00
|
|
|
inp->excl = exclusive ? C_O_EXCL : 0;
|
|
|
|
inp->mode = mode<<6;
|
|
|
|
CNV_V2VV_ATTR(&inp->attr, va);
|
|
|
|
|
|
|
|
inp->name = Isize;
|
|
|
|
STRCPY(name, nm, len); /* increments Isize */
|
|
|
|
|
1998-09-12 19:05:47 +04:00
|
|
|
error = coda_call(mdp, Isize, &Osize, (char *)inp);
|
2006-03-15 17:30:56 +03:00
|
|
|
KASSERT(outp != NULL);
|
1998-08-30 01:26:45 +04:00
|
|
|
if (!error) {
|
2003-08-27 21:49:48 +04:00
|
|
|
*VFid = outp->Fid;
|
1998-08-30 01:26:45 +04:00
|
|
|
CNV_VV2V_ATTR(attr, &outp->attr);
|
|
|
|
}
|
|
|
|
|
1998-09-12 19:05:47 +04:00
|
|
|
CODA_FREE(inp, coda_create_size);
|
1998-08-30 01:26:45 +04:00
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2003-08-27 21:49:48 +04:00
|
|
|
venus_remove(void *mdp, CodaFid *fid,
|
1998-08-30 01:26:45 +04:00
|
|
|
const char *nm, int len,
|
2006-05-15 01:19:33 +04:00
|
|
|
kauth_cred_t cred, struct lwp *l)
|
1998-08-30 01:26:45 +04:00
|
|
|
{
|
1998-09-12 19:05:47 +04:00
|
|
|
DECL_NO_OUT(coda_remove); /* sets Isize & Osize */
|
|
|
|
coda_remove_size += len + 1;
|
|
|
|
ALLOC_NO_OUT(coda_remove); /* sets inp & outp */
|
1998-08-30 01:26:45 +04:00
|
|
|
|
|
|
|
/* send the open to venus. */
|
2006-03-15 17:30:56 +03:00
|
|
|
INIT_IN_L(&inp->ih, CODA_REMOVE, cred, l);
|
2003-08-27 21:49:48 +04:00
|
|
|
inp->Fid = *fid;
|
1998-08-30 01:26:45 +04:00
|
|
|
|
|
|
|
inp->name = Isize;
|
|
|
|
STRCPY(name, nm, len); /* increments Isize */
|
|
|
|
|
1998-09-12 19:05:47 +04:00
|
|
|
error = coda_call(mdp, Isize, &Osize, (char *)inp);
|
1998-08-30 01:26:45 +04:00
|
|
|
|
1998-09-12 19:05:47 +04:00
|
|
|
CODA_FREE(inp, coda_remove_size);
|
1998-08-30 01:26:45 +04:00
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2003-08-27 21:49:48 +04:00
|
|
|
venus_link(void *mdp, CodaFid *fid, CodaFid *tfid,
|
1998-08-30 01:26:45 +04:00
|
|
|
const char *nm, int len,
|
2006-05-15 01:19:33 +04:00
|
|
|
kauth_cred_t cred, struct lwp *l)
|
1998-08-30 01:26:45 +04:00
|
|
|
{
|
1998-09-12 19:05:47 +04:00
|
|
|
DECL_NO_OUT(coda_link); /* sets Isize & Osize */
|
|
|
|
coda_link_size += len + 1;
|
|
|
|
ALLOC_NO_OUT(coda_link); /* sets inp & outp */
|
1998-08-30 01:26:45 +04:00
|
|
|
|
|
|
|
/* send the open to venus. */
|
2006-03-15 17:30:56 +03:00
|
|
|
INIT_IN_L(&inp->ih, CODA_LINK, cred, l);
|
1998-08-30 01:26:45 +04:00
|
|
|
inp->sourceFid = *fid;
|
|
|
|
inp->destFid = *tfid;
|
|
|
|
|
|
|
|
inp->tname = Isize;
|
|
|
|
STRCPY(tname, nm, len); /* increments Isize */
|
|
|
|
|
1998-09-12 19:05:47 +04:00
|
|
|
error = coda_call(mdp, Isize, &Osize, (char *)inp);
|
1998-08-30 01:26:45 +04:00
|
|
|
|
1998-09-12 19:05:47 +04:00
|
|
|
CODA_FREE(inp, coda_link_size);
|
1998-08-30 01:26:45 +04:00
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2003-08-27 21:49:48 +04:00
|
|
|
venus_rename(void *mdp, CodaFid *fid, CodaFid *tfid,
|
1998-08-30 01:26:45 +04:00
|
|
|
const char *nm, int len, const char *tnm, int tlen,
|
2006-05-15 01:19:33 +04:00
|
|
|
kauth_cred_t cred, struct lwp *l)
|
1998-08-30 01:26:45 +04:00
|
|
|
{
|
1998-09-12 19:05:47 +04:00
|
|
|
DECL_NO_OUT(coda_rename); /* sets Isize & Osize */
|
|
|
|
coda_rename_size += len + 1 + tlen + 1;
|
|
|
|
ALLOC_NO_OUT(coda_rename); /* sets inp & outp */
|
1998-08-30 01:26:45 +04:00
|
|
|
|
|
|
|
/* send the open to venus. */
|
2006-03-15 17:30:56 +03:00
|
|
|
INIT_IN_L(&inp->ih, CODA_RENAME, cred, l);
|
1998-08-30 01:26:45 +04:00
|
|
|
inp->sourceFid = *fid;
|
|
|
|
inp->destFid = *tfid;
|
|
|
|
|
|
|
|
inp->srcname = Isize;
|
|
|
|
STRCPY(srcname, nm, len); /* increments Isize */
|
|
|
|
|
|
|
|
inp->destname = Isize;
|
|
|
|
STRCPY(destname, tnm, tlen); /* increments Isize */
|
|
|
|
|
1998-09-12 19:05:47 +04:00
|
|
|
error = coda_call(mdp, Isize, &Osize, (char *)inp);
|
1998-08-30 01:26:45 +04:00
|
|
|
|
1998-09-12 19:05:47 +04:00
|
|
|
CODA_FREE(inp, coda_rename_size);
|
1998-08-30 01:26:45 +04:00
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2003-08-27 21:49:48 +04:00
|
|
|
venus_mkdir(void *mdp, CodaFid *fid,
|
1998-08-30 01:26:45 +04:00
|
|
|
const char *nm, int len, struct vattr *va,
|
2006-05-15 01:19:33 +04:00
|
|
|
kauth_cred_t cred, struct lwp *l,
|
2003-08-27 21:49:48 +04:00
|
|
|
/*out*/ CodaFid *VFid, struct vattr *ova)
|
1998-08-30 01:26:45 +04:00
|
|
|
{
|
1998-09-12 19:05:47 +04:00
|
|
|
DECL(coda_mkdir); /* sets Isize & Osize */
|
|
|
|
coda_mkdir_size += len + 1;
|
|
|
|
ALLOC(coda_mkdir); /* sets inp & outp */
|
1998-08-30 01:26:45 +04:00
|
|
|
|
|
|
|
/* send the open to venus. */
|
2006-03-15 17:30:56 +03:00
|
|
|
INIT_IN_L(&inp->ih, CODA_MKDIR, cred, l);
|
2003-08-27 21:49:48 +04:00
|
|
|
inp->Fid = *fid;
|
1998-08-30 01:26:45 +04:00
|
|
|
CNV_V2VV_ATTR(&inp->attr, va);
|
|
|
|
|
|
|
|
inp->name = Isize;
|
|
|
|
STRCPY(name, nm, len); /* increments Isize */
|
|
|
|
|
1998-09-12 19:05:47 +04:00
|
|
|
error = coda_call(mdp, Isize, &Osize, (char *)inp);
|
2006-03-15 17:30:56 +03:00
|
|
|
KASSERT(outp != NULL);
|
1998-08-30 01:26:45 +04:00
|
|
|
if (!error) {
|
2003-08-27 21:49:48 +04:00
|
|
|
*VFid = outp->Fid;
|
1998-08-30 01:26:45 +04:00
|
|
|
CNV_VV2V_ATTR(ova, &outp->attr);
|
|
|
|
}
|
|
|
|
|
1998-09-12 19:05:47 +04:00
|
|
|
CODA_FREE(inp, coda_mkdir_size);
|
1998-08-30 01:26:45 +04:00
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2003-08-27 21:49:48 +04:00
|
|
|
venus_rmdir(void *mdp, CodaFid *fid,
|
1998-08-30 01:26:45 +04:00
|
|
|
const char *nm, int len,
|
2006-05-15 01:19:33 +04:00
|
|
|
kauth_cred_t cred, struct lwp *l)
|
1998-08-30 01:26:45 +04:00
|
|
|
{
|
1998-09-12 19:05:47 +04:00
|
|
|
DECL_NO_OUT(coda_rmdir); /* sets Isize & Osize */
|
|
|
|
coda_rmdir_size += len + 1;
|
|
|
|
ALLOC_NO_OUT(coda_rmdir); /* sets inp & outp */
|
1998-08-30 01:26:45 +04:00
|
|
|
|
|
|
|
/* send the open to venus. */
|
2006-03-15 17:30:56 +03:00
|
|
|
INIT_IN_L(&inp->ih, CODA_RMDIR, cred, l);
|
2003-08-27 21:49:48 +04:00
|
|
|
inp->Fid = *fid;
|
1998-08-30 01:26:45 +04:00
|
|
|
|
|
|
|
inp->name = Isize;
|
|
|
|
STRCPY(name, nm, len); /* increments Isize */
|
|
|
|
|
1998-09-12 19:05:47 +04:00
|
|
|
error = coda_call(mdp, Isize, &Osize, (char *)inp);
|
1998-08-30 01:26:45 +04:00
|
|
|
|
1998-09-12 19:05:47 +04:00
|
|
|
CODA_FREE(inp, coda_rmdir_size);
|
1998-08-30 01:26:45 +04:00
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2003-08-27 21:49:48 +04:00
|
|
|
venus_symlink(void *mdp, CodaFid *fid,
|
1998-08-30 01:26:45 +04:00
|
|
|
const char *lnm, int llen, const char *nm, int len, struct vattr *va,
|
2006-05-15 01:19:33 +04:00
|
|
|
kauth_cred_t cred, struct lwp *l)
|
1998-08-30 01:26:45 +04:00
|
|
|
{
|
1998-09-12 19:05:47 +04:00
|
|
|
DECL_NO_OUT(coda_symlink); /* sets Isize & Osize */
|
|
|
|
coda_symlink_size += llen + 1 + len + 1;
|
|
|
|
ALLOC_NO_OUT(coda_symlink); /* sets inp & outp */
|
1998-08-30 01:26:45 +04:00
|
|
|
|
|
|
|
/* send the open to venus. */
|
2006-03-15 17:30:56 +03:00
|
|
|
INIT_IN_L(&inp->ih, CODA_SYMLINK, cred, l);
|
2003-08-27 21:49:48 +04:00
|
|
|
inp->Fid = *fid;
|
1998-08-30 01:26:45 +04:00
|
|
|
CNV_V2VV_ATTR(&inp->attr, va);
|
|
|
|
|
|
|
|
inp->srcname = Isize;
|
|
|
|
STRCPY(srcname, lnm, llen); /* increments Isize */
|
|
|
|
|
|
|
|
inp->tname = Isize;
|
|
|
|
STRCPY(tname, nm, len); /* increments Isize */
|
|
|
|
|
1998-09-12 19:05:47 +04:00
|
|
|
error = coda_call(mdp, Isize, &Osize, (char *)inp);
|
1998-08-30 01:26:45 +04:00
|
|
|
|
1998-09-12 19:05:47 +04:00
|
|
|
CODA_FREE(inp, coda_symlink_size);
|
1998-08-30 01:26:45 +04:00
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2003-08-27 21:49:48 +04:00
|
|
|
venus_readdir(void *mdp, CodaFid *fid,
|
1998-08-30 01:26:45 +04:00
|
|
|
int count, int offset,
|
2006-05-15 01:19:33 +04:00
|
|
|
kauth_cred_t cred, struct lwp *l,
|
1998-08-30 01:26:45 +04:00
|
|
|
/*out*/ char *buffer, int *len)
|
|
|
|
{
|
1998-09-12 19:05:47 +04:00
|
|
|
DECL(coda_readdir); /* sets Isize & Osize */
|
|
|
|
coda_readdir_size = VC_MAXMSGSIZE;
|
|
|
|
ALLOC(coda_readdir); /* sets inp & outp */
|
1998-08-30 01:26:45 +04:00
|
|
|
|
|
|
|
/* send the open to venus. */
|
2006-03-15 17:30:56 +03:00
|
|
|
INIT_IN_L(&inp->ih, CODA_READDIR, cred, l);
|
2003-08-27 21:49:48 +04:00
|
|
|
inp->Fid = *fid;
|
1998-08-30 01:26:45 +04:00
|
|
|
inp->count = count;
|
|
|
|
inp->offset = offset;
|
|
|
|
|
|
|
|
Osize = VC_MAXMSGSIZE;
|
1998-09-12 19:05:47 +04:00
|
|
|
error = coda_call(mdp, Isize, &Osize, (char *)inp);
|
2006-03-15 17:30:56 +03:00
|
|
|
KASSERT(outp != NULL);
|
1998-08-30 01:26:45 +04:00
|
|
|
if (!error) {
|
1998-11-18 06:09:20 +03:00
|
|
|
bcopy((char *)outp + (int)(long)outp->data, buffer, outp->size);
|
1998-08-30 01:26:45 +04:00
|
|
|
*len = outp->size;
|
|
|
|
}
|
|
|
|
|
1998-09-12 19:05:47 +04:00
|
|
|
CODA_FREE(inp, coda_readdir_size);
|
1998-08-30 01:26:45 +04:00
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
2002-03-27 08:10:40 +03:00
|
|
|
int
|
2006-05-15 01:19:33 +04:00
|
|
|
venus_statfs(void *mdp, kauth_cred_t cred, struct lwp *l,
|
2002-03-27 08:10:40 +03:00
|
|
|
/*out*/ struct coda_statfs *fsp)
|
|
|
|
{
|
|
|
|
DECL(coda_statfs); /* sets Isize & Osize */
|
|
|
|
ALLOC(coda_statfs); /* sets inp & outp */
|
|
|
|
|
|
|
|
/* send the open to venus. */
|
2006-03-15 17:30:56 +03:00
|
|
|
INIT_IN_L(&inp->ih, CODA_STATFS, cred, l);
|
2002-03-27 08:10:40 +03:00
|
|
|
|
|
|
|
error = coda_call(mdp, Isize, &Osize, (char *)inp);
|
2006-03-15 17:30:56 +03:00
|
|
|
KASSERT(outp != NULL);
|
2002-03-27 08:10:40 +03:00
|
|
|
if (!error) {
|
|
|
|
*fsp = outp->stat;
|
|
|
|
}
|
|
|
|
|
|
|
|
CODA_FREE(inp, coda_statfs_size);
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
1998-08-30 01:26:45 +04:00
|
|
|
int
|
2003-08-27 21:49:48 +04:00
|
|
|
venus_fhtovp(void *mdp, CodaFid *fid,
|
2006-05-15 01:19:33 +04:00
|
|
|
kauth_cred_t cred, struct proc *p,
|
2003-08-27 21:49:48 +04:00
|
|
|
/*out*/ CodaFid *VFid, int *vtype)
|
1998-08-30 01:26:45 +04:00
|
|
|
{
|
1998-09-12 19:05:47 +04:00
|
|
|
DECL(coda_vget); /* sets Isize & Osize */
|
|
|
|
ALLOC(coda_vget); /* sets inp & outp */
|
1998-08-30 01:26:45 +04:00
|
|
|
|
|
|
|
/* Send the open to Venus. */
|
2003-06-30 02:28:00 +04:00
|
|
|
INIT_IN(&inp->ih, CODA_VGET, cred, p);
|
2003-08-27 21:49:48 +04:00
|
|
|
inp->Fid = *fid;
|
1998-08-30 01:26:45 +04:00
|
|
|
|
1998-09-12 19:05:47 +04:00
|
|
|
error = coda_call(mdp, Isize, &Osize, (char *)inp);
|
2006-03-15 17:30:56 +03:00
|
|
|
KASSERT(outp != NULL);
|
1998-08-30 01:26:45 +04:00
|
|
|
if (!error) {
|
2003-08-27 21:49:48 +04:00
|
|
|
*VFid = outp->Fid;
|
1998-08-30 01:26:45 +04:00
|
|
|
*vtype = outp->vtype;
|
|
|
|
}
|
|
|
|
|
1998-09-12 19:05:47 +04:00
|
|
|
CODA_FREE(inp, coda_vget_size);
|
1998-08-30 01:26:45 +04:00
|
|
|
return error;
|
|
|
|
}
|