r12311: Reformatting
[kai/samba.git] / source3 / smbd / trans2.c
index 522d3c0f54c576900917304a39ba29307d1c03f8..6a4b7111cdb5a5aeba727573f5af7dd222f0276d 100644 (file)
@@ -4,6 +4,7 @@
    Copyright (C) Jeremy Allison                        1994-2003
    Copyright (C) Stefan (metze) Metzmacher     2003
    Copyright (C) Volker Lendecke               2005
+   Copyright (C) Steve French                  2005
 
    Extensively modified by Andrew Tridgell, 1995
 
@@ -27,7 +28,6 @@
 extern int max_send;
 extern enum protocol_types Protocol;
 extern int smb_read_error;
-extern int global_oplock_break;
 extern uint32 global_client_caps;
 extern struct current_user current_user;
 
@@ -135,7 +135,7 @@ static BOOL get_ea_value(TALLOC_CTX *mem_ctx, connection_struct *conn, files_str
                return False;
        }
 
-       DEBUG(10,("get_ea_value: EA %s is of length %d: ", ea_name, sizeret));
+       DEBUG(10,("get_ea_value: EA %s is of length %u: ", ea_name, (unsigned int)sizeret));
        dump_data(10, val, sizeret);
 
        pea->flags = 0;
@@ -188,7 +188,7 @@ static struct ea_list *get_ea_list_from_file(TALLOC_CTX *mem_ctx, connection_str
        if (sizeret == -1)
                return NULL;
 
-       DEBUG(10,("get_ea_list_from_file: ea_namelist size = %d\n", sizeret ));
+       DEBUG(10,("get_ea_list_from_file: ea_namelist size = %u\n", (unsigned int)sizeret ));
 
        if (sizeret) {
                for (p = ea_namelist; p - ea_namelist < sizeret; p += strlen(p) + 1) {
@@ -210,7 +210,7 @@ static struct ea_list *get_ea_list_from_file(TALLOC_CTX *mem_ctx, connection_str
                                push_ascii_fstring(dos_ea_name, listp->ea.name);
                                *pea_total_len += 4 + strlen(dos_ea_name) + 1 + listp->ea.value.length;
                                DEBUG(10,("get_ea_list_from_file: total_len = %u, %s, val len = %u\n",
-                                       *pea_total_len, dos_ea_name,
+                                       (unsigned int)*pea_total_len, dos_ea_name,
                                        (unsigned int)listp->ea.value.length ));
                        }
                        DLIST_ADD_END(ea_list_head, listp, tmp);
@@ -221,7 +221,7 @@ static struct ea_list *get_ea_list_from_file(TALLOC_CTX *mem_ctx, connection_str
                }
        }
 
-       DEBUG(10,("get_ea_list_from_file: total_len = %u\n", *pea_total_len));
+       DEBUG(10,("get_ea_list_from_file: total_len = %u\n", (unsigned int)*pea_total_len));
        return ea_list_head;
 }
 
@@ -329,7 +329,7 @@ NTSTATUS set_ea(connection_struct *conn, files_struct *fsp, const char *fname, s
 
                canonicalize_ea_name(conn, fsp, fname, unix_ea_name);
 
-               DEBUG(10,("set_ea: ea_name %s ealen = %u\n", unix_ea_name, ea_list->ea.value.length));
+               DEBUG(10,("set_ea: ea_name %s ealen = %u\n", unix_ea_name, (unsigned int)ea_list->ea.value.length));
 
                if (samba_private_attr_name(unix_ea_name)) {
                        DEBUG(10,("set_ea: ea name %s is a private Samba name.\n", unix_ea_name));
@@ -775,7 +775,7 @@ static int call_trans2open(connection_struct *conn, char *inbuf, char *outbuf, i
                return(ERROR_DOS(ERRSRV,ERRaccess));
        }
 
-       srvstr_get_path(inbuf, fname, pname, sizeof(fname), -1, STR_TERMINATE, &status, False);
+       srvstr_get_path(inbuf, fname, pname, sizeof(fname), -1, STR_TERMINATE, &status);
        if (!NT_STATUS_IS_OK(status)) {
                return ERROR_NT(status);
        }
@@ -804,11 +804,11 @@ static int call_trans2open(connection_struct *conn, char *inbuf, char *outbuf, i
        }
 
        /* Any data in this call is an EA list. */
-       if (total_data && !lp_ea_support(SNUM(conn))) {
+       if (total_data && (total_data != 4) && !lp_ea_support(SNUM(conn))) {
                return ERROR_NT(NT_STATUS_EAS_NOT_SUPPORTED);
        }
 
-       if (total_data) {
+       if (total_data != 4) {
                if (total_data < 10) {
                        return ERROR_NT(NT_STATUS_INVALID_PARAMETER);
                }
@@ -828,6 +828,8 @@ static int call_trans2open(connection_struct *conn, char *inbuf, char *outbuf, i
                        talloc_destroy(ctx);
                        return ERROR_NT(NT_STATUS_INVALID_PARAMETER);
                }
+       } else if (IVAL(pdata,0) != 4) {
+               return ERROR_NT(NT_STATUS_INVALID_PARAMETER);
        }
 
        fsp = open_file_ntcreate(conn,fname,&sbuf,
@@ -876,10 +878,11 @@ static int call_trans2open(connection_struct *conn, char *inbuf, char *outbuf, i
 
        SSVAL(params,0,fsp->fnum);
        SSVAL(params,2,open_attr);
-       put_dos_date2(params,4, mtime);
+       srv_put_dos_date2(params,4, mtime);
        SIVAL(params,8, (uint32)size);
-       SSVAL(params,12,open_ofun);
-       SSVAL(params,16,0); /* Padding. */
+       SSVAL(params,12,deny_mode);
+       SSVAL(params,14,0); /* open_type - file or directory. */
+       SSVAL(params,16,0); /* open_state - only valid for IPC device. */
 
        if (oplock_request && lp_fake_oplocks(SNUM(conn))) {
                smb_action |= EXTENDED_OPLOCK_GRANTED;
@@ -1122,7 +1125,7 @@ static BOOL get_lanman2_dir_entry(connection_struct *conn,
 
                                if(lp_host_msdfs() && 
                                   lp_msdfs_root(SNUM(conn)) &&
-                                  is_msdfs_link(conn, pathreal, NULL, NULL,
+                                  is_msdfs_link(NULL,conn, pathreal, NULL, NULL,
                                                 &sbuf)) {
 
                                        DEBUG(5,("get_lanman2_dir_entry: Masquerading msdfs link %s as a directory\n", pathreal));
@@ -1183,9 +1186,9 @@ static BOOL get_lanman2_dir_entry(connection_struct *conn,
                                SIVAL(p,0,reskey);
                                p += 4;
                        }
-                       put_dos_date2(p,0,cdate);
-                       put_dos_date2(p,4,adate);
-                       put_dos_date2(p,8,mdate);
+                       srv_put_dos_date2(p,0,cdate);
+                       srv_put_dos_date2(p,4,adate);
+                       srv_put_dos_date2(p,8,mdate);
                        SIVAL(p,12,(uint32)file_size);
                        SIVAL(p,16,(uint32)allocation_size);
                        SSVAL(p,20,mode);
@@ -1215,9 +1218,9 @@ static BOOL get_lanman2_dir_entry(connection_struct *conn,
                                SIVAL(p,0,reskey);
                                p += 4;
                        }
-                       put_dos_date2(p,0,cdate);
-                       put_dos_date2(p,4,adate);
-                       put_dos_date2(p,8,mdate);
+                       srv_put_dos_date2(p,0,cdate);
+                       srv_put_dos_date2(p,4,adate);
+                       srv_put_dos_date2(p,8,mdate);
                        SIVAL(p,12,(uint32)file_size);
                        SIVAL(p,16,(uint32)allocation_size);
                        SSVAL(p,20,mode);
@@ -1259,9 +1262,9 @@ static BOOL get_lanman2_dir_entry(connection_struct *conn,
                                SIVAL(p,0,reskey);
                                p += 4;
                        }
-                       put_dos_date2(p,0,cdate);
-                       put_dos_date2(p,4,adate);
-                       put_dos_date2(p,8,mdate);
+                       srv_put_dos_date2(p,0,cdate);
+                       srv_put_dos_date2(p,4,adate);
+                       srv_put_dos_date2(p,8,mdate);
                        SIVAL(p,12,(uint32)file_size);
                        SIVAL(p,16,(uint32)allocation_size);
                        SSVAL(p,20,mode);
@@ -1433,8 +1436,8 @@ static BOOL get_lanman2_dir_entry(connection_struct *conn,
                                p +=4;
                        }
                        SIVAL(p,0,0); p += 4; /* Unknown - reserved ? */
-                       SIVAL(p,0,sbuf.st_dev); p += 4;
-                       SIVAL(p,0,sbuf.st_ino); p += 4;
+                       SIVAL(p,0,sbuf.st_ino); p += 4; /* FileIndexLow */
+                       SIVAL(p,0,sbuf.st_dev); p += 4; /* FileIndexHigh */
                        len = srvstr_push(outbuf, p, fname, -1, STR_TERMINATE_ASCII);
                        SIVAL(q, 0, len);
                        p += len; 
@@ -1483,8 +1486,8 @@ static BOOL get_lanman2_dir_entry(connection_struct *conn,
                        }
                        p += 26;
                        SSVAL(p,0,0); p += 2; /* Reserved ? */
-                       SIVAL(p,0,sbuf.st_dev); p += 4;
-                       SIVAL(p,0,sbuf.st_ino); p += 4;
+                       SIVAL(p,0,sbuf.st_ino); p += 4; /* FileIndexLow */
+                       SIVAL(p,0,sbuf.st_dev); p += 4; /* FileIndexHigh */
                        len = srvstr_push(outbuf, p, fname, -1, STR_TERMINATE_ASCII);
                        SIVAL(q,0,len);
                        p += len;
@@ -1611,6 +1614,7 @@ static int call_trans2findfirst(connection_struct *conn, char *inbuf, char *outb
        BOOL out_of_space = False;
        int space_remaining;
        BOOL bad_path = False;
+       BOOL mask_contains_wcard = False;
        SMB_STRUCT_STAT sbuf;
        TALLOC_CTX *ea_ctx = NULL;
        struct ea_list *ea_list = NULL;
@@ -1651,7 +1655,7 @@ close_if_end = %d requires_resume_key = %d level = 0x%x, max_data_bytes = %d\n",
                        return(ERROR_DOS(ERRDOS,ERRunknownlevel));
        }
 
-       srvstr_get_path(inbuf, directory, params+12, sizeof(directory), -1, STR_TERMINATE, &ntstatus, True);
+       srvstr_get_path_wcard(inbuf, directory, params+12, sizeof(directory), -1, STR_TERMINATE, &ntstatus, &mask_contains_wcard);
        if (!NT_STATUS_IS_OK(ntstatus)) {
                return ERROR_NT(ntstatus);
        }
@@ -1669,10 +1673,12 @@ close_if_end = %d requires_resume_key = %d level = 0x%x, max_data_bytes = %d\n",
        p = strrchr_m(directory,'/');
        if(p == NULL) {
                /* Windows and OS/2 systems treat search on the root '\' as if it were '\*' */
-               if((directory[0] == '.') && (directory[1] == '\0'))
+               if((directory[0] == '.') && (directory[1] == '\0')) {
                        pstrcpy(mask,"*");
-               else
+                       mask_contains_wcard = True;
+               } else {
                        pstrcpy(mask,directory);
+               }
                pstrcpy(directory,"./");
        } else {
                pstrcpy(mask,p+1);
@@ -1730,7 +1736,7 @@ total_data=%u (should be %u)\n", (unsigned int)total_data, (unsigned int)IVAL(pd
        /* Save the wildcard match and attribs we are using on this directory - 
                needed as lanman2 assumes these are being saved between calls */
 
-       dptr_num = dptr_create(conn,directory, False, True ,SVAL(inbuf,smb_pid), mask, dirtype);
+       dptr_num = dptr_create(conn,directory, False, True ,SVAL(inbuf,smb_pid), mask, mask_contains_wcard, dirtype);
        if (dptr_num < 0) {
                talloc_destroy(ea_ctx);
                return(UNIXERROR(ERRDOS,ERRbadfile));
@@ -1865,6 +1871,7 @@ static int call_trans2findnext(connection_struct *conn, char *inbuf, char *outbu
        BOOL close_if_end = (findnext_flags & FLAG_TRANS2_FIND_CLOSE_IF_END);
        BOOL requires_resume_key = (findnext_flags & FLAG_TRANS2_FIND_REQUIRE_RESUME);
        BOOL continue_bit = (findnext_flags & FLAG_TRANS2_FIND_CONTINUE);
+       BOOL mask_contains_wcard = False;
        pstring resume_name;
        pstring mask;
        pstring directory;
@@ -1886,7 +1893,7 @@ static int call_trans2findnext(connection_struct *conn, char *inbuf, char *outbu
 
        *mask = *directory = *resume_name = 0;
 
-       srvstr_get_path(inbuf, resume_name, params+12, sizeof(resume_name), -1, STR_TERMINATE, &ntstatus, True);
+       srvstr_get_path_wcard(inbuf, resume_name, params+12, sizeof(resume_name), -1, STR_TERMINATE, &ntstatus, &mask_contains_wcard);
        if (!NT_STATUS_IS_OK(ntstatus)) {
                /* Win9x or OS/2 can send a resume name of ".." or ".". This will cause the parser to
                   complain (it thinks we're asking for the directory above the shared
@@ -2144,7 +2151,7 @@ static int call_trans2qfsinfo(connection_struct *conn, char *inbuf, char *outbuf
                {
                        SMB_BIG_UINT dfree,dsize,bsize,block_size,sectors_per_unit,bytes_per_sector;
                        data_len = 18;
-                       if (SMB_VFS_DISK_FREE(conn,".",False,&bsize,&dfree,&dsize) == (SMB_BIG_UINT)-1) {
+                       if (get_dfree_info(conn,".",False,&bsize,&dfree,&dsize) == (SMB_BIG_UINT)-1) {
                                return(UNIXERROR(ERRHRD,ERRgeneral));
                        }
 
@@ -2245,7 +2252,7 @@ cBytesSector=%u, cUnitTotal=%u, cUnitAvail=%d\n", (unsigned int)st.st_dev, (unsi
                {
                        SMB_BIG_UINT dfree,dsize,bsize,block_size,sectors_per_unit,bytes_per_sector;
                        data_len = 24;
-                       if (SMB_VFS_DISK_FREE(conn,".",False,&bsize,&dfree,&dsize) == (SMB_BIG_UINT)-1) {
+                       if (get_dfree_info(conn,".",False,&bsize,&dfree,&dsize) == (SMB_BIG_UINT)-1) {
                                return(UNIXERROR(ERRHRD,ERRgeneral));
                        }
                        block_size = lp_block_size(snum);
@@ -2277,7 +2284,7 @@ cBytesSector=%u, cUnitTotal=%u, cUnitAvail=%d\n", (unsigned int)bsize, (unsigned
                {
                        SMB_BIG_UINT dfree,dsize,bsize,block_size,sectors_per_unit,bytes_per_sector;
                        data_len = 32;
-                       if (SMB_VFS_DISK_FREE(conn,".",False,&bsize,&dfree,&dsize) == (SMB_BIG_UINT)-1) {
+                       if (get_dfree_info(conn,".",False,&bsize,&dfree,&dsize) == (SMB_BIG_UINT)-1) {
                                return(UNIXERROR(ERRHRD,ERRgeneral));
                        }
                        block_size = lp_block_size(snum);
@@ -2346,7 +2353,6 @@ cBytesSector=%u, cUnitTotal=%u, cUnitAvail=%d\n", (unsigned int)bsize, (unsigned
                        
                        fsp.conn = conn;
                        fsp.fnum = -1;
-                       fsp.fh->fd = -1;
                        
                        /* access check */
                        if (current_user.uid != 0) {
@@ -2404,6 +2410,38 @@ cBytesSector=%u, cUnitTotal=%u, cUnitAvail=%d\n", (unsigned int)bsize, (unsigned
                                        CIFS_UNIX_POSIX_PATHNAMES_CAP))); /* We have POSIX ACLs and pathname capability. */
                        break;
 
+               case SMB_QUERY_POSIX_FS_INFO:
+               {
+                       int rc;
+                       vfs_statvfs_struct svfs;
+
+                       if (!lp_unix_extensions())
+                               return ERROR_DOS(ERRDOS,ERRunknownlevel);
+                       
+                       rc = SMB_VFS_STATVFS(conn, ".", &svfs);
+
+                       if (!rc) {
+                               data_len = 56;
+                               SIVAL(pdata,0,svfs.OptimalTransferSize);
+                               SIVAL(pdata,4,svfs.BlockSize);
+                               SBIG_UINT(pdata,8,svfs.TotalBlocks);
+                               SBIG_UINT(pdata,16,svfs.BlocksAvail);
+                               SBIG_UINT(pdata,24,svfs.UserBlocksAvail);
+                               SBIG_UINT(pdata,32,svfs.TotalFileNodes);
+                               SBIG_UINT(pdata,40,svfs.FreeFileNodes);
+                               SBIG_UINT(pdata,48,svfs.FsIdentifier);
+                               DEBUG(5,("call_trans2qfsinfo : SMB_QUERY_POSIX_FS_INFO succsessful\n"));
+#ifdef EOPNOTSUPP
+                       } else if (rc == EOPNOTSUPP) {
+                               return ERROR_DOS(ERRDOS, ERRunknownlevel);
+#endif /* EOPNOTSUPP */
+                       } else {
+                               DEBUG(0,("vfs_statvfs() failed for service [%s]\n",lp_servicename(SNUM(conn))));
+                               return ERROR_DOS(ERRSRV,ERRerror);
+                       }
+                       break;
+               }
+
                case SMB_MAC_QUERY_FS_INFO:
                        /*
                         * Thursby MAC extension... ONLY on NTFS filesystems
@@ -2786,9 +2824,7 @@ static int call_trans2qfilepathinfo(connection_struct *conn, char *inbuf, char *
                                return set_bad_path_error(errno, bad_path, outbuf, ERRDOS,ERRbadpath);
                        }
 
-                       delete_pending =
-                               get_delete_on_close_flag(sbuf.st_dev,
-                                                        sbuf.st_ino);
+                       delete_pending = get_delete_on_close_flag(sbuf.st_dev, sbuf.st_ino);
                } else {
                        /*
                         * Original code - this is an open file.
@@ -2801,9 +2837,7 @@ static int call_trans2qfilepathinfo(connection_struct *conn, char *inbuf, char *
                                return(UNIXERROR(ERRDOS,ERRbadfid));
                        }
                        pos = fsp->fh->position_information;
-                       delete_pending = 
-                               get_delete_on_close_flag(sbuf.st_dev,
-                                                        sbuf.st_ino);
+                       delete_pending = get_delete_on_close_flag(sbuf.st_dev, sbuf.st_ino);
                        access_mask = fsp->access_mask;
                }
        } else {
@@ -2818,7 +2852,7 @@ static int call_trans2qfilepathinfo(connection_struct *conn, char *inbuf, char *
 
                DEBUG(3,("call_trans2qfilepathinfo: TRANSACT2_QPATHINFO: level = %d\n", info_level));
 
-               srvstr_get_path(inbuf, fname, &params[6], sizeof(fname), -1, STR_TERMINATE, &status, False);
+               srvstr_get_path(inbuf, fname, &params[6], sizeof(fname), -1, STR_TERMINATE, &status);
                if (!NT_STATUS_IS_OK(status)) {
                        return ERROR_NT(status);
                }
@@ -2845,8 +2879,7 @@ static int call_trans2qfilepathinfo(connection_struct *conn, char *inbuf, char *
                        return set_bad_path_error(errno, bad_path, outbuf, ERRDOS,ERRbadpath);
                }
 
-               delete_pending = get_delete_on_close_flag(sbuf.st_dev,
-                                                         sbuf.st_ino);
+               delete_pending = get_delete_on_close_flag(sbuf.st_dev, sbuf.st_ino);
                if (delete_pending) {
                        return ERROR_NT(NT_STATUS_DELETE_PENDING);
                }
@@ -2975,9 +3008,9 @@ total_data=%u (should be %u)\n", (unsigned int)total_data, (unsigned int)IVAL(pd
                case SMB_INFO_STANDARD:
                        DEBUG(10,("call_trans2qfilepathinfo: SMB_INFO_STANDARD\n"));
                        data_size = 22;
-                       put_dos_date2(pdata,l1_fdateCreation,c_time);
-                       put_dos_date2(pdata,l1_fdateLastAccess,sbuf.st_atime);
-                       put_dos_date2(pdata,l1_fdateLastWrite,sbuf.st_mtime); /* write time */
+                       srv_put_dos_date2(pdata,l1_fdateCreation,c_time);
+                       srv_put_dos_date2(pdata,l1_fdateLastAccess,sbuf.st_atime);
+                       srv_put_dos_date2(pdata,l1_fdateLastWrite,sbuf.st_mtime); /* write time */
                        SIVAL(pdata,l1_cbFile,(uint32)file_size);
                        SIVAL(pdata,l1_cbFileAlloc,(uint32)allocation_size);
                        SSVAL(pdata,l1_attrFile,mode);
@@ -2988,9 +3021,9 @@ total_data=%u (should be %u)\n", (unsigned int)total_data, (unsigned int)IVAL(pd
                        unsigned int ea_size = estimate_ea_size(conn, fsp, fname);
                        DEBUG(10,("call_trans2qfilepathinfo: SMB_INFO_QUERY_EA_SIZE\n"));
                        data_size = 26;
-                       put_dos_date2(pdata,0,c_time);
-                       put_dos_date2(pdata,4,sbuf.st_atime);
-                       put_dos_date2(pdata,8,sbuf.st_mtime); /* write time */
+                       srv_put_dos_date2(pdata,0,c_time);
+                       srv_put_dos_date2(pdata,4,sbuf.st_atime);
+                       srv_put_dos_date2(pdata,8,sbuf.st_mtime); /* write time */
                        SIVAL(pdata,12,(uint32)file_size);
                        SIVAL(pdata,16,(uint32)allocation_size);
                        SSVAL(pdata,20,mode);
@@ -3183,8 +3216,8 @@ total_data=%u (should be %u)\n", (unsigned int)total_data, (unsigned int)IVAL(pd
                           BasicFileInformationTest. -tpot */
 
                        DEBUG(10,("call_trans2qfilepathinfo: SMB_FILE_INTERNAL_INFORMATION\n"));
-                       SIVAL(pdata,0,sbuf.st_dev);
-                       SIVAL(pdata,4,sbuf.st_ino);
+                       SIVAL(pdata,4,sbuf.st_ino); /* FileIndexLow */
+                       SIVAL(pdata,0,sbuf.st_dev); /* FileIndexHigh */
                        data_size = 8;
                        break;
 
@@ -3453,91 +3486,6 @@ total_data=%u (should be %u)\n", (unsigned int)total_data, (unsigned int)IVAL(pd
        return(-1);
 }
 
-/****************************************************************************
- Deal with the internal needs of setting the delete on close flag. Note that
- as the tdb locking is recursive, it is safe to call this from within 
- open_file_shared. JRA.
-****************************************************************************/
-
-NTSTATUS can_set_delete_on_close(files_struct *fsp, BOOL delete_on_close,
-                                uint32 dosmode)
-{
-       if (!delete_on_close) {
-               return NT_STATUS_OK;
-       }
-
-       /*
-        * Only allow delete on close for writable files.
-        */
-
-       if ((dosmode & aRONLY) &&
-           !lp_delete_readonly(SNUM(fsp->conn))) {
-               DEBUG(10,("can_set_delete_on_close: file %s delete on close "
-                         "flag set but file attribute is readonly.\n",
-                         fsp->fsp_name ));
-               return NT_STATUS_CANNOT_DELETE;
-       }
-
-       /*
-        * Only allow delete on close for writable shares.
-        */
-
-       if (!CAN_WRITE(fsp->conn)) {
-               DEBUG(10,("can_set_delete_on_close: file %s delete on "
-                         "close flag set but write access denied on share.\n",
-                         fsp->fsp_name ));
-               return NT_STATUS_ACCESS_DENIED;
-       }
-
-       /*
-        * Only allow delete on close for files/directories opened with delete
-        * intent.
-        */
-
-       if (!(fsp->access_mask & DELETE_ACCESS)) {
-               DEBUG(10,("can_set_delete_on_close: file %s delete on "
-                         "close flag set but delete access denied.\n",
-                         fsp->fsp_name ));
-               return NT_STATUS_ACCESS_DENIED;
-       }
-
-       return NT_STATUS_OK;
-}
-
-/****************************************************************************
- Sets the delete on close flag over all share modes on this file.
- Modify the share mode entry for all files open
- on this device and inode to tell other smbds we have
- changed the delete on close flag. This will be noticed
- in the close code, the last closer will delete the file
- if flag is set.
-****************************************************************************/
-
-NTSTATUS set_delete_on_close(files_struct *fsp, BOOL delete_on_close)
-{
-       DEBUG(10,("set_delete_on_close: %s delete on close flag for "
-                 "fnum = %d, file %s\n",
-                 delete_on_close ? "Adding" : "Removing", fsp->fnum,
-                 fsp->fsp_name ));
-
-       if (fsp->is_directory || fsp->is_stat)
-               return NT_STATUS_OK;
-
-       if (lock_share_entry_fsp(fsp) == False)
-               return NT_STATUS_ACCESS_DENIED;
-
-       if (!modify_delete_flag(fsp->dev, fsp->inode, delete_on_close)) {
-               DEBUG(0,("set_delete_on_close: failed to change delete "
-                        "on close flag for file %s\n",
-                        fsp->fsp_name ));
-               unlock_share_entry_fsp(fsp);
-               return NT_STATUS_ACCESS_DENIED;
-       }
-
-       unlock_share_entry_fsp(fsp);
-       return NT_STATUS_OK;
-}
-
 /****************************************************************************
  Set a hard link (called by UNIX extensions and by NT rename with HARD link
  code.
@@ -3707,7 +3655,7 @@ static int call_trans2setfilepathinfo(connection_struct *conn, char *inbuf, char
                }
 
                info_level = SVAL(params,0);    
-               srvstr_get_path(inbuf, fname, &params[6], sizeof(fname), -1, STR_TERMINATE, &status, False);
+               srvstr_get_path(inbuf, fname, &params[6], sizeof(fname), -1, STR_TERMINATE, &status);
                if (!NT_STATUS_IS_OK(status)) {
                        return ERROR_NT(status);
                }
@@ -3774,9 +3722,9 @@ static int call_trans2setfilepathinfo(connection_struct *conn, char *inbuf, char
                        }
 
                        /* access time */
-                       tvs.actime = make_unix_date2(pdata+l1_fdateLastAccess);
+                       tvs.actime = srv_make_unix_date2(pdata+l1_fdateLastAccess);
                        /* write time */
-                       tvs.modtime = make_unix_date2(pdata+l1_fdateLastWrite);
+                       tvs.modtime = srv_make_unix_date2(pdata+l1_fdateLastWrite);
                        break;
                }
 
@@ -3786,6 +3734,17 @@ static int call_trans2setfilepathinfo(connection_struct *conn, char *inbuf, char
                        TALLOC_CTX *ctx = NULL;
 
                        if (total_data < 10) {
+
+                               /* OS/2 workplace shell seems to send SET_EA requests of "null"
+                                  length. They seem to have no effect. Bug #3212. JRA */
+
+                               if ((total_data == 4) && (IVAL(pdata,0) == 4)) {
+                                       /* We're done. We only get EA info in this call. */
+                                       SSVAL(params,0,0);
+                                       send_trans2_replies(outbuf, bufsize, params, 2, *ppdata, 0);
+                                       return(-1);
+                               }
+
                                return ERROR_NT(NT_STATUS_INVALID_PARAMETER);
                        }
 
@@ -3911,16 +3870,6 @@ static int call_trans2setfilepathinfo(connection_struct *conn, char *inbuf, char
                                if (fd == -1) {
                                        files_struct *new_fsp = NULL;
  
-                                       if(global_oplock_break) {
-                                               /* Queue this file modify as we are the process of an oplock break.  */
-                                               DEBUG(2,("call_trans2setfilepathinfo: queueing message due to being "));
-                                               DEBUGADD(2,( "in oplock break state.\n"));
-                                               push_oplock_pending_smb_message(inbuf, length);
-                                               return -1;
-                                       }
                                        new_fsp = open_file_ntcreate(conn, fname, &sbuf,
                                                                        FILE_WRITE_DATA,
                                                                        FILE_SHARE_READ|FILE_SHARE_WRITE,
@@ -4002,9 +3951,8 @@ static int call_trans2setfilepathinfo(connection_struct *conn, char *inbuf, char
                        }
 
                        /* The set is across all open files on this dev/inode pair. */
-                       status =set_delete_on_close(fsp, delete_on_close);
-                       if (!NT_STATUS_IS_OK(status)) {
-                               return ERROR_NT(status);
+                       if (!set_delete_on_close(fsp, delete_on_close)) {
+                               return ERROR_NT(NT_STATUS_ACCESS_DENIED);
                        }
 
                        SSVAL(params,0,0);
@@ -4265,7 +4213,7 @@ size = %.0f, uid = %u, gid = %u, raw perms = 0%o\n",
                        char *newname = fname;
 
                        /* Set a hard link. */
-                       srvstr_get_path(inbuf, oldname, pdata, sizeof(oldname), -1, STR_TERMINATE, &status, False);
+                       srvstr_get_path(inbuf, oldname, pdata, sizeof(oldname), -1, STR_TERMINATE, &status);
                        if (!NT_STATUS_IS_OK(status)) {
                                return ERROR_NT(status);
                        }
@@ -4299,7 +4247,7 @@ size = %.0f, uid = %u, gid = %u, raw perms = 0%o\n",
                        overwrite = (CVAL(pdata,0) ? True : False);
                        root_fid = IVAL(pdata,4);
                        len = IVAL(pdata,8);
-                       srvstr_get_path(inbuf, newname, &pdata[12], sizeof(newname), len, 0, &status, False);
+                       srvstr_get_path(inbuf, newname, &pdata[12], sizeof(newname), len, 0, &status);
                        if (!NT_STATUS_IS_OK(status)) {
                                return ERROR_NT(status);
                        }
@@ -4326,7 +4274,7 @@ size = %.0f, uid = %u, gid = %u, raw perms = 0%o\n",
                        } else {
                                DEBUG(10,("call_trans2setfilepathinfo: SMB_FILE_RENAME_INFORMATION %s -> %s\n",
                                        fname, newname ));
-                               status = rename_internals(conn, fname, base_name, 0, overwrite);
+                               status = rename_internals(conn, fname, base_name, 0, overwrite, False);
                        }
                        if (!NT_STATUS_IS_OK(status)) {
                                return ERROR_NT(status);
@@ -4455,16 +4403,6 @@ size = %.0f, uid = %u, gid = %u, raw perms = 0%o\n",
                if (fd == -1) {
                        files_struct *new_fsp = NULL;
 
-                       if(global_oplock_break) {
-                               /* Queue this file modify as we are the process of an oplock break.  */
-
-                               DEBUG(2,("call_trans2setfilepathinfo: queueing message due to being "));
-                               DEBUGADD(2,( "in oplock break state.\n"));
-
-                               push_oplock_pending_smb_message(inbuf, length);
-                               return -1;
-                       }
-
                        new_fsp = open_file_ntcreate(conn, fname, &sbuf,
                                                FILE_WRITE_DATA,
                                                FILE_SHARE_READ|FILE_SHARE_WRITE,
@@ -4547,7 +4485,7 @@ static int call_trans2mkdir(connection_struct *conn, char *inbuf, char *outbuf,
                return ERROR_NT(NT_STATUS_INVALID_PARAMETER);
        }
 
-       srvstr_get_path(inbuf, directory, &params[4], sizeof(directory), -1, STR_TERMINATE, &status, False);
+       srvstr_get_path(inbuf, directory, &params[4], sizeof(directory), -1, STR_TERMINATE, &status);
        if (!NT_STATUS_IS_OK(status)) {
                return ERROR_NT(status);
        }
@@ -4560,11 +4498,17 @@ static int call_trans2mkdir(connection_struct *conn, char *inbuf, char *outbuf,
        }
 
        /* Any data in this call is an EA list. */
-       if (total_data && !lp_ea_support(SNUM(conn))) {
+       if (total_data && (total_data != 4) && !lp_ea_support(SNUM(conn))) {
                return ERROR_NT(NT_STATUS_EAS_NOT_SUPPORTED);
        }
 
-       if (total_data) {
+       /*
+        * OS/2 workplace shell seems to send SET_EA requests of "null"
+        * length (4 bytes containing IVAL 4).
+        * They seem to have no effect. Bug #3212. JRA.
+        */
+
+       if (total_data != 4) {
                if (total_data < 10) {
                        return ERROR_NT(NT_STATUS_INVALID_PARAMETER);
                }
@@ -4584,6 +4528,8 @@ static int call_trans2mkdir(connection_struct *conn, char *inbuf, char *outbuf,
                        talloc_destroy(ctx);
                        return ERROR_NT(NT_STATUS_INVALID_PARAMETER);
                }
+       } else if (IVAL(pdata,0) != 4) {
+               return ERROR_NT(NT_STATUS_INVALID_PARAMETER);
        }
 
        if (check_name(directory,conn)) {
@@ -4858,18 +4804,6 @@ int reply_trans2(connection_struct *conn,
        unsigned int num_params, num_params_sofar, num_data, num_data_sofar;
        START_PROFILE(SMBtrans2);
 
-       if(global_oplock_break && (tran_call == TRANSACT2_OPEN)) {
-               /* Queue this open message as we are the process of an
-                * oplock break.  */
-
-               DEBUG(2,("reply_trans2: queueing message trans2open due to being "));
-               DEBUGADD(2,( "in oplock break state.\n"));
-
-               push_oplock_pending_smb_message(inbuf, length);
-               END_PROFILE(SMBtrans2);
-               return -1;
-       }
-       
        if (IS_IPC(conn) && (tran_call != TRANSACT2_OPEN)
             && (tran_call != TRANSACT2_GET_DFS_REFERRAL)) {
                END_PROFILE(SMBtrans2);