r20612: A checkin I've wanted to do for ages: For bad_path==False set_bad_path_error
authorVolker Lendecke <vlendec@samba.org>
Mon, 8 Jan 2007 15:36:33 +0000 (15:36 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 17:16:58 +0000 (12:16 -0500)
is equivalent to UNIX_ERROR. Expand the last reference. Lets see if I can kill
that as well :-)

Volker
(This used to be commit 794d5d38f19601bb5b30b965b41b844aacf1caeb)

source3/smbd/nttrans.c
source3/smbd/reply.c
source3/smbd/trans2.c

index da24e4084d929a2a1a5e7a7f1b5f3a89709faab9..f62f5881b380f89ed7548559f74d6534c4781879 100644 (file)
@@ -639,8 +639,7 @@ int reply_ntcreate_and_X(connection_struct *conn,
        if (!check_name(fname,conn)) {
                restore_case_semantics(conn, file_attributes);
                END_PROFILE(SMBntcreateX);
-               return set_bad_path_error(errno, False, outbuf,
-                                         ERRDOS,ERRbadpath);
+               return UNIXERROR(ERRDOS, ERRbadpath);
        }
 
 #if 0
@@ -1266,7 +1265,7 @@ static int call_nt_transact_create(connection_struct *conn, char *inbuf, char *o
        /* All file access must go through check_name() */
        if (!check_name(fname,conn)) {
                restore_case_semantics(conn, file_attributes);
-               return set_bad_path_error(errno, False, outbuf, ERRDOS,ERRbadpath);
+               return UNIXERROR(ERRDOS, ERRbadpath);
        }
     
 #if 0
index 63a1889390ab4408e88db2542f37fcdfb689a944..ac0663d23813e3b8762677cb1276ec23d6874e55 100644 (file)
@@ -948,8 +948,7 @@ int reply_getatr(connection_struct *conn, char *inbuf,char *outbuf, int dum_size
   
        if (!ok) {
                END_PROFILE(SMBgetatr);
-               return set_bad_path_error(errno, False, outbuf,
-                                         ERRDOS,ERRbadfile);
+               return UNIXERROR(ERRDOS, ERRbadfile);
        }
  
        outsize = set_message(outbuf,10,0,True);
@@ -1024,15 +1023,13 @@ int reply_setatr(connection_struct *conn, char *inbuf,char *outbuf, int dum_size
 
                if (file_set_dosmode(conn,fname,mode,&sbuf,False) != 0) {
                        END_PROFILE(SMBsetatr);
-                       return set_bad_path_error(errno, False, outbuf,
-                                                 ERRDOS, ERRnoaccess);
+                       return UNIXERROR(ERRDOS, ERRnoaccess);
                }
        }
 
        if (!set_filetime(conn,fname,mtime)) {
                END_PROFILE(SMBsetatr);
-               return set_bad_path_error(errno, False, outbuf,
-                                         ERRDOS, ERRnoaccess);
+               return UNIXERROR(ERRDOS, ERRnoaccess);
        }
  
        outsize = set_message(outbuf,0,0,False);
@@ -1212,7 +1209,10 @@ int reply_search(connection_struct *conn, char *inbuf,char *outbuf, int dum_size
                        if (dptr_num < 0) {
                                if(dptr_num == -2) {
                                        END_PROFILE(SMBsearch);
-                                       return set_bad_path_error(errno, bad_path, outbuf, ERRDOS, ERRnofids);
+                                       if ((errno == ENOENT) && bad_path) {
+                                               return ERROR_NT(NT_STATUS_OBJECT_PATH_NOT_FOUND);
+                                       }
+                                       return UNIXERROR(ERRDOS, ERRnofids);
                                }
                                END_PROFILE(SMBsearch);
                                return ERROR_DOS(ERRDOS,ERRnofids);
@@ -4007,8 +4007,7 @@ int reply_rmdir(connection_struct *conn, char *inbuf,char *outbuf, int dum_size,
   
        if (!ok) {
                END_PROFILE(SMBrmdir);
-               return set_bad_path_error(errno, False, outbuf,
-                                         ERRDOS, ERRbadpath);
+               return UNIXERROR(ERRDOS, ERRbadpath);
        }
  
        outsize = set_message(outbuf,0,0,False);
index 7d25b09e1f320383bc280104005bae9e5ea34fbf..40394c3d8af7e78b1838a7c94fa0af4dce77c3de 100644 (file)
@@ -807,8 +807,7 @@ static int call_trans2open(connection_struct *conn, char *inbuf, char *outbuf, i
        }
     
        if (!check_name(fname,conn)) {
-               return set_bad_path_error(errno, False, outbuf,
-                                         ERRDOS, ERRnoaccess);
+               return UNIXERROR(ERRDOS, ERRnoaccess);
        }
 
        if (open_ofun == 0) {
@@ -1726,8 +1725,7 @@ close_if_end = %d requires_resume_key = %d level = 0x%x, max_data_bytes = %d\n",
                return ERROR_NT(NT_STATUS_OBJECT_PATH_NOT_FOUND);
        }
        if(!check_name(directory,conn)) {
-               return set_bad_path_error(errno, False, outbuf,
-                                         ERRDOS,ERRbadpath);
+               return UNIXERROR(ERRDOS, ERRbadpath);
        }
 
        p = strrchr_m(directory,'/');
@@ -2704,21 +2702,6 @@ cap_low = 0x%x, cap_high = 0x%x\n",
        return outsize;
 }
 
-/****************************************************************************
- Utility function to set bad path error.
-****************************************************************************/
-
-int set_bad_path_error(int err, BOOL bad_path, char *outbuf, int def_class, uint32 def_code)
-{
-       DEBUG(10,("set_bad_path_error: err = %d bad_path = %d\n",
-                       err, (int)bad_path ));
-
-       if ((err == ENOENT) && bad_path) {
-               return ERROR_NT(NT_STATUS_OBJECT_PATH_NOT_FOUND);
-       }
-       return UNIXERROR(def_class,def_code);
-}
-
 #if defined(HAVE_POSIX_ACLS)
 /****************************************************************************
  Utility function to count the number of entries in a POSIX acl.
@@ -2908,14 +2891,11 @@ static int call_trans2qfilepathinfo(connection_struct *conn, char *inbuf, char *
                                /* Always do lstat for UNIX calls. */
                                if (SMB_VFS_LSTAT(conn,fname,&sbuf)) {
                                        DEBUG(3,("call_trans2qfilepathinfo: SMB_VFS_LSTAT of %s failed (%s)\n",fname,strerror(errno)));
-                                       return set_bad_path_error(
-                                               errno, False, outbuf,
-                                               ERRDOS,ERRbadpath);
+                                       return UNIXERROR(ERRDOS, ERRbadpath);
                                }
                        } else if (SMB_VFS_STAT(conn,fname,&sbuf)) {
                                DEBUG(3,("call_trans2qfilepathinfo: SMB_VFS_STAT of %s failed (%s)\n",fname,strerror(errno)));
-                               return set_bad_path_error(errno, False, outbuf,
-                                                         ERRDOS,ERRbadpath);
+                               return UNIXERROR(ERRDOS, ERRbadpath);
                        }
 
                        delete_pending = get_delete_on_close_flag(sbuf.st_dev, sbuf.st_ino);
@@ -2959,21 +2939,18 @@ static int call_trans2qfilepathinfo(connection_struct *conn, char *inbuf, char *
                }
                if (!check_name(fname,conn)) {
                        DEBUG(3,("call_trans2qfilepathinfo: fileinfo of %s failed (%s)\n",fname,strerror(errno)));
-                       return set_bad_path_error(errno, False, outbuf,
-                                                 ERRDOS,ERRbadpath);
+                       return UNIXERROR(ERRDOS, ERRbadpath);
                }
 
                if (INFO_LEVEL_IS_UNIX(info_level)) {
                        /* Always do lstat for UNIX calls. */
                        if (SMB_VFS_LSTAT(conn,fname,&sbuf)) {
                                DEBUG(3,("call_trans2qfilepathinfo: SMB_VFS_LSTAT of %s failed (%s)\n",fname,strerror(errno)));
-                               return set_bad_path_error(errno, False, outbuf,
-                                                         ERRDOS,ERRbadpath);
+                               return UNIXERROR(ERRDOS, ERRbadpath);
                        }
                } else if (!VALID_STAT(sbuf) && SMB_VFS_STAT(conn,fname,&sbuf) && (info_level != SMB_INFO_IS_NAME_VALID)) {
                        DEBUG(3,("call_trans2qfilepathinfo: SMB_VFS_STAT of %s failed (%s)\n",fname,strerror(errno)));
-                       return set_bad_path_error(errno, False, outbuf,
-                                                 ERRDOS,ERRbadpath);
+                       return UNIXERROR(ERRDOS, ERRbadpath);
                }
 
                delete_pending = get_delete_on_close_flag(sbuf.st_dev, sbuf.st_ino);
@@ -3819,8 +3796,7 @@ static int call_trans2setfilepathinfo(connection_struct *conn, char *inbuf, char
                        pstrcpy(fname, fsp->fsp_name);
                        if (SMB_VFS_STAT(conn,fname,&sbuf) != 0) {
                                DEBUG(3,("call_trans2setfilepathinfo: fileinfo of %s failed (%s)\n",fname,strerror(errno)));
-                               return set_bad_path_error(errno, False, outbuf,
-                                                         ERRDOS,ERRbadpath);
+                               return UNIXERROR(ERRDOS, ERRbadpath);
                        }
                } else if (fsp && fsp->print_file) {
                        /*
@@ -3872,13 +3848,11 @@ static int call_trans2setfilepathinfo(connection_struct *conn, char *inbuf, char
 
                if(!VALID_STAT(sbuf) && !INFO_LEVEL_IS_UNIX(info_level)) {
                        DEBUG(3,("call_trans2setfilepathinfo: stat of %s failed (%s)\n", fname, strerror(errno)));
-                       return set_bad_path_error(errno, False, outbuf,
-                                                 ERRDOS,ERRbadpath);
+                       return UNIXERROR(ERRDOS, ERRbadpath);
                }    
 
                if(!check_name(fname, conn)) {
-                       return set_bad_path_error(errno, False, outbuf,
-                                                 ERRDOS,ERRbadpath);
+                       return UNIXERROR(ERRDOS, ERRbadpath);
                }
 
        }
@@ -4871,8 +4845,7 @@ static int call_trans2mkdir(connection_struct *conn, char *inbuf, char *outbuf,
 
        if (!check_name(directory,conn)) {
                DEBUG(5,("call_trans2mkdir error (%s)\n", strerror(errno)));
-               return set_bad_path_error(errno, False, outbuf, ERRDOS,
-                                         ERRnoaccess);
+               return UNIXERROR(ERRDOS, ERRnoaccess);
        }
 
        status = create_directory(conn, directory);