]> arthur.barton.de Git - netatalk.git/commitdiff
Better at funcs detection
authorFrank Lahm <franklahm@googlemail.com>
Mon, 21 Mar 2011 12:08:39 +0000 (13:08 +0100)
committerFrank Lahm <franklahm@googlemail.com>
Mon, 21 Mar 2011 12:08:39 +0000 (13:08 +0100)
configure.in
etc/afpd/filedir.c
etc/afpd/fork.h
etc/afpd/ofork.c
libatalk/vfs/unix.c

index 96dbfbb39594f1914c9ec84106ecf422d87b6cf0..a24906f2040403a8c82ac9ee8cfc5d1109a478f2 100644 (file)
@@ -73,13 +73,12 @@ AC_FUNC_WAIT3
 AC_CHECK_FUNCS(getcwd gethostname gettimeofday getusershell mkdir rmdir select socket strdup strcasestr strstr strtoul strchr memcpy)
 AC_CHECK_FUNCS(backtrace_symbols setlocale nl_langinfo strlcpy strlcat setlinebuf dirfd pselect access pread pwrite)
 AC_CHECK_FUNCS(waitpid getcwd strdup strndup strnlen strtoul strerror chown fchown chmod fchmod chroot link mknod mknod64)
-#ac_neta_haveatfuncs=yes
-#AC_CHECK_FUNCS(openat renameat fstatat unlinkat, ,ac_neta_haveatfuncs=no)
-#if test x"$ac_neta_haveatfuncs" = x"yes" ; then
-#   AC_DEFINE([_ATFILE_SOURCE], 1, AT file source)
-#fi
-AC_DEFINE([_ATFILE_SOURCE], 1, AT file source)
-AC_CHECK_FUNCS(openat renameat fstatat unlinkat, ,AC_DEFINE([_ATFILE_SOURCE], 0, AT file source))
+ac_neta_haveatfuncs=yes
+AC_CHECK_FUNCS(openat renameat fstatat unlinkat, , ac_neta_haveatfuncs=no)
+if test x"$ac_neta_haveatfuncs" = x"yes" ; then
+   AC_DEFINE([_ATFILE_SOURCE], 1, AT file source)
+   AC_DEFINE([HAVE_ATFUNCS], 1, whether at funcs are available)
+fi
 
 AC_CHECK_MEMBERS(struct tm.tm_gmtoff,,, [#include <time.h>])
 
index be7056a796ab9c0729d1b8d4307c54ca5f3818d8..8644225b07879b1bd4791f52d8b3e5bdaaecb1e2 100644 (file)
@@ -348,21 +348,21 @@ static int moveandrename(const struct vol *vol,
         if ((p = mtoupath(vol, oldname, sdir->d_did, utf8_encoding())) == NULL)
             return AFPERR_PARAM; /* can't convert */
 
-#ifndef HAVE_RENAMEAT
+#ifndef HAVE_ATFUNCS
         /* Need full path */
         id = cnid_get(vol->v_cdb, sdir->d_did, p, strlen(p));
         p = ctoupath( vol, sdir, oldname );
         if (!p)
             return AFPERR_PARAM; /* pathname too long */
-#endif /* HAVE_RENAMEAT */
+#endif /* HAVE_ATFUNCS */
 
         path.st_valid = 0;
         path.u_name = p;
-#ifdef HAVE_RENAMEAT
+#ifdef HAVE_ATFUNCS
         opened = of_findnameat(sdir_fd, &path);
 #else
         opened = of_findname(&path);
-#endif /* HAVE_RENAMEAT */
+#endif /* HAVE_ATFUNCS */
         if (opened) {
             /* reuse struct adouble so it won't break locks */
             adp = opened->of_ad;
@@ -712,7 +712,7 @@ int afp_moveandrename(AFPObj *obj, char *ibuf, size_t ibuflen _U_, char *rbuf _U
         memcpy(oldname, cfrombstr(sdir->d_m_name), blength(sdir->d_m_name) + 1);
     }
 
-#ifdef HAVE_RENAMEAT
+#ifdef HAVE_ATFUNCS
     if ((sdir_fd = open(".", O_RDONLY)) == -1)
         return AFPERR_MISC;
 #endif
@@ -777,7 +777,7 @@ int afp_moveandrename(AFPObj *obj, char *ibuf, size_t ibuflen _U_, char *rbuf _U
     }
 
 exit:
-#ifdef HAVE_RENAMEAT
+#ifdef HAVE_ATFUNCS
     if (sdir_fd != -1)
         close(sdir_fd);
 #endif
index ab75f1f7930856b8e03a206299d880ce97b6e62c..0cd55cec41aaf609990ef121c4adcaa205e6af09 100644 (file)
@@ -72,10 +72,10 @@ extern int          of_closefork (struct ofork *ofork);
 extern void         of_closevol  (const struct vol *vol);
 extern struct adouble *of_ad     (const struct vol *, struct path *, struct adouble *);
 
-#ifdef HAVE_RENAMEAT
+#ifdef HAVE_ATFUNCS
 extern struct ofork *of_findnameat(int dirfd, struct path *path);
 extern int of_fstatat(int dirfd, struct path *path);
-#endif  /* HAVE_RENAMEAT */
+#endif  /* HAVE_ATFUNCS */
 
 
 /* in fork.c */
index a69a73c56c5de3d015f07858ea6d0e9b029ad3a9..8d6ef268b223e28cf330b2a92876cea4b0d5a4d6 100644 (file)
@@ -272,7 +272,7 @@ int of_stat(struct path *path)
 }
 
 
-#ifdef HAVE_RENAMEAT
+#ifdef HAVE_ATFUNCS
 int of_fstatat(int dirfd, struct path *path)
 {
     int ret;
@@ -285,7 +285,7 @@ int of_fstatat(int dirfd, struct path *path)
 
    return ret;
 }
-#endif /* HAVE_RENAMEAT */
+#endif /* HAVE_ATFUNCS */
 
 /* -------------------------- 
    stat the current directory.
@@ -365,7 +365,7 @@ struct ofork *of_findname(struct path *path)
  * @param dirfd     (r) directory fd
  * @param path      (rw) pointer to struct path
  */
-#ifdef HAVE_RENAMEAT
+#ifdef HAVE_ATFUNCS
 struct ofork *of_findnameat(int dirfd, struct path *path)
 {
     struct ofork *of;
index a43794e139550b0a6513602e3b7d82684eb78874..229f1b7a216e25309c3c581c5c9fcc6e3a1ca6e5 100644 (file)
@@ -101,15 +101,15 @@ int setfilmode(const char * name, mode_t mode, struct stat *st, mode_t v_umask)
 /*
  * @brief system rmdir with afp error code.
  *
- * Supports *at semantics (cf openat) if HAVE_RENAMEAT. Pass dirfd=-1 to ignore this.
+ * Supports *at semantics (cf openat) if HAVE_ATFUNCS. Pass dirfd=-1 to ignore this.
  */
 int netatalk_rmdir_all_errors(int dirfd, const char *name)
 {
     int err;
 
-#ifdef HAVE_RENAMEAT
+#ifdef HAVE_ATFUNCS
     if (dirfd == -1)
-        dirfd = ATFD_CWD;
+        dirfd = AT_FDCWD;
     err = unlinkat(dirfd, name, AT_REMOVEDIR);
 #else
     err = rmdir(name);
@@ -136,7 +136,7 @@ int netatalk_rmdir_all_errors(int dirfd, const char *name)
 /*
  * @brief System rmdir with afp error code, but ENOENT is not an error.
  *
- * Supports *at semantics (cf openat) if HAVE_RENAMEAT. Pass dirfd=-1 to ignore this.
+ * Supports *at semantics (cf openat) if HAVE_ATFUNCS. Pass dirfd=-1 to ignore this.
  */
 int netatalk_rmdir(int dirfd, const char *name)
 {
@@ -188,7 +188,7 @@ char *fullpathname(const char *name)
  **************************************************************************/
 
 /* 
- * Supports *at semantics if HAVE_RENAMEAT, pass dirfd=-1 to ignore this
+ * Supports *at semantics if HAVE_ATFUNCS, pass dirfd=-1 to ignore this
  */
 int copy_file(int dirfd, const char *src, const char *dst, mode_t mode)
 {
@@ -199,9 +199,9 @@ int copy_file(int dirfd, const char *src, const char *dst, mode_t mode)
     size_t  buflen;
     char   filebuf[8192];
 
-#ifdef HAVE_RENAMEAT
+#ifdef HAVE_ATFUNCS
     if (dirfd == -1)
-        dirfd = ATFD_CWD;
+        dirfd = AT_FDCWD;
     sfd = openat(dirfd, src, O_RDONLY);
 #else
     sfd = open(src, O_RDONLY);
@@ -267,7 +267,7 @@ exit:
  */
 int netatalk_unlinkat(int dirfd, const char *name)
 {
-#ifdef HAVE_RENAMEAT
+#ifdef HAVE_ATFUNCS
     if (dirfd == -1)
         dirfd = AT_FDCWD;
 
@@ -296,17 +296,17 @@ int netatalk_unlinkat(int dirfd, const char *name)
 /*
  * @brief This is equivalent of unix rename()
  *
- * unix_rename mulitplexes rename and renameat. If we dont HAVE_RENAMEAT, sfd and dfd
+ * unix_rename mulitplexes rename and renameat. If we dont HAVE_ATFUNCS, sfd and dfd
  * are ignored.
  *
- * @param sfd        (r) if we HAVE_RENAMEAT, -1 gives AT_FDCWD
+ * @param sfd        (r) if we HAVE_ATFUNCS, -1 gives AT_FDCWD
  * @param oldpath    (r) guess what
  * @param dfd        (r) same as sfd
  * @param newpath    (r) guess what
  */
 int unix_rename(int sfd, const char *oldpath, int dfd, const char *newpath)
 {
-#ifdef HAVE_RENAMEAT
+#ifdef HAVE_ATFUNCS
     if (sfd == -1)
         sfd = AT_FDCWD;
     if (dfd == -1)
@@ -317,7 +317,7 @@ int unix_rename(int sfd, const char *oldpath, int dfd, const char *newpath)
 #else
     if (rename(oldpath, newpath) < 0)
         return -1;
-#endif  /* HAVE_RENAMEAT */
+#endif  /* HAVE_ATFUNCS */
 
     return 0;
 }
@@ -325,15 +325,15 @@ int unix_rename(int sfd, const char *oldpath, int dfd, const char *newpath)
 /* 
  * @brief stat/fsstatat multiplexer
  *
- * statat mulitplexes stat and fstatat. If we dont HAVE_RENAMEAT, dirfd is ignored.
+ * statat mulitplexes stat and fstatat. If we dont HAVE_ATFUNCS, dirfd is ignored.
  *
- * @param dirfd   (r) Only used if HAVE_RENAMEAT, ignored else, -1 gives AT_FDCWD
+ * @param dirfd   (r) Only used if HAVE_ATFUNCS, ignored else, -1 gives AT_FDCWD
  * @param path    (r) pathname
  * @param st      (rw) pointer to struct stat
  */
 int statat(int dirfd, const char *path, struct stat *st)
 {
-#ifdef HAVE_RENAMEAT
+#ifdef HAVE_ATFUNCS
     if (dirfd == -1)
         dirfd = AT_FDCWD;
     return (fstatat(dirfd, path, st, 0));
@@ -348,15 +348,15 @@ int statat(int dirfd, const char *path, struct stat *st)
 /* 
  * @brief lstat/fsstatat multiplexer
  *
- * lstatat mulitplexes lstat and fstatat. If we dont HAVE_RENAMEAT, dirfd is ignored.
+ * lstatat mulitplexes lstat and fstatat. If we dont HAVE_ATFUNCS, dirfd is ignored.
  *
- * @param dirfd   (r) Only used if HAVE_RENAMEAT, ignored else, -1 gives AT_FDCWD
+ * @param dirfd   (r) Only used if HAVE_ATFUNCS, ignored else, -1 gives AT_FDCWD
  * @param path    (r) pathname
  * @param st      (rw) pointer to struct stat
  */
 int lstatat(int dirfd, const char *path, struct stat *st)
 {
-#ifdef HAVE_RENAMEAT
+#ifdef HAVE_ATFUNCS
     if (dirfd == -1)
         dirfd = AT_FDCWD;
     return (fstatat(dirfd, path, st, AT_SYMLINK_NOFOLLOW));