Introduce "struct stat_ex" as a replacement for SMB_STRUCT_STAT
[kamenim/samba.git] / source3 / modules / vfs_netatalk.c
index 6ff53760f573d9cf1ec5999897b07c38ba1259e2..ed3592235986f33e5c3a91432057183de20f5197 100644 (file)
@@ -6,7 +6,7 @@
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
+ * the Free Software Foundation; either version 3 of the License, or
  * (at your option) any later version.
  *  
  * This program is distributed in the hope that it will be useful,
@@ -15,8 +15,7 @@
  * GNU General Public License for more details.
  *  
  * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ * along with this program; if not, see <http://www.gnu.org/licenses/>.
  */
 
 #include "includes.h"
@@ -83,7 +82,7 @@ static int atalk_build_paths(TALLOC_CTX *ctx, const char *path, const char *fnam
 
        sys_lstat(*orig_path, orig_info);
 
-       if (S_ISDIR(orig_info->st_mode)) {
+       if (S_ISDIR(orig_info->st_ex_mode)) {
                *adbl_path = talloc_asprintf(ctx, "%s/%s/%s/", 
                  path, &fname[ptr0], APPLEDOUBLE);
        } else {
@@ -195,7 +194,7 @@ static SMB_STRUCT_DIR *atalk_opendir(struct vfs_handle_struct *handle, const cha
 
 static int atalk_rmdir(struct vfs_handle_struct *handle, const char *path)
 {
-       BOOL add = False;
+       bool add = False;
        TALLOC_CTX *ctx = 0;
        char *dpath;
 
@@ -243,7 +242,7 @@ static int atalk_rename(struct vfs_handle_struct *handle, const char *oldname, c
          &adbl_info, &orig_info) != 0)
                goto exit_rename;
 
-       if (S_ISDIR(orig_info.st_mode) || S_ISREG(orig_info.st_mode)) {
+       if (S_ISDIR(orig_info.st_ex_mode) || S_ISREG(orig_info.st_ex_mode)) {
                DEBUG(3, ("ATALK: %s has passed..\n", adbl_path));              
                goto exit_rename;
        }
@@ -299,7 +298,7 @@ static int atalk_unlink(struct vfs_handle_struct *handle, const char *path)
          &adbl_info, &orig_info) != 0)
                goto exit_unlink;
 
-       if (S_ISDIR(orig_info.st_mode) || S_ISREG(orig_info.st_mode)) {
+       if (S_ISDIR(orig_info.st_ex_mode) || S_ISREG(orig_info.st_ex_mode)) {
                DEBUG(3, ("ATALK: %s has passed..\n", adbl_path));
                goto exit_unlink;
        }
@@ -331,7 +330,7 @@ static int atalk_chmod(struct vfs_handle_struct *handle, const char *path, mode_
          &adbl_info, &orig_info) != 0)
                goto exit_chmod;
 
-       if (!S_ISDIR(orig_info.st_mode) && !S_ISREG(orig_info.st_mode)) {
+       if (!S_ISDIR(orig_info.st_ex_mode) && !S_ISREG(orig_info.st_ex_mode)) {
                DEBUG(3, ("ATALK: %s has passed..\n", orig_path));              
                goto exit_chmod;
        }
@@ -363,12 +362,14 @@ static int atalk_chown(struct vfs_handle_struct *handle, const char *path, uid_t
          &adbl_info, &orig_info) != 0)
                goto exit_chown;
 
-       if (!S_ISDIR(orig_info.st_mode) && !S_ISREG(orig_info.st_mode)) {
+       if (!S_ISDIR(orig_info.st_ex_mode) && !S_ISREG(orig_info.st_ex_mode)) {
                DEBUG(3, ("ATALK: %s has passed..\n", orig_path));              
                goto exit_chown;
        }
 
-       chown(adbl_path, uid, gid);
+       if (chown(adbl_path, uid, gid) == -1) {
+               DEBUG(3, ("ATALK: chown error %s\n", strerror(errno)));
+       }
 
 exit_chown:    
        talloc_destroy(ctx);
@@ -395,12 +396,14 @@ static int atalk_lchown(struct vfs_handle_struct *handle, const char *path, uid_
          &adbl_info, &orig_info) != 0)
                goto exit_lchown;
 
-       if (!S_ISDIR(orig_info.st_mode) && !S_ISREG(orig_info.st_mode)) {
+       if (!S_ISDIR(orig_info.st_ex_mode) && !S_ISREG(orig_info.st_ex_mode)) {
                DEBUG(3, ("ATALK: %s has passed..\n", orig_path));              
                goto exit_lchown;
        }
 
-       sys_lchown(adbl_path, uid, gid);
+       if (lchown(adbl_path, uid, gid) == -1) {
+               DEBUG(3, ("ATALK: lchown error %s\n", strerror(errno)));
+       }
 
 exit_lchown:   
        talloc_destroy(ctx);