]> arthur.barton.de Git - netatalk.git/commitdiff
Remove flock lock support.
authorsrittau <srittau>
Thu, 14 Nov 2002 17:15:22 +0000 (17:15 +0000)
committersrittau <srittau>
Thu, 14 Nov 2002 17:15:22 +0000 (17:15 +0000)
include/atalk/adouble.h
libatalk/adouble/ad_lock.c
libatalk/adouble/ad_private.h
libatalk/compat/Makefile.am
libatalk/compat/flock.c [deleted file]

index 95dea94e78ac72c7dd400b1beb58953dbbb37dcf..542503fc6509df2ffef6fc1b64feedf1052ac25b 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: adouble.h,v 1.11 2002-10-11 14:18:35 didg Exp $
+ * $Id: adouble.h,v 1.12 2002-11-14 17:15:22 srittau Exp $
  * Copyright (c) 1990,1991 Regents of The University of Michigan.
  * All Rights Reserved.
  *
 #include <unistd.h>
 #endif 
 
-#ifdef HAVE_FLOCK
-#include <sys/file.h>
-#else
-#define LOCK_SH 1
-#define LOCK_EX 2
-#define LOCK_NB 4
-#define LOCK_UN 8
-extern int flock (int /*fd*/, int /*operation*/);
-#endif
-
 #ifdef HAVE_FCNTL_H  
 #include <fcntl.h>
 #endif
@@ -316,30 +306,18 @@ extern int ad_flush           __P((struct adouble *, int));
 extern int ad_close           __P((struct adouble *, int));
 
 /* ad_lock.c */
-extern int ad_flock_lock __P((struct adouble *, const u_int32_t /*eid*/,
-                             const int /*type*/, const off_t /*offset*/,
-                             const size_t /*len*/, const int /*user*/));
 extern int ad_fcntl_lock __P((struct adouble *, const u_int32_t /*eid*/,
                              const int /*type*/, const off_t /*offset*/,
                              const size_t /*len*/, const int /*user*/));
 extern void ad_fcntl_unlock __P((struct adouble *, const int /*user*/));
 
-extern int ad_flock_tmplock __P((struct adouble *, const u_int32_t /*eid*/,
-                                const int /*type*/, const off_t /*offset*/,
-                                const size_t /*len*/));
 extern int ad_fcntl_tmplock __P((struct adouble *, const u_int32_t /*eid*/,
                                 const int /*type*/, const off_t /*offset*/,
                                 const size_t /*len*/));
 
-#ifdef USE_FLOCK_LOCKS
-#define ad_lock ad_flock_lock
-#define ad_tmplock ad_flock_tmplock
-#define ad_unlock(a,b) 
-#else
 #define ad_lock ad_fcntl_lock
 #define ad_tmplock ad_fcntl_tmplock
 #define ad_unlock ad_fcntl_unlock
-#endif
 
 /* ad_open.c */
 extern char *ad_dir   __P((const char *));
