17 #include <linux/signal.h>
18 #include <linux/sched.h>
19 #include <linux/types.h>
20 #include <linux/kernel.h>
22 #include <linux/time.h>
25 #include <linux/stat.h>
26 #include <linux/errno.h>
27 #include <linux/string.h>
28 #include <linux/slab.h>
30 #include <asm/uaccess.h>
34 #include <linux/coda.h>
35 #include <linux/coda_psdev.h>
41 static int coda_upcall(
struct venus_comm *
vc,
int inSize,
int *outSize,
44 static void *alloc_upcall(
int opcode,
int size)
62 inp = (union inputArgs *)alloc_upcall(op, insize); \
63 if (IS_ERR(inp)) { return PTR_ERR(inp); }\
64 outp = (union outputArgs *)(inp); \
68 #define INSIZE(tag) sizeof(struct coda_ ## tag ## _in)
69 #define OUTSIZE(tag) sizeof(struct coda_ ## tag ## _out)
70 #define SIZE(tag) max_t(unsigned int, INSIZE(tag), OUTSIZE(tag))
78 int insize, outsize,
error;
83 error = coda_upcall(coda_vcp(sb), insize, &outsize, inp);
96 int insize, outsize,
error;
98 insize =
SIZE(getattr);
102 error = coda_upcall(coda_vcp(sb), insize, &outsize, inp);
115 int insize, outsize,
error;
117 insize =
SIZE(setattr);
123 error = coda_upcall(coda_vcp(sb), insize, &outsize, inp);
135 int insize, outsize,
error;
146 memcpy((
char *)(inp) + offset, name, length);
147 *((
char *)inp + offset + length) =
'\0';
149 error = coda_upcall(coda_vcp(sb), insize, &outsize, inp);
164 int insize, outsize,
error;
173 error = coda_upcall(coda_vcp(sb), insize, &outsize, inp);
184 int insize, outsize,
error;
186 insize =
SIZE(open_by_fd);
192 error = coda_upcall(coda_vcp(sb), insize, &outsize, inp);
206 int insize, outsize,
error;
210 insize =
max_t(
unsigned int, offset + length + 1,
OUTSIZE(mkdir));
217 memcpy((
char *)(inp) + offset, name, length);
218 *((
char *)inp + offset + length) =
'\0';
220 error = coda_upcall(coda_vcp(sb), insize, &outsize, inp);
232 struct CodaFid *new_fid,
size_t old_length,
233 size_t new_length,
const char *old_name,
234 const char *new_name)
238 int insize, outsize,
error;
242 insize =
max_t(
unsigned int, offset + new_length + old_length + 8,
251 s = ( old_length & ~0x3) +4;
252 memcpy((
char *)(inp) + offset, old_name, old_length);
253 *((
char *)inp + offset + old_length) =
'\0';
258 s = ( new_length & ~0x3) +4;
259 memcpy((
char *)(inp) + offset, new_name, new_length);
260 *((
char *)inp + offset + new_length) =
'\0';
262 error = coda_upcall(coda_vcp(sb), insize, &outsize, inp);
274 int insize, outsize,
error;
288 memcpy((
char *)(inp) + offset, name, length);
289 *((
char *)inp + offset + length) =
'\0';
291 error = coda_upcall(coda_vcp(sb), insize, &outsize, inp);
306 int insize, outsize,
error;
310 insize =
max_t(
unsigned int, offset + length + 1,
OUTSIZE(rmdir));
315 memcpy((
char *)(inp) + offset, name, length);
316 *((
char *)inp + offset + length) =
'\0';
318 error = coda_upcall(coda_vcp(sb), insize, &outsize, inp);
332 insize =
max_t(
unsigned int, offset + length + 1,
OUTSIZE(
remove));
337 memcpy((
char *)(inp) + offset, name, length);
338 *((
char *)inp + offset + length) =
'\0';
340 error = coda_upcall(coda_vcp(sb), insize, &outsize, inp);
351 int insize, outsize,
error;
355 insize =
max_t(
unsigned int,
361 error = coda_upcall(coda_vcp(sb), insize, &outsize, inp);
364 if ( retlen > *length )
368 memcpy(buffer, result, retlen);
369 *(buffer + retlen) =
'\0';
379 struct CodaFid *dirfid,
const char *
name,
int len )
383 int insize, outsize,
error;
395 memcpy((
char *)(inp) + offset, name, len);
396 *((
char *)inp + offset + len) =
'\0';
398 error = coda_upcall(coda_vcp(sb), insize, &outsize, inp);
405 const char *
name,
int len,
406 const char *symname,
int symlen)
410 int insize, outsize,
error;
414 insize =
max_t(
unsigned int, offset + len + symlen + 8,
OUTSIZE(symlink));
422 s = ( symlen & ~0x3 ) + 4;
423 memcpy((
char *)(inp) + offset, symname, symlen);
424 *((
char *)inp + offset + symlen) =
'\0';
429 s = (len & ~0x3) + 4;
430 memcpy((
char *)(inp) + offset, name, len);
431 *((
char *)inp + offset + len) =
'\0';
433 error = coda_upcall(coda_vcp(sb), insize, &outsize, inp);
443 int insize, outsize,
error;
449 error = coda_upcall(coda_vcp(sb),
sizeof(
union inputArgs),
460 int insize, outsize,
error;
468 error = coda_upcall(coda_vcp(sb), insize, &outsize, inp);
480 int insize, outsize,
error;
503 iocsize = ((cmd >> 16) &
PIOCPARM_MASK) -
sizeof(
char *) -
sizeof(
int);
512 data->
vi.in, data->
vi.in_size) ) {
517 error = coda_upcall(coda_vcp(sb),
SIZE(ioctl) + data->
vi.in_size,
521 printk(
"coda_pioctl: Venus returns: %d for %s\n",
554 int insize, outsize,
error;
559 error = coda_upcall(coda_vcp(dentry->
d_sb), insize, &outsize, inp);
575 static void coda_block_signals(
sigset_t *old)
577 spin_lock_irq(&
current->sighand->siglock);
586 spin_unlock_irq(&
current->sighand->siglock);
589 static void coda_unblock_signals(
sigset_t *old)
591 spin_lock_irq(&
current->sighand->siglock);
594 spin_unlock_irq(&
current->sighand->siglock);
602 #define CODA_INTERRUPTIBLE(r) (!coda_hard && \
603 (((r)->uc_opcode != CODA_CLOSE && \
604 (r)->uc_opcode != CODA_STORE && \
605 (r)->uc_opcode != CODA_RELEASE) || \
606 (r)->uc_flags & CODA_REQ_READ))
608 static inline void coda_waitfor_upcall(
struct venus_comm *vcp,
616 coda_block_signals(&old);
633 coda_unblock_signals(&old);
650 coda_unblock_signals(&old);
666 static int coda_upcall(
struct venus_comm *vcp,
667 int inSize,
int *outSize,
693 req->
uc_outSize = *outSize ? *outSize : inSize;
715 coda_waitfor_upcall(vcp, req);
721 error = -out->
oh.result;
744 if (!sig_req)
goto exit;
747 if (!sig_req->uc_data) {
753 sig_inputArgs = (
union inputArgs *)sig_req->uc_data;
758 sig_req->uc_opcode = sig_inputArgs->
ih.opcode;
759 sig_req->uc_unique = sig_inputArgs->
ih.unique;
764 list_add(&(sig_req->uc_chain), &vcp->
vc_pending);
859 coda_flag_inode(inode,
C_VATTR);
863 coda_flag_inode(inode,
C_VATTR);
870 coda_flag_inode(inode,
C_PURGE);