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

Cache object: c077c5cfbb17fc96bea53671b932ae5a


[ 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.