@@ -354,7 +332,6 @@ extern int ad_refresh __P((struct adouble *));
 #ifndef ATACC
 static __inline__ mode_t ad_hf_mode (mode_t mode)
 {
-#ifndef USE_FLOCK_LOCKS
     /* fnctl lock need write access */
     if ((mode & S_IRUSR))
         mode |= S_IWUSR;
@@ -362,7 +339,7 @@ static __inline__ mode_t ad_hf_mode (mode_t mode)
         mode |= S_IWGRP;
     if ((mode & S_IROTH))
         mode |= S_IWOTH;
-#endif
+
     /* if write mode set add read mode */
     if ((mode & S_IWUSR))
         mode |= S_IRUSR;
index 159ba4a79f6c60311c49642793a7772e0752ef22..22ceef504c9a2fc20fe453e8459ccd282076929d 100644 (file)
@@ -1,5 +1,5 @@
 /* 
- * $Id: ad_lock.c,v 1.5 2002-07-01 23:25:00 didg Exp $
+ * $Id: ad_lock.c,v 1.6 2002-11-14 17:15:22 srittau Exp $
  *
  * Copyright (c) 1998,1999 Adrian Sun (asun@zoology.washington.edu)
  * All Rights Reserved. See COPYRIGHT for more information.
@@ -360,8 +360,7 @@ int ad_testlock(struct adouble *ad, int eid, const off_t off)
   struct ad_fd *adf;
   adf_lock_t *plock;
   int i;
-  int lockmode;
-    
+
   lock.l_start = off;
   if (eid == ADEID_DFORK) {
     adf = &ad->ad_df;
@@ -448,69 +447,3 @@ void ad_fcntl_unlock(struct adouble *ad, const int user)
     adf_unlock(&ad->ad_hf, ad->ad_hf.adf_fd, user);
   }
 }
-
-/* byte-range locks. ad_lock is used by afp_bytelock and afp_openfork
- * to establish locks. both ad_lock and ad_tmplock take 0, 0, 0 to
- * signify locking of the entire file. in the absence of working 
- * byte-range locks, this will default to file-wide flock-style locks.
- */
-int ad_flock_lock(struct adouble *ad, const u_int32_t eid, const int type,
-                 const off_t off, const size_t len, const int user)
-{
-  int err, lock_type;
-  
-  lock_type = XLATE_FLOCK(type & ADLOCK_MASK);
-  if (eid == ADEID_DFORK) {
-    if ((err = flock(ad_dfileno(ad), lock_type | LOCK_NB)) == 0)
-      ad->ad_df.adf_lockcount = lock_type;
-  } else if ((err = flock(ad_hfileno(ad), lock_type | LOCK_NB)) == 0)
-    ad->ad_hf.adf_lockcount = lock_type;
-
-  if (err) {
-    if ((EWOULDBLOCK != EAGAIN) && (errno == EWOULDBLOCK))
-      errno = EAGAIN;
-    return -1;
-  } 
-
-  return 0; 
-}
-
-/* ad_tmplock is used by afpd to lock actual read/write operations. 
- * it saves the current lock state before attempting to lock to prevent
- * mixups. if byte-locks don't exist, it will lock the entire file with
- * an flock. we can be a little smart here by just upgrading/downgrading
- * locks. */
-int ad_flock_tmplock(struct adouble *ad, const u_int32_t eid, const int type,
-                    const off_t off, const size_t len) 
-{
-  int fd, oldlock, lock_type;
-  
-  if (eid == ADEID_DFORK) {
-    oldlock = ad->ad_df.adf_lockcount;
-    fd = ad_dfileno(ad);
-  } else {
-    oldlock = ad->ad_hf.adf_lockcount;
-    fd = ad_hfileno(ad);
-  }
-
-  /* if we already have a write lock, we don't need to do anything */
-  if (oldlock == LOCK_EX) {
-    return 0;
-  }
-
-  /* if we have a read lock, upgrade it if necessary */
-  lock_type = XLATE_FLOCK(type & ADLOCK_MASK);
-  if (oldlock == LOCK_SH) {
-    if (lock_type == LOCK_EX) 
-      return flock(fd, LOCK_EX | LOCK_NB);
-    else if (lock_type == LOCK_UN) /* reset it */
-      return flock(fd, LOCK_SH | LOCK_NB);
-    else /* do nothing */
-      return 0;
-  }
-
-  /* if we don't already have a lock, just do it. */
-  return flock(fd, lock_type | LOCK_NB);
-}
-
-
index 6cd19b005d832bef30ac7955c08ffeac2ed69918..1ae494ef73bf54327b88b791a1cf984faab4958d 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: ad_private.h,v 1.3 2002-08-16 08:07:57 didg Exp $
+ * $Id: ad_private.h,v 1.4 2002-11-14 17:15:23 srittau Exp $
  */
 
 #ifndef LIBATALK_ADOUBLE_AD_PRIVATE_H
 /* this is so that we can keep lists of fds referencing the same file
  * around. that way, we can honor locks created by the same process
  * with the same file. */
-#ifdef USE_FLOCK_LOCKS
-#define adf_lock_init(a)
-#define adf_lock_free(a)
-#else /* USE_FLOCK_LOCKS */
 
 #define adf_lock_init(a) do { \
        (a)->adf_lockmax = (a)->adf_lockcount = 0; \
@@ -39,6 +35,5 @@
        free((a)->adf_lock); \
        adf_lock_init(a); \
 } while (0)
-#endif /* USE_FLOCK_LOCKS */
 
 #endif /* libatalk/adouble/ad_private.h */
index 1223fcad4457f9c3b35d62d069a2e60c0a46d83f..63ccddd4dcc6fbd9d48f3df38ff4e69c49b0745f 100644 (file)
@@ -10,5 +10,4 @@ libcompat_la_SOURCES =        \
        strdup.c        \
        inet_aton.c     \
        rquota_xdr.c    \
-       flock.c         \
        snprintf.c
diff --git a/libatalk/compat/flock.c b/libatalk/compat/flock.c
deleted file mode 100644 (file)
index 1a7f644..0000000
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * $Id: flock.c,v 1.4 2001-06-29 14:14:46 rufustfirefly Exp $
- *
- * Copyright (c) 1996 Regents of The University of Michigan.
- * All Rights Reserved.  See COPYRIGHT.
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif /* HAVE_CONFIG_H */
-
-static int     _flock_dummy;
-
-#ifndef HAVE_FLOCK
-
-#include <sys/types.h>
-#ifdef HAVE_FCNTL_H
-#include <fcntl.h>
-#endif /* HAVE_FCNTL_H */
-#include <errno.h>
-
-#define LOCK_SH         1
-#define LOCK_EX         2
-#define LOCK_NB         4
-#define LOCK_UN         8
-
-int flock( fd, operation )
-    int                fd;
-    int                operation;
-{
-    struct flock       l;
-    int                        rc, op;
-
-    if ( operation & LOCK_NB ) {
-       op = F_SETLK;
-    } else {
-       op = F_SETLKW;
-    }
-
-    if ( operation & LOCK_EX ) {
-       l.l_type = F_WRLCK;
-    }
-
-    if ( operation & LOCK_SH ) {
-       l.l_type = F_RDLCK;
-    }
-
-    if ( operation & LOCK_UN ) {
-       l.l_type = F_UNLCK;
-    }
-
-    l.l_whence = 0;
-    l.l_start = 0;
-    l.l_len = 0;
-
-    if (( rc = fcntl( fd, F_SETLK, &l )) < 0 ) {
-       if ( errno == EAGAIN || errno == EACCES ) {
-           errno = EWOULDBLOCK;
-       }
-    }
-    return( rc );
-}
-#endif /* !HAVE_FLOCK */