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  -  FREEBSD11  -  FREEBSD10  -  FREEBSD9  -  FREEBSD92  -  FREEBSD91  -  FREEBSD90  -  FREEBSD8  -  FREEBSD82  -  FREEBSD81  -  FREEBSD80  -  FREEBSD7  -  FREEBSD74  -  FREEBSD73  -  FREEBSD72  -  FREEBSD71  -  FREEBSD70  -  FREEBSD6  -  FREEBSD64  -  FREEBSD63  -  FREEBSD62  -  FREEBSD61  -  FREEBSD60  -  FREEBSD5  -  FREEBSD55  -  FREEBSD54  -  FREEBSD53  -  FREEBSD52  -  FREEBSD51  -  FREEBSD50  -  FREEBSD4  -  FREEBSD3  -  FREEBSD22  -  linux-2.6  -  linux-2.4.22  -  MK83  -  MK84  -  PLAN9  -  DFBSD  -  NETBSD  -  NETBSD5  -  NETBSD4  -  NETBSD3  -  NETBSD20  -  OPENBSD  -  xnu-517  -  xnu-792  -  xnu-792.6.70  -  xnu-1228  -  xnu-1456.1.26  -  xnu-1699.24.8  -  xnu-2050.18.24  -  OPENSOLARIS  -  minix-3-1-1 
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$");
   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*/ struct cdev **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         *dev =  findcdev(outp->dev);
  216         *inode = outp->inode;
  217     }
  218 
  219     CODA_FREE(inp, coda_open_size);
  220     return error;
  221 }
  222 
  223 int
  224 venus_close(void *mdp, CodaFid *fid, int flag,
  225         struct ucred *cred, struct proc *p)
  226 {
  227     int cflag;
  228     DECL_NO_OUT(coda_close);            /* sets Isize & Osize */
  229     ALLOC_NO_OUT(coda_close);           /* sets inp & outp */
  230 
  231     INIT_IN(&inp->ih, CODA_CLOSE, cred, p);
  232     inp->Fid = *fid;
  233     CNV_OFLAG(cflag, flag);
  234     inp->flags = cflag;
  235 
  236     error = coda_call(mdp, Isize, &Osize, (char *)inp);
  237 
  238     CODA_FREE(inp, coda_close_size);
  239     return error;
  240 }
  241 
  242 /*
  243  * these two calls will not exist!!!  the container file is read/written
  244  * directly.
  245  */
  246 void
  247 venus_read(void)
  248 {
  249 }
  250 
  251 void
  252 venus_write(void)
  253 {
  254 }
  255 
  256 /*
  257  * this is a bit sad too.  the ioctl's are for the control file, not for
  258  * normal files.
  259  */
  260 int
  261 venus_ioctl(void *mdp, CodaFid *fid,
  262         int com, int flag, caddr_t data,
  263         struct ucred *cred, struct proc *p)
  264 {
  265     DECL(coda_ioctl);                   /* sets Isize & Osize */
  266     struct PioctlData *iap = (struct PioctlData *)data;
  267     int tmp;
  268 
  269     coda_ioctl_size = VC_MAXMSGSIZE;
  270     ALLOC(coda_ioctl);                  /* sets inp & outp */
  271 
  272     INIT_IN(&inp->ih, CODA_IOCTL, cred, p);
  273     inp->Fid = *fid;
  274 
  275     /* command was mutated by increasing its size field to reflect the  
  276      * path and follow args. we need to subtract that out before sending
  277      * the command to venus.
  278      */
  279     inp->cmd = (com & ~(IOCPARM_MASK << 16));
  280     tmp = ((com >> 16) & IOCPARM_MASK) - sizeof (char *) - sizeof (int);
  281     inp->cmd |= (tmp & IOCPARM_MASK) << 16;
  282 
  283     inp->rwflag = flag;
  284     inp->len = iap->vi.in_size;
  285     inp->data = (char *)(sizeof (struct coda_ioctl_in));
  286 
  287     error = copyin(iap->vi.in, (char*)inp + (long)inp->data, 
  288                    iap->vi.in_size);
  289     if (error) {
  290         CODA_FREE(inp, coda_ioctl_size);
  291         return(error);
  292     }
  293 
  294     Osize = VC_MAXMSGSIZE;
  295     error = coda_call(mdp, Isize + iap->vi.in_size, &Osize, (char *)inp);
  296 
  297         /* copy out the out buffer. */
  298     if (!error) {
  299         if (outp->len > iap->vi.out_size) {
  300             error = EINVAL;
  301         } else {
  302             error = copyout((char *)outp + (long)outp->data, 
  303                             iap->vi.out, iap->vi.out_size);
  304         }
  305     }
  306 
  307     CODA_FREE(inp, coda_ioctl_size);
  308     return error;
  309 }
  310 
  311 int
  312 venus_getattr(void *mdp, CodaFid *fid,
  313         struct ucred *cred, struct proc *p,
  314 /*out*/ struct vattr *vap)
  315 {
  316     DECL(coda_getattr);                 /* sets Isize & Osize */
  317     ALLOC(coda_getattr);                        /* sets inp & outp */
  318 
  319     /* send the open to venus. */
  320     INIT_IN(&inp->ih, CODA_GETATTR, cred, p);
  321     inp->Fid = *fid;
  322 
  323     error = coda_call(mdp, Isize, &Osize, (char *)inp);
  324     if (!error) {
  325         CNV_VV2V_ATTR(vap, &outp->attr);
  326     }
  327 
  328     CODA_FREE(inp, coda_getattr_size);
  329     return error;
  330 }
  331 
  332 int
  333 venus_setattr(void *mdp, CodaFid *fid, struct vattr *vap,
  334         struct ucred *cred, struct proc *p)
  335 {
  336     DECL_NO_OUT(coda_setattr);          /* sets Isize & Osize */
  337     ALLOC_NO_OUT(coda_setattr);         /* sets inp & outp */
  338 
  339     /* send the open to venus. */
  340     INIT_IN(&inp->ih, CODA_SETATTR, cred, p);
  341     inp->Fid = *fid;
  342     CNV_V2VV_ATTR(&inp->attr, vap);
  343 
  344     error = coda_call(mdp, Isize, &Osize, (char *)inp);
  345 
  346     CODA_FREE(inp, coda_setattr_size);
  347     return error;
  348 }
  349 
  350 int
  351 venus_access(void *mdp, CodaFid *fid, int mode,
  352         struct ucred *cred, struct proc *p)
  353 {
  354     DECL_NO_OUT(coda_access);           /* sets Isize & Osize */
  355     ALLOC_NO_OUT(coda_access);          /* sets inp & outp */
  356 
  357     /* send the open to venus. */
  358     INIT_IN(&inp->ih, CODA_ACCESS, cred, p);
  359     inp->Fid = *fid;
  360     /* NOTE:
  361      * NetBSD and Venus internals use the "data" in the low 3 bits.
  362      * Hence, the conversion.
  363      */
  364     inp->flags = mode>>6;
  365 
  366     error = coda_call(mdp, Isize, &Osize, (char *)inp);
  367 
  368     CODA_FREE(inp, coda_access_size);
  369     return error;
  370 }
  371 
  372 int
  373 venus_readlink(void *mdp, CodaFid *fid,
  374         struct ucred *cred, struct proc *p,
  375 /*out*/ char **str, int *len)
  376 {
  377     DECL(coda_readlink);                        /* sets Isize & Osize */
  378     coda_readlink_size += CODA_MAXPATHLEN;
  379     ALLOC(coda_readlink);               /* sets inp & outp */
  380 
  381     /* send the open to venus. */
  382     INIT_IN(&inp->ih, CODA_READLINK, cred, p);
  383     inp->Fid = *fid;
  384 
  385     Osize += CODA_MAXPATHLEN;
  386     error = coda_call(mdp, Isize, &Osize, (char *)inp);
  387     if (!error) {
  388             CODA_ALLOC(*str, char *, outp->count);
  389             *len = outp->count;
  390             bcopy((char *)outp + (long)outp->data, *str, *len);
  391     }
  392 
  393     CODA_FREE(inp, coda_readlink_size);
  394     return error;
  395 }
  396 
  397 int
  398 venus_fsync(void *mdp, CodaFid *fid,
  399         struct ucred *cred, struct proc *p)
  400 {
  401     DECL_NO_OUT(coda_fsync);            /* sets Isize & Osize */
  402     ALLOC_NO_OUT(coda_fsync);           /* sets inp & outp */
  403 
  404     /* send the open to venus. */
  405     INIT_IN(&inp->ih, CODA_FSYNC, cred, p);
  406     inp->Fid = *fid;
  407 
  408     error = coda_call(mdp, Isize, &Osize, (char *)inp);
  409 
  410     CODA_FREE(inp, coda_fsync_size);
  411     return error;
  412 }
  413 
  414 int
  415 venus_lookup(void *mdp, CodaFid *fid,
  416         const char *nm, int len,
  417         struct ucred *cred, struct proc *p,
  418 /*out*/ CodaFid *VFid, int *vtype)
  419 {
  420     DECL(coda_lookup);                  /* sets Isize & Osize */
  421     coda_lookup_size += len + 1;
  422     ALLOC(coda_lookup);                 /* sets inp & outp */
  423 
  424     /* send the open to venus. */
  425     INIT_IN(&inp->ih, CODA_LOOKUP, cred, p);
  426     inp->Fid = *fid;
  427 
  428     /* NOTE:
  429      * Between version 1 and version 2 we have added an extra flag field
  430      * to this structure.  But because the string was at the end and because
  431      * of the wierd way we represent strings by having the slot point to
  432      * where the string characters are in the "heap", we can just slip the
  433      * flag parameter in after the string slot pointer and veni that don't
  434      * know better won't see this new flag field ...
  435      * Otherwise we'd need two different venus_lookup functions.
  436      */
  437     inp->name = Isize;
  438     inp->flags = CLU_CASE_SENSITIVE;    /* doesn't really matter for BSD */
  439     STRCPY(name, nm, len);              /* increments Isize */
  440 
  441     error = coda_call(mdp, Isize, &Osize, (char *)inp);
  442     if (!error) {
  443         *VFid = outp->Fid;
  444         *vtype = outp->vtype;
  445     }
  446 
  447     CODA_FREE(inp, coda_lookup_size);
  448     return error;
  449 }
  450 
  451 int
  452 venus_create(void *mdp, CodaFid *fid,
  453         const char *nm, int len, int exclusive, int mode, struct vattr *va,
  454         struct ucred *cred, struct proc *p,
  455 /*out*/ CodaFid *VFid, struct vattr *attr)
  456 {
  457     DECL(coda_create);                  /* sets Isize & Osize */
  458     coda_create_size += len + 1;
  459     ALLOC(coda_create);                 /* sets inp & outp */
  460 
  461     /* send the open to venus. */
  462     INIT_IN(&inp->ih, CODA_CREATE, cred, p);
  463     inp->Fid = *fid;
  464     inp->excl = exclusive ? C_O_EXCL : 0;
  465     inp->mode = mode;
  466     CNV_V2VV_ATTR(&inp->attr, va);
  467 
  468     inp->name = Isize;
  469     STRCPY(name, nm, len);              /* increments Isize */
  470 
  471     error = coda_call(mdp, Isize, &Osize, (char *)inp);
  472     if (!error) {
  473         *VFid = outp->Fid;
  474         CNV_VV2V_ATTR(attr, &outp->attr);
  475     }
  476 
  477     CODA_FREE(inp, coda_create_size);
  478     return error;
  479 }
  480 
  481 int
  482 venus_remove(void *mdp, CodaFid *fid,
  483         const char *nm, int len,
  484         struct ucred *cred, struct proc *p)
  485 {
  486     DECL_NO_OUT(coda_remove);           /* sets Isize & Osize */
  487     coda_remove_size += len + 1;
  488     ALLOC_NO_OUT(coda_remove);          /* sets inp & outp */
  489 
  490     /* send the open to venus. */
  491     INIT_IN(&inp->ih, CODA_REMOVE, cred, p);
  492     inp->Fid = *fid;
  493 
  494     inp->name = Isize;
  495     STRCPY(name, nm, len);              /* increments Isize */
  496 
  497     error = coda_call(mdp, Isize, &Osize, (char *)inp);
  498 
  499     CODA_FREE(inp, coda_remove_size);
  500     return error;
  501 }
  502 
  503 int
  504 venus_link(void *mdp, CodaFid *fid, CodaFid *tfid,
  505         const char *nm, int len,
  506         struct ucred *cred, struct proc *p)
  507 {
  508     DECL_NO_OUT(coda_link);             /* sets Isize & Osize */
  509     coda_link_size += len + 1;
  510     ALLOC_NO_OUT(coda_link);            /* sets inp & outp */
  511 
  512     /* send the open to venus. */
  513     INIT_IN(&inp->ih, CODA_LINK, cred, p);
  514     inp->sourceFid = *fid;
  515     inp->destFid = *tfid;
  516 
  517     inp->tname = Isize;
  518     STRCPY(tname, nm, len);             /* increments Isize */
  519 
  520     error = coda_call(mdp, Isize, &Osize, (char *)inp);
  521 
  522     CODA_FREE(inp, coda_link_size);
  523     return error;
  524 }
  525 
  526 int
  527 venus_rename(void *mdp, CodaFid *fid, CodaFid *tfid,
  528         const char *nm, int len, const char *tnm, int tlen,
  529         struct ucred *cred, struct proc *p)
  530 {
  531     DECL_NO_OUT(coda_rename);           /* sets Isize & Osize */
  532     coda_rename_size += len + 1 + tlen + 1;
  533     ALLOC_NO_OUT(coda_rename);          /* sets inp & outp */
  534 
  535     /* send the open to venus. */
  536     INIT_IN(&inp->ih, CODA_RENAME, cred, p);
  537     inp->sourceFid = *fid;
  538     inp->destFid = *tfid;
  539 
  540     inp->srcname = Isize;
  541     STRCPY(srcname, nm, len);           /* increments Isize */
  542 
  543     inp->destname = Isize;
  544     STRCPY(destname, tnm, tlen);        /* increments Isize */
  545 
  546     error = coda_call(mdp, Isize, &Osize, (char *)inp);
  547 
  548     CODA_FREE(inp, coda_rename_size);
  549     return error;
  550 }
  551 
  552 int
  553 venus_mkdir(void *mdp, CodaFid *fid,
  554         const char *nm, int len, struct vattr *va,
  555         struct ucred *cred, struct proc *p,
  556 /*out*/ CodaFid *VFid, struct vattr *ova)
  557 {
  558     DECL(coda_mkdir);                   /* sets Isize & Osize */
  559     coda_mkdir_size += len + 1;
  560     ALLOC(coda_mkdir);                  /* sets inp & outp */
  561 
  562     /* send the open to venus. */
  563     INIT_IN(&inp->ih, CODA_MKDIR, cred, p);
  564     inp->Fid = *fid;
  565     CNV_V2VV_ATTR(&inp->attr, va);
  566 
  567     inp->name = Isize;
  568     STRCPY(name, nm, len);              /* increments Isize */
  569 
  570     error = coda_call(mdp, Isize, &Osize, (char *)inp);
  571     if (!error) {
  572         *VFid = outp->Fid;
  573         CNV_VV2V_ATTR(ova, &outp->attr);
  574     }
  575 
  576     CODA_FREE(inp, coda_mkdir_size);
  577     return error;
  578 }
  579 
  580 int
  581 venus_rmdir(void *mdp, CodaFid *fid,
  582         const char *nm, int len,
  583         struct ucred *cred, struct proc *p)
  584 {
  585     DECL_NO_OUT(coda_rmdir);            /* sets Isize & Osize */
  586     coda_rmdir_size += len + 1;
  587     ALLOC_NO_OUT(coda_rmdir);           /* sets inp & outp */
  588 
  589     /* send the open to venus. */
  590     INIT_IN(&inp->ih, CODA_RMDIR, cred, p);
  591     inp->Fid = *fid;
  592 
  593     inp->name = Isize;
  594     STRCPY(name, nm, len);              /* increments Isize */
  595 
  596     error = coda_call(mdp, Isize, &Osize, (char *)inp);
  597 
  598     CODA_FREE(inp, coda_rmdir_size);
  599     return error;
  600 }
  601 
  602 int
  603 venus_symlink(void *mdp, CodaFid *fid,
  604         const char *lnm, int llen, const char *nm, int len, struct vattr *va,
  605         struct ucred *cred, struct proc *p)
  606 {
  607     DECL_NO_OUT(coda_symlink);          /* sets Isize & Osize */
  608     coda_symlink_size += llen + 1 + len + 1;
  609     ALLOC_NO_OUT(coda_symlink);         /* sets inp & outp */
  610 
  611     /* send the open to venus. */
  612     INIT_IN(&inp->ih, CODA_SYMLINK, cred, p);
  613     inp->Fid = *fid;
  614     CNV_V2VV_ATTR(&inp->attr, va);
  615 
  616     inp->srcname = Isize;
  617     STRCPY(srcname, lnm, llen);         /* increments Isize */
  618 
  619     inp->tname = Isize;
  620     STRCPY(tname, nm, len);             /* increments Isize */
  621 
  622     error = coda_call(mdp, Isize, &Osize, (char *)inp);
  623 
  624     CODA_FREE(inp, coda_symlink_size);
  625     return error;
  626 }
  627 
  628 int
  629 venus_readdir(void *mdp, CodaFid *fid,
  630         int count, int offset,
  631         struct ucred *cred, struct proc *p,
  632 /*out*/ char *buffer, int *len)
  633 {
  634     DECL(coda_readdir);                 /* sets Isize & Osize */
  635     coda_readdir_size = VC_MAXMSGSIZE;
  636     ALLOC(coda_readdir);                        /* sets inp & outp */
  637 
  638     /* send the open to venus. */
  639     INIT_IN(&inp->ih, CODA_READDIR, cred, p);
  640     inp->Fid = *fid;
  641     inp->count = count;
  642     inp->offset = offset;
  643 
  644     Osize = VC_MAXMSGSIZE;
  645     error = coda_call(mdp, Isize, &Osize, (char *)inp);
  646     if (!error) {
  647         bcopy((char *)outp + (long)outp->data, buffer, outp->size);
  648         *len = outp->size;
  649     }
  650 
  651     CODA_FREE(inp, coda_readdir_size);
  652     return error;
  653 }
  654 
  655 int
  656 venus_fhtovp(void *mdp, CodaFid *fid,
  657         struct ucred *cred, struct proc *p,
  658 /*out*/ CodaFid *VFid, int *vtype)
  659 {
  660     DECL(coda_vget);                    /* sets Isize & Osize */
  661     ALLOC(coda_vget);                   /* sets inp & outp */
  662 
  663     /* Send the open to Venus. */
  664     INIT_IN(&inp->ih, CODA_VGET, cred, p);
  665     inp->Fid = *fid;
  666 
  667     error = coda_call(mdp, Isize, &Osize, (char *)inp);
  668     if (!error) {
  669         *VFid = outp->Fid;
  670         *vtype = outp->vtype;
  671     }
  672 
  673     CODA_FREE(inp, coda_vget_size);
  674     return error;
  675 }

Cache object: 1ebe90ec9a3fc257aae6c2c047e7deec


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