// SPDX-License-Identifier: GPL-2.0 /* * Mostly platform independent upcall operations to Venus: * -- upcalls * -- upcall routines * * Linux 2.0 version * Copyright (C) 1996 Peter J. Braam <braam@maths.ox.ac.uk>, * Michael Callahan <callahan@maths.ox.ac.uk> * * Redone for Linux 2.1 * Copyright (C) 1997 Carnegie Mellon University * * Carnegie Mellon University encourages users of this code to contribute * improvements to the Coda project. Contact Peter Braam <coda@cs.cmu.edu>.
*/
/* the upcalls */ int venus_rootfid(struct super_block *sb, struct CodaFid *fidp)
{ union inputArgs *inp; union outputArgs *outp; int insize, outsize, error;
int venus_lookup(struct super_block *sb, struct CodaFid *fid, constchar *name, int length, int * type, struct CodaFid *resfid)
{ union inputArgs *inp; union outputArgs *outp; int insize, outsize, error; int offset;
int venus_close(struct super_block *sb, struct CodaFid *fid, int flags,
kuid_t uid)
{ union inputArgs *inp; union outputArgs *outp; int insize, outsize, error;
int venus_open(struct super_block *sb, struct CodaFid *fid, int flags, struct file **fh)
{ union inputArgs *inp; union outputArgs *outp; int insize, outsize, error;
int venus_mkdir(struct super_block *sb, struct CodaFid *dirfid, constchar *name, int length, struct CodaFid *newfid, struct coda_vattr *attrs)
{ union inputArgs *inp; union outputArgs *outp; int insize, outsize, error; int offset;
int venus_create(struct super_block *sb, struct CodaFid *dirfid, constchar *name, int length, int excl, int mode, struct CodaFid *newfid, struct coda_vattr *attrs)
{ union inputArgs *inp; union outputArgs *outp; int insize, outsize, error; int offset;
int venus_rmdir(struct super_block *sb, struct CodaFid *dirfid, constchar *name, int length)
{ union inputArgs *inp; union outputArgs *outp; int insize, outsize, error; int offset;
int venus_remove(struct super_block *sb, struct CodaFid *dirfid, constchar *name, int length)
{ union inputArgs *inp; union outputArgs *outp; int error=0, insize, outsize, offset;
int venus_readlink(struct super_block *sb, struct CodaFid *fid, char *buffer, int *length)
{ union inputArgs *inp; union outputArgs *outp; int insize, outsize, error; int retlen; char *result;
int venus_link(struct super_block *sb, struct CodaFid *fid, struct CodaFid *dirfid, constchar *name, int len )
{ union inputArgs *inp; union outputArgs *outp; int insize, outsize, error; int offset;
int venus_symlink(struct super_block *sb, struct CodaFid *fid, constchar *name, int len, constchar *symname, int symlen)
{ union inputArgs *inp; union outputArgs *outp; int insize, outsize, error; int offset, s;
int venus_pioctl(struct super_block *sb, struct CodaFid *fid, unsignedint cmd, struct PioctlData *data)
{ union inputArgs *inp; union outputArgs *outp; int insize, outsize, error; int iocsize;
insize = VC_MAXMSGSIZE;
UPARG(CODA_IOCTL);
/* build packet for Venus */ if (data->vi.in_size > VC_MAXDATASIZE) {
error = -EINVAL; gotoexit;
}
if (data->vi.out_size > VC_MAXDATASIZE) {
error = -EINVAL; gotoexit;
}
inp->coda_ioctl.VFid = *fid;
/* the cmd field was mutated by increasing its size field to * reflect the path and follow args. We need to subtract that
* out before sending the command to Venus. */
inp->coda_ioctl.cmd = (cmd & ~(PIOCPARM_MASK << 16));
iocsize = ((cmd >> 16) & PIOCPARM_MASK) - sizeof(char *) - sizeof(int);
inp->coda_ioctl.cmd |= (iocsize & PIOCPARM_MASK) << 16;
/* get the data out of user space */ if (copy_from_user((char *)inp + (long)inp->coda_ioctl.data,
data->vi.in, data->vi.in_size)) {
error = -EINVAL; gotoexit;
}
/* Copy out the OUT buffer. */ if (outp->coda_ioctl.len > data->vi.out_size) {
error = -EINVAL; gotoexit;
}
/* Copy out the OUT buffer. */ if (copy_to_user(data->vi.out,
(char *)outp + (long)outp->coda_ioctl.data,
outp->coda_ioctl.len)) {
error = -EFAULT; gotoexit;
}
exit:
kvfree(inp); return error;
}
int venus_statfs(struct dentry *dentry, struct kstatfs *sfs)
{ union inputArgs *inp; union outputArgs *outp; int insize, outsize, error;
/* * we have to free the request buffer for synchronous upcalls * or when asynchronous upcalls fail, but not when asynchronous * upcalls succeed
*/ if (!finalizer || error)
kvfree(inp);
/* Chunked access is not supported or an old Coda client */ if (error == -EOPNOTSUPP) {
*access_intent_supported = false;
error = 0;
} return error;
}
add_wait_queue(&req->uc_sleep, &wait); for (;;) { if (CODA_INTERRUPTIBLE(req))
set_current_state(TASK_INTERRUPTIBLE); else
set_current_state(TASK_UNINTERRUPTIBLE);
/* got a reply */ if (req->uc_flags & (CODA_REQ_WRITE | CODA_REQ_ABORT)) break;
/* * coda_upcall will return an error in the case of * failed communication with Venus _or_ will peek at Venus * reply and return Venus' error. * * As venus has 2 types of errors, normal errors (positive) and internal * errors (negative), normal errors are negated, while internal errors * are all mapped to -EINTR, while showing a nice warning message. (jh)
*/ staticint coda_upcall(struct venus_comm *vcp, int inSize, int *outSize, union inputArgs *buffer)
{ union outputArgs *out; union inputArgs *sig_inputArgs; struct upc_req *req = NULL, *sig_req; int error;
mutex_lock(&vcp->vc_mutex);
if (!vcp->vc_inuse) {
pr_notice("Venus dead, not sending upcall\n");
error = -ENXIO; gotoexit;
}
/* Format the request message. */
req = kmalloc(sizeof(struct upc_req), GFP_KERNEL); if (!req) {
error = -ENOMEM; gotoexit;
}
/* Append msg to pending queue and poke Venus. */
list_add_tail(&req->uc_chain, &vcp->vc_pending);
wake_up_interruptible(&vcp->vc_waitq);
/* We can return early on asynchronous requests */ if (outSize == NULL) {
mutex_unlock(&vcp->vc_mutex); return 0;
}
/* We can be interrupted while we wait for Venus to process * our request. If the interrupt occurs before Venus has read * the request, we dequeue and return. If it occurs after the * read but before the reply, we dequeue, send a signal * message, and return. If it occurs after the reply we ignore * it. In no case do we want to restart the syscall. If it * was interrupted by a venus shutdown (psdev_close), return
* ENODEV. */
/* Go to sleep. Wake up on signals only after the timeout. */
coda_waitfor_upcall(vcp, req);
/* Op went through, interrupt or not... */ if (req->uc_flags & CODA_REQ_WRITE) {
out = (union outputArgs *)req->uc_data; /* here we map positive Venus errors to kernel errors */
error = -out->oh.result;
*outSize = req->uc_outSize; gotoexit;
}
/* The statements below are part of the Coda opportunistic programming -- taken from the Mach/BSD kernel code for Coda. You don't get correct semantics by stating what needs to be done without guaranteeing the invariants needed for it to happen. When will be have time to find out what exactly is going on? (pjb)
*/
/* * There are 7 cases where cache invalidations occur. The semantics * of each is listed here: * * CODA_FLUSH -- flush all entries from the name cache and the cnode cache. * CODA_PURGEUSER -- flush all entries from the name cache for a specific user * This call is a result of token expiration. * * The next arise as the result of callbacks on a file or directory. * CODA_ZAPFILE -- flush the cached attributes for a file.
* CODA_ZAPDIR -- flush the attributes for the dir and * force a new lookup for all the children of this dir.
* * The next is a result of Venus detecting an inconsistent file. * CODA_PURGEFID -- flush the attribute for the file * purge it and its children from the dcache * * The last allows Venus to replace local fids with global ones * during reintegration. *
* CODA_REPLACE -- replace one CodaFid with another throughout the name cache */
int coda_downcall(struct venus_comm *vcp, int opcode, union outputArgs *out,
size_t nbytes)
{ struct inode *inode = NULL; struct CodaFid *fid = NULL, *newfid; struct super_block *sb;
/* * Make sure we have received enough data from the cache * manager to populate the necessary fields in the buffer
*/ switch (opcode) { case CODA_PURGEUSER: if (nbytes < sizeof(struct coda_purgeuser_out)) return -EINVAL; break;
case CODA_ZAPDIR: if (nbytes < sizeof(struct coda_zapdir_out)) return -EINVAL; break;
case CODA_ZAPFILE: if (nbytes < sizeof(struct coda_zapfile_out)) return -EINVAL; break;
case CODA_PURGEFID: if (nbytes < sizeof(struct coda_purgefid_out)) return -EINVAL; break;
case CODA_REPLACE: if (nbytes < sizeof(struct coda_replace_out)) return -EINVAL; break;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.