The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/coda/coda_venus.c

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 /*
    2  * 
    3  *             Coda: an Experimental Distributed File System
    4  *                              Release 3.1
    5  * 
    6  *           Copyright (c) 1987-1998 Carnegie Mellon University
    7  *                          All Rights Reserved
    8  * 
    9  * Permission  to  use, copy, modify and distribute this software and its
   10  * documentation is hereby granted,  provided  that  both  the  copyright
   11  * notice  and  this  permission  notice  appear  in  all  copies  of the
   12  * software, derivative works or  modified  versions,  and  any  portions
   13  * thereof, and that both notices appear in supporting documentation, and
   14  * that credit is given to Carnegie Mellon University  in  all  documents
   15  * and publicity pertaining to direct or indirect use of this code or its
   16  * derivatives.
   17  * 
   18  * CODA IS AN EXPERIMENTAL SOFTWARE SYSTEM AND IS  KNOWN  TO  HAVE  BUGS,
   19  * SOME  OF  WHICH MAY HAVE SERIOUS CONSEQUENCES.  CARNEGIE MELLON ALLOWS
   20  * FREE USE OF THIS SOFTWARE IN ITS "AS IS" CONDITION.   CARNEGIE  MELLON
   21  * DISCLAIMS  ANY  LIABILITY  OF  ANY  KIND  FOR  ANY  DAMAGES WHATSOEVER
   22  * RESULTING DIRECTLY OR INDIRECTLY FROM THE USE OF THIS SOFTWARE  OR  OF
   23  * ANY DERIVATIVE WORK.
   24  * 
   25  * Carnegie  Mellon  encourages  users  of  this  software  to return any
   26  * improvements or extensions that  they  make,  and  to  grant  Carnegie
   27  * Mellon the rights to redistribute these changes without encumbrance.
   28  * 
   29  *      @(#) src/sys/cfs/coda_venus.c,v 1.1.1.1 1998/08/29 21:14:52 rvb Exp $
   30  * $FreeBSD$
   31  * 
   32  */
   33 
   34 #include <sys/param.h>
   35 #include <sys/systm.h>
   36 #include <sys/malloc.h>
   37 #include <sys/proc.h>
   38 #include <sys/select.h>
   39 #include <sys/ioccom.h>
   40 #include <sys/fcntl.h>
   41 
   42 #include <coda/coda.h>
   43 #include <coda/cnode.h>
   44 #include <coda/coda_venus.h>
   45 #include <coda/coda_pioctl.h>
   46 
   47 #define DECL_NO_IN(name)                                \
   48     struct coda_in_hdr *inp;                            \
   49     struct name ## _out *outp;                          \
   50     int name ## _size = sizeof (struct coda_in_hdr);    \
   51     int Isize = sizeof (struct coda_in_hdr);            \
   52     int Osize = sizeof (struct name ## _out);           \
   53     int error
   54 
   55 #define DECL(name)                                      \
   56     struct name ## _in *inp;                            \
   57     struct name ## _out *outp;                          \
   58     int name ## _size = sizeof (struct name ## _in);    \
   59     int Isize = sizeof (struct name ## _in);            \
   60     int Osize = sizeof (struct name ## _out);           \
   61     int error
   62 
   63 #define DECL_NO_OUT(name)                               \
   64     struct name ## _in *inp;                            \
   65     struct coda_out_hdr *outp;                          \
   66     int name ## _size = sizeof (struct name ## _in);    \
   67     int Isize = sizeof (struct name ## _in);            \
   68     int Osize = sizeof (struct coda_out_hdr);           \
   69     int error
   70 
   71 #define ALLOC_NO_IN(name)                               \
   72     if (Osize > name ## _size)                          \
   73         name ## _size = Osize;                          \
   74     CODA_ALLOC(inp, struct coda_in_hdr *, name ## _size);\
   75     outp = (struct name ## _out *) inp
   76 
   77 #define ALLOC(name)                                     \
   78     if (Osize > name ## _size)                          \
   79         name ## _size = Osize;                          \
   80     CODA_ALLOC(inp, struct name ## _in *, name ## _size);\
   81     outp = (struct name ## _out *) inp
   82 
   83 #define ALLOC_NO_OUT(name)                              \
   84     if (Osize > name ## _size)                          \
   85         name ## _size = Osize;                          \
   86     CODA_ALLOC(inp, struct name ## _in *, name ## _size);\
   87     outp = (struct coda_out_hdr *) inp
   88 
   89 #define STRCPY(struc, name, len) \
   90     bcopy(name, (char *)inp + (int)inp->struc, len); \
   91     ((char*)inp + (int)inp->struc)[len++] = 0; \
   92     Isize += len
   93 
   94 #define INIT_IN(in, op, ident, p) \
   95           (in)->opcode = (op); \
   96           (in)->pid = p ? p->p_pid : -1; \
   97           (in)->pgid = p ? p->p_pgid : -1; \
   98           (in)->sid = (p && p->p_session && p->p_session->s_leader) ? (p->p_session->s_leader->p_pid) : -1; \
   99           if (ident != NOCRED) {                              \
  100               (in)->cred.cr_uid = ident->cr_uid;              \
  101               (in)->cred.cr_groupid = ident->cr_gid;          \
  102           } else {                                            \
  103               bzero(&((in)->cred),sizeof(struct coda_cred));  \
  104               (in)->cred.cr_uid = -1;                         \
  105               (in)->cred.cr_groupid = -1;                     \
  106           }                                                   \
  107 
  108 #define CNV_OFLAG(to, from)                             \
  109     do {                                                \
  110           to = 0;                                       \
  111           if (from & FREAD)   to |= C_O_READ;           \
  112           if (from & FWRITE)  to |= C_O_WRITE;          \
  113           if (from & O_TRUNC) to |= C_O_TRUNC;          \
  114           if (from & O_EXCL)  to |= C_O_EXCL;           \
  115           if (from & O_CREAT) to |= C_O_CREAT;          \
  116     } while (0)
  117 
  118 #define CNV_VV2V_ATTR(top, fromp) \
  119         do { \
  120                 (top)->va_type = (fromp)->va_type; \
  121                 (top)->va_mode = (fromp)->va_mode; \
  122                 (top)->va_nlink = (fromp)->va_nlink; \
  123                 (top)->va_uid = (fromp)->va_uid; \
  124                 (top)->va_gid = (fromp)->va_gid; \
  125                 (top)->va_fsid = VNOVAL; \
  126                 (top)->va_fileid = (fromp)->va_fileid; \
  127                 (top)->va_size = (fromp)->va_size; \
  128                 (top)->va_blocksize = (fromp)->va_blocksize; \
  129                 (top)->va_atime = (fromp)->va_atime; \
  130                 (top)->va_mtime = (fromp)->va_mtime; \
  131                 (top)->va_ctime = (fromp)->va_ctime; \
  132                 (top)->va_gen = (fromp)->va_gen; \
  133                 (top)->va_flags = (fromp)->va_flags; \
  134                 (top)->va_rdev = (fromp)->va_rdev; \
  135                 (top)->va_bytes = (fromp)->va_bytes; \
  136                 (top)->va_filerev = (fromp)->va_filerev; \
  137                 (top)->va_vaflags = VNOVAL; \
  138                 (top)->va_spare = VNOVAL; \
  139         } while (0)
  140 
  141 #define CNV_V2VV_ATTR(top, fromp) \
  142         do { \
  143                 (top)->va_type = (fromp)->va_type; \
  144                 (top)->va_mode = (fromp)->va_mode; \
  145                 (top)->va_nlink = (fromp)->va_nlink; \
  146                 (top)->va_uid = (fromp)->va_uid; \
  147                 (top)->va_gid = (fromp)->va_gid; \
  148                 (top)->va_fileid = (fromp)->va_fileid; \
  149                 (top)->va_size = (fromp)->va_size; \
  150                 (top)->va_blocksize = (fromp)->va_blocksize; \
  151                 (top)->va_atime = (fromp)->va_atime; \
  152                 (top)->va_mtime = (fromp)->va_mtime; \
  153                 (top)->va_ctime = (fromp)->va_ctime; \
  154                 (top)->va_gen = (fromp)->va_gen; \
  155                 (top)->va_flags = (fromp)->va_flags; \
  156                 (top)->va_rdev = (fromp)->va_rdev; \
  157                 (top)->va_bytes = (fromp)->va_bytes; \
  158                 (top)->va_filerev = (fromp)->va_filerev; \
  159         } while (0)
  160 
  161 
  162 int coda_kernel_version = CODA_KERNEL_VERSION;
  163 
  164 int
  165 venus_root(void *mdp,
  166         struct ucred *cred, struct proc *p,
  167 /*out*/ ViceFid *VFid)
  168 {
  169     DECL_NO_IN(coda_root);              /* sets Isize & Osize */
  170     ALLOC_NO_IN(coda_root);             /* sets inp & outp */
  171 
  172     /* send the open to venus. */
  173     INIT_IN(inp, CODA_ROOT, cred, p);  
  174 
  175     error = coda_call(mdp, Isize, &Osize, (char *)inp);
  176     if (!error)
  177         *VFid = outp->VFid;
  178 
  179     CODA_FREE(inp, coda_root_size);
  180     return error;
  181 }
  182 
  183 int
  184 venus_open(void *mdp, ViceFid *fid, int flag,
  185         struct ucred *cred, struct proc *p,
  186 /*out*/ dev_t *dev, ino_t *inode)
  187 {
  188     int cflag;
  189     DECL(coda_open);                    /* sets Isize & Osize */
  190     ALLOC(coda_open);                   /* sets inp & outp */
  191 
  192     /* send the open to venus. */
  193     INIT_IN(&inp->ih, CODA_OPEN, cred, p);
  194     inp->VFid = *fid;
  195     CNV_OFLAG(cflag, flag);
  196     inp->flags = cflag;
  197 
  198     error = coda_call(mdp, Isize, &Osize, (char *)inp);
  199     if (!error) {
  200         *dev =  outp->dev;
  201         *inode = outp->inode;
  202     }
  203 
  204     CODA_FREE(inp, coda_open_size);
  205     return error;
  206 }
  207 
  208 int
  209 venus_close(void *mdp, ViceFid *fid, int flag,
  210         struct ucred *cred, struct proc *p)
  211 {
  212     int cflag;
  213     DECL_NO_OUT(coda_close);            /* sets Isize & Osize */
  214     ALLOC_NO_OUT(coda_close);           /* sets inp & outp */
  215 
  216     INIT_IN(&inp->ih, CODA_CLOSE, cred, p);
  217     inp->VFid = *fid;
  218     CNV_OFLAG(cflag, flag);
  219     inp->flags = cflag;
  220 
  221     error = coda_call(mdp, Isize, &Osize, (char *)inp);
  222 
  223     CODA_FREE(inp, coda_close_size);
  224     return error;
  225 }
  226 
  227 /*
  228  * these two calls will not exist!!!  the container file is read/written
  229  * directly.
  230  */
  231 void
  232 venus_read(void)
  233 {
  234 }
  235 
  236 void
  237 venus_write(void)
  238 {
  239 }
  240 
  241 /*
  242  * this is a bit sad too.  the ioctl's are for the control file, not for
  243  * normal files.
  244  */
  245 int
  246 venus_ioctl(void *mdp, ViceFid *fid,
  247         int com, int flag, caddr_t data,
  248         struct ucred *cred, struct proc *p)
  249 {
  250     DECL(coda_ioctl);                   /* sets Isize & Osize */
  251     struct PioctlData *iap = (struct PioctlData *)data;
  252     int tmp;
  253 
  254     coda_ioctl_size = VC_MAXMSGSIZE;
  255     ALLOC(coda_ioctl);                  /* sets inp & outp */
  256 
  257     INIT_IN(&inp->ih, CODA_IOCTL, cred, p);
  258     inp->VFid = *fid;
  259 
  260     /* command was mutated by increasing its size field to reflect the  
  261      * path and follow args. we need to subtract that out before sending
  262      * the command to venus.
  263      */
  264     inp->cmd = (com & ~(IOCPARM_MASK << 16));
  265     tmp = ((com >> 16) & IOCPARM_MASK) - sizeof (char *) - sizeof (int);
  266     inp->cmd |= (tmp & IOCPARM_MASK) << 16;
  267 
  268     inp->rwflag = flag;
  269     inp->len = iap->vi.in_size;
  270     inp->data = (char *)(sizeof (struct coda_ioctl_in));
  271 
  272     error = copyin(iap->vi.in, (char*)inp + (int)inp->data, 
  273                    iap->vi.in_size);
  274     if (error) {
  275         CODA_FREE(inp, coda_ioctl_size);
  276         return(error);
  277     }
  278 
  279     Osize = VC_MAXMSGSIZE;
  280     error = coda_call(mdp, Isize + iap->vi.in_size, &Osize, (char *)inp);
  281 
  282         /* copy out the out buffer. */
  283     if (!error) {
  284         if (outp->len > iap->vi.out_size) {
  285             error = EINVAL;
  286         } else {
  287             error = copyout((char *)outp + (int)outp->data, 
  288                             iap->vi.out, iap->vi.out_size);
  289         }
  290     }
  291 
  292     CODA_FREE(inp, coda_ioctl_size);
  293     return error;
  294 }
  295 
  296 int
  297 venus_getattr(void *mdp, ViceFid *fid,
  298         struct ucred *cred, struct proc *p,
  299 /*out*/ struct vattr *vap)
  300 {
  301     DECL(coda_getattr);                 /* sets Isize & Osize */
  302     ALLOC(coda_getattr);                        /* sets inp & outp */
  303 
  304     /* send the open to venus. */
  305     INIT_IN(&inp->ih, CODA_GETATTR, cred, p);
  306     inp->VFid = *fid;
  307 
  308     error = coda_call(mdp, Isize, &Osize, (char *)inp);
  309     if (!error) {
  310         CNV_VV2V_ATTR(vap, &outp->attr);
  311     }
  312 
  313     CODA_FREE(inp, coda_getattr_size);
  314     return error;
  315 }
  316 
  317 int
  318 venus_setattr(void *mdp, ViceFid *fid, struct vattr *vap,
  319         struct ucred *cred, struct proc *p)
  320 {
  321     DECL_NO_OUT(coda_setattr);          /* sets Isize & Osize */
  322     ALLOC_NO_OUT(coda_setattr);         /* sets inp & outp */
  323 
  324     /* send the open to venus. */
  325     INIT_IN(&inp->ih, CODA_SETATTR, cred, p);
  326     inp->VFid = *fid;
  327     CNV_V2VV_ATTR(&inp->attr, vap);
  328 
  329     error = coda_call(mdp, Isize, &Osize, (char *)inp);
  330 
  331     CODA_FREE(inp, coda_setattr_size);
  332     return error;
  333 }
  334 
  335 int
  336 venus_access(void *mdp, ViceFid *fid, int mode,
  337         struct ucred *cred, struct proc *p)
  338 {
  339     DECL_NO_OUT(coda_access);           /* sets Isize & Osize */
  340     ALLOC_NO_OUT(coda_access);          /* sets inp & outp */
  341 
  342     /* send the open to venus. */
  343     INIT_IN(&inp->ih, CODA_ACCESS, cred, p);
  344     inp->VFid = *fid;
  345     /* NOTE:
  346      * NetBSD and Venus internals use the "data" in the low 3 bits.
  347      * Hence, the conversion.
  348      */
  349     inp->flags = mode>>6;
  350 
  351     error = coda_call(mdp, Isize, &Osize, (char *)inp);
  352 
  353     CODA_FREE(inp, coda_access_size);
  354     return error;
  355 }
  356 
  357 int
  358 venus_readlink(void *mdp, ViceFid *fid,
  359         struct ucred *cred, struct proc *p,
  360 /*out*/ char **str, int *len)
  361 {
  362     DECL(coda_readlink);                        /* sets Isize & Osize */
  363     coda_readlink_size += CODA_MAXPATHLEN;
  364     ALLOC(coda_readlink);               /* sets inp & outp */
  365 
  366     /* send the open to venus. */
  367     INIT_IN(&inp->ih, CODA_READLINK, cred, p);
  368     inp->VFid = *fid;
  369 
  370     Osize += CODA_MAXPATHLEN;
  371     error = coda_call(mdp, Isize, &Osize, (char *)inp);
  372     if (!error) {
  373             CODA_ALLOC(*str, char *, outp->count);
  374             *len = outp->count;
  375             bcopy((char *)outp + (int)outp->data, *str, *len);
  376     }
  377 
  378     CODA_FREE(inp, coda_readlink_size);
  379     return error;
  380 }
  381 
  382 int
  383 venus_fsync(void *mdp, ViceFid *fid,
  384         struct ucred *cred, struct proc *p)
  385 {
  386     DECL_NO_OUT(coda_fsync);            /* sets Isize & Osize */
  387     ALLOC_NO_OUT(coda_fsync);           /* sets inp & outp */
  388 
  389     /* send the open to venus. */
  390     INIT_IN(&inp->ih, CODA_FSYNC, cred, p);
  391     inp->VFid = *fid;
  392 
  393     error = coda_call(mdp, Isize, &Osize, (char *)inp);
  394 
  395     CODA_FREE(inp, coda_fsync_size);
  396     return error;
  397 }
  398 
  399 int
  400 venus_lookup(void *mdp, ViceFid *fid,
  401         const char *nm, int len,
  402         struct ucred *cred, struct proc *p,
  403 /*out*/ ViceFid *VFid, int *vtype)
  404 {
  405     DECL(coda_lookup);                  /* sets Isize & Osize */
  406     coda_lookup_size += len + 1;
  407     ALLOC(coda_lookup);                 /* sets inp & outp */
  408 
  409     /* send the open to venus. */
  410     INIT_IN(&inp->ih, CODA_LOOKUP, cred, p);
  411     inp->VFid = *fid;
  412 
  413     /* NOTE:
  414      * Between version 1 and version 2 we have added an extra flag field
  415      * to this structure.  But because the string was at the end and because
  416      * of the wierd way we represent strings by having the slot point to
  417      * where the string characters are in the "heap", we can just slip the
  418      * flag parameter in after the string slot pointer and veni that don't
  419      * know better won't see this new flag field ...
  420      * Otherwise we'd need two different venus_lookup functions.
  421      */
  422     inp->name = Isize;
  423     inp->flags = CLU_CASE_SENSITIVE;    /* doesn't really matter for BSD */
  424     STRCPY(name, nm, len);              /* increments Isize */
  425 
  426     error = coda_call(mdp, Isize, &Osize, (char *)inp);
  427     if (!error) {
  428         *VFid = outp->VFid;
  429         *vtype = outp->vtype;
  430     }
  431 
  432     CODA_FREE(inp, coda_lookup_size);
  433     return error;
  434 }
  435 
  436 int
  437 venus_create(void *mdp, ViceFid *fid,
  438         const char *nm, int len, int exclusive, int mode, struct vattr *va,
  439         struct ucred *cred, struct proc *p,
  440 /*out*/ ViceFid *VFid, struct vattr *attr)
  441 {
  442     DECL(coda_create);                  /* sets Isize & Osize */
  443     coda_create_size += len + 1;
  444     ALLOC(coda_create);                 /* sets inp & outp */
  445 
  446     /* send the open to venus. */
  447     INIT_IN(&inp->ih, CODA_CREATE, cred, p);
  448     inp->VFid = *fid;
  449     inp->excl = exclusive ? C_O_EXCL : 0;
  450     inp->mode = mode;
  451     CNV_V2VV_ATTR(&inp->attr, va);
  452 
  453     inp->name = Isize;
  454     STRCPY(name, nm, len);              /* increments Isize */
  455 
  456     error = coda_call(mdp, Isize, &Osize, (char *)inp);
  457     if (!error) {
  458         *VFid = outp->VFid;
  459         CNV_VV2V_ATTR(attr, &outp->attr);
  460     }
  461 
  462     CODA_FREE(inp, coda_create_size);
  463     return error;
  464 }
  465 
  466 int
  467 venus_remove(void *mdp, ViceFid *fid,
  468         const char *nm, int len,
  469         struct ucred *cred, struct proc *p)
  470 {
  471     DECL_NO_OUT(coda_remove);           /* sets Isize & Osize */
  472     coda_remove_size += len + 1;
  473     ALLOC_NO_OUT(coda_remove);          /* sets inp & outp */
  474 
  475     /* send the open to venus. */
  476     INIT_IN(&inp->ih, CODA_REMOVE, cred, p);
  477     inp->VFid = *fid;
  478 
  479     inp->name = Isize;
  480     STRCPY(name, nm, len);              /* increments Isize */
  481 
  482     error = coda_call(mdp, Isize, &Osize, (char *)inp);
  483 
  484     CODA_FREE(inp, coda_remove_size);
  485     return error;
  486 }
  487 
  488 int
  489 venus_link(void *mdp, ViceFid *fid, ViceFid *tfid,
  490         const char *nm, int len,
  491         struct ucred *cred, struct proc *p)
  492 {
  493     DECL_NO_OUT(coda_link);             /* sets Isize & Osize */
  494     coda_link_size += len + 1;
  495     ALLOC_NO_OUT(coda_link);            /* sets inp & outp */
  496 
  497     /* send the open to venus. */
  498     INIT_IN(&inp->ih, CODA_LINK, cred, p);
  499     inp->sourceFid = *fid;
  500     inp->destFid = *tfid;
  501 
  502     inp->tname = Isize;
  503     STRCPY(tname, nm, len);             /* increments Isize */
  504 
  505     error = coda_call(mdp, Isize, &Osize, (char *)inp);
  506 
  507     CODA_FREE(inp, coda_link_size);
  508     return error;
  509 }
  510 
  511 int
  512 venus_rename(void *mdp, ViceFid *fid, ViceFid *tfid,
  513         const char *nm, int len, const char *tnm, int tlen,
  514         struct ucred *cred, struct proc *p)
  515 {
  516     DECL_NO_OUT(coda_rename);           /* sets Isize & Osize */
  517     coda_rename_size += len + 1 + tlen + 1;
  518     ALLOC_NO_OUT(coda_rename);          /* sets inp & outp */
  519 
  520     /* send the open to venus. */
  521     INIT_IN(&inp->ih, CODA_RENAME, cred, p);
  522     inp->sourceFid = *fid;
  523     inp->destFid = *tfid;
  524 
  525     inp->srcname = Isize;
  526     STRCPY(srcname, nm, len);           /* increments Isize */
  527 
  528     inp->destname = Isize;
  529     STRCPY(destname, tnm, tlen);        /* increments Isize */
  530 
  531     error = coda_call(mdp, Isize, &Osize, (char *)inp);
  532 
  533     CODA_FREE(inp, coda_rename_size);
  534     return error;
  535 }
  536 
  537 int
  538 venus_mkdir(void *mdp, ViceFid *fid,
  539         const char *nm, int len, struct vattr *va,
  540         struct ucred *cred, struct proc *p,
  541 /*out*/ ViceFid *VFid, struct vattr *ova)
  542 {
  543     DECL(coda_mkdir);                   /* sets Isize & Osize */
  544     coda_mkdir_size += len + 1;
  545     ALLOC(coda_mkdir);                  /* sets inp & outp */
  546 
  547     /* send the open to venus. */
  548     INIT_IN(&inp->ih, CODA_MKDIR, cred, p);
  549     inp->VFid = *fid;
  550     CNV_V2VV_ATTR(&inp->attr, va);
  551 
  552     inp->name = Isize;
  553     STRCPY(name, nm, len);              /* increments Isize */
  554 
  555     error = coda_call(mdp, Isize, &Osize, (char *)inp);
  556     if (!error) {
  557         *VFid = outp->VFid;
  558         CNV_VV2V_ATTR(ova, &outp->attr);
  559     }
  560 
  561     CODA_FREE(inp, coda_mkdir_size);
  562     return error;
  563 }
  564 
  565 int
  566 venus_rmdir(void *mdp, ViceFid *fid,
  567         const char *nm, int len,
  568         struct ucred *cred, struct proc *p)
  569 {
  570     DECL_NO_OUT(coda_rmdir);            /* sets Isize & Osize */
  571     coda_rmdir_size += len + 1;
  572     ALLOC_NO_OUT(coda_rmdir);           /* sets inp & outp */
  573 
  574     /* send the open to venus. */
  575     INIT_IN(&inp->ih, CODA_RMDIR, cred, p);
  576     inp->VFid = *fid;
  577 
  578     inp->name = Isize;
  579     STRCPY(name, nm, len);              /* increments Isize */
  580 
  581     error = coda_call(mdp, Isize, &Osize, (char *)inp);
  582 
  583     CODA_FREE(inp, coda_rmdir_size);
  584     return error;
  585 }
  586 
  587 int
  588 venus_symlink(void *mdp, ViceFid *fid,
  589         const char *lnm, int llen, const char *nm, int len, struct vattr *va,
  590         struct ucred *cred, struct proc *p)
  591 {
  592     DECL_NO_OUT(coda_symlink);          /* sets Isize & Osize */
  593     coda_symlink_size += llen + 1 + len + 1;
  594     ALLOC_NO_OUT(coda_symlink);         /* sets inp & outp */
  595 
  596     /* send the open to venus. */
  597     INIT_IN(&inp->ih, CODA_SYMLINK, cred, p);
  598     inp->VFid = *fid;
  599     CNV_V2VV_ATTR(&inp->attr, va);
  600 
  601     inp->srcname = Isize;
  602     STRCPY(srcname, lnm, llen);         /* increments Isize */
  603 
  604     inp->tname = Isize;
  605     STRCPY(tname, nm, len);             /* increments Isize */
  606 
  607     error = coda_call(mdp, Isize, &Osize, (char *)inp);
  608 
  609     CODA_FREE(inp, coda_symlink_size);
  610     return error;
  611 }
  612 
  613 int
  614 venus_readdir(void *mdp, ViceFid *fid,
  615         int count, int offset,
  616         struct ucred *cred, struct proc *p,
  617 /*out*/ char *buffer, int *len)
  618 {
  619     DECL(coda_readdir);                 /* sets Isize & Osize */
  620     coda_readdir_size = VC_MAXMSGSIZE;
  621     ALLOC(coda_readdir);                        /* sets inp & outp */
  622 
  623     /* send the open to venus. */
  624     INIT_IN(&inp->ih, CODA_READDIR, cred, p);
  625     inp->VFid = *fid;
  626     inp->count = count;
  627     inp->offset = offset;
  628 
  629     Osize = VC_MAXMSGSIZE;
  630     error = coda_call(mdp, Isize, &Osize, (char *)inp);
  631     if (!error) {
  632         bcopy((char *)outp + (int)outp->data, buffer, outp->size);
  633         *len = outp->size;
  634     }
  635 
  636     CODA_FREE(inp, coda_readdir_size);
  637     return error;
  638 }
  639 
  640 int
  641 venus_fhtovp(void *mdp, ViceFid *fid,
  642         struct ucred *cred, struct proc *p,
  643 /*out*/ ViceFid *VFid, int *vtype)
  644 {
  645     DECL(coda_vget);                    /* sets Isize & Osize */
  646     ALLOC(coda_vget);                   /* sets inp & outp */
  647 
  648     /* Send the open to Venus. */
  649     INIT_IN(&inp->ih, CODA_VGET, cred, p);
  650     inp->VFid = *fid;
  651 
  652     error = coda_call(mdp, Isize, &Osize, (char *)inp);
  653     if (!error) {
  654         *VFid = outp->VFid;
  655         *vtype = outp->vtype;
  656     }
  657 
  658     CODA_FREE(inp, coda_vget_size);
  659     return error;
  660 }

Cache object: 2ed3eeb5385def99fba608de88867996


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.