]> arthur.barton.de Git - netatalk.git/blobdiff - etc/afpd/afs.c
Spelling fixes
[netatalk.git] / etc / afpd / afs.c
index 4c80d06993a1eabf1c618a516b0c4fa481110915..f11d77eb22995a400ff43247cf7ddd4441babdbb 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: afs.c,v 1.10 2002-03-24 01:23:40 sibaz Exp $
+ * $Id: afs.c,v 1.18 2009-10-15 10:43:13 didg Exp $
  * Copyright (c) 1990,1993 Regents of The University of Michigan.
  * All Rights Reserved.  See COPYRIGHT.
  */
 #ifdef HAVE_UNISTD_H
 #include <unistd.h>
 #endif /* HAVE_UNISTD_H */
+#include <sys/stat.h>
 
 #include "globals.h"
 #include "directory.h"
 #include "volume.h"
 #include "misc.h"
+#include "unix.h"
 
-afs_getvolspace( vol, bfree, btotal, bsize )
-struct vol     *vol;
-VolSpace       *bfree, *btotal;
-u_int32_t   *bsize;
+int afs_getvolspace(struct vol *vol, VolSpace *bfree, VolSpace *btotal, uint32_t *bsize)
 {
     struct ViceIoctl   vi;
     struct VolumeStatus        *vs;
@@ -48,6 +47,9 @@ u_int32_t   *bsize;
 
     if ( vs->PartBlocksAvail > 0 ) {
         if ( vs->MaxQuota != 0 ) {
+#ifdef min
+#undef min
+#endif
 #define min(x,y)       (((x)<(y))?(x):(y))
             free = min( vs->MaxQuota - vs->BlocksInUse, vs->PartBlocksAvail );
         } else {
@@ -70,17 +72,14 @@ u_int32_t   *bsize;
     return( AFP_OK );
 }
 
-afp_getdiracl(obj, ibuf, ibuflen, rbuf, rbuflen )
-AFPObj      *obj;
-char   *ibuf, *rbuf;
-int            ibuflen, *rbuflen;
+int afp_getdiracl(AFPObj *obj, char *ibuf, size_t ibuflen, char *rbuf, size_t *rbuflen)
 {
     struct ViceIoctl   vi;
     struct vol         *vol;
     struct dir         *dir;
-    char               *path;
-    u_int32_t          did;
-    u_int16_t          vid;
+    struct path                *path;
+    uint32_t           did;
+    uint16_t           vid;
 
     ibuf += 2;
     memcpy( &vid, ibuf, sizeof( vid ));
@@ -92,18 +91,18 @@ int         ibuflen, *rbuflen;
 
     memcpy( &did, ibuf, sizeof( did ));
     ibuf += sizeof( int );
-    if (( dir = dirsearch( vol, did )) == NULL ) {
+    if (( dir = dirlookup( vol, did )) == NULL ) {
         *rbuflen = 0;
-        return( AFPERR_NOOBJ );
+        return afp_errno;
     }
 
     if (( path = cname( vol, dir, &ibuf )) == NULL ) {
         *rbuflen = 0;
-        return( AFPERR_NOOBJ );
+        return get_afp_errno(AFPERR_PARAM);
     }
-    if ( *path != '\0' ) {
+    if ( *path->m_name != '\0' ) {
         *rbuflen = 0;
-        return( AFPERR_BITMAP );
+        return (path_isadir( path))? afp_errno: AFPERR_BITMAP;
     }
 
     vi.in_size = 0;
@@ -123,10 +122,11 @@ int               ibuflen, *rbuflen;
  * VIOCGETAL.  If the directory is on AFS, use access() calls to
  * estimate permission, a la mdw.
  */
-afsmode( path, ma, dir )
-char           *path;
-struct maccess *ma;
-struct dir             *dir;
+#ifdef accessmode
+    #undef accessmode
+#endif
+
+void afsmode(const struct volume *vol, char *path, struct maccess *ma, struct dir *dir, struct stat *st)
 {
     struct ViceIoctl   vi;
     char               buf[ 1024 ];
@@ -146,7 +146,7 @@ struct dir          *dir;
         return;
     }
 
-    accessmode( path, &ma, dir );
+    accessmode(vol, path, ma, dir, st );
 
     return;
 }
@@ -155,17 +155,15 @@ extern struct dir *curdir;
 /*
  * cmd | 0 | vid | did | pathtype | pathname | 0 | acl
  */
-afp_setdiracl(obj, ibuf, ibuflen, rbuf, rbuflen )
-AFPObj      *obj;
-char   *ibuf, *rbuf;
-int            ibuflen, *rbuflen;
+int afp_setdiracl(AFPObj *obj, char *ibuf, size_t ibuflen, char *rbuf, size_t *rbuflen)
 {
     struct ViceIoctl   vi;
     struct vol         *vol;
     struct dir         *dir;
-    char               *path, *iend;
-    u_int32_t          did;
-    u_int16_t          vid;
+    char               *iend;
+    struct path                *path;
+    uint32_t           did;
+    uint16_t           vid;
 
     *rbuflen = 0;
     iend = ibuf + ibuflen;
@@ -179,18 +177,18 @@ int               ibuflen, *rbuflen;
 
     memcpy( &did, ibuf, sizeof( did ));
     ibuf += sizeof( int );
-    if (( dir = dirsearch( vol, did )) == NULL ) {
+    if (( dir = dirlookup( vol, did )) == NULL ) {
         *rbuflen = 0;
-        return( AFPERR_NOOBJ );
+        return afp_errno;
     }
 
     if (( path = cname( vol, dir, &ibuf )) == NULL ) {
         *rbuflen = 0;
-        return( AFPERR_NOOBJ );
+        return get_afp_errno(AFPERR_PARAM);
     }
-    if ( *path != '\0' ) {
+    if ( *path->m_name != '\0' ) {
         *rbuflen = 0;
-        return( AFPERR_BITMAP );
+        return (path_isadir( path))? afp_errno: AFPERR_BITMAP;
     }
 
     if ((int)ibuf & 1 ) {
@@ -224,16 +222,13 @@ int               ibuflen, *rbuflen;
 extern C_Block         seskey;
 extern Key_schedule    seskeysched;
 
-afp_afschangepw(obj, ibuf, ibuflen, rbuf, rbuflen )
-AFPObj      *obj;
-char   *ibuf, *rbuf;
-int            ibuflen, *rbuflen;
+int afp_afschangepw(AFPObj *obj, char *ibuf, size_t ibuflen, char *rbuf, size_t *rbuflen)
 {
     char       name[ MAXKTCNAMELEN ], instance[ MAXKTCNAMELEN ];
     char       realm[ MAXKTCREALMLEN ];
     char       oldpw[ 9 ], newpw[ 9 ];
     int                len, rc;
-    u_int16_t  clen;
+    uint16_t   clen;
     struct ktc_encryptionKey   oldkey, newkey;
     struct ktc_token           adtok;
     struct ubik_client         *conn;