diff options
author | Jeremy Allison <jra@samba.org> | 1999-06-29 16:43:20 +0000 |
---|---|---|
committer | Jeremy Allison <jra@samba.org> | 1999-06-29 16:43:20 +0000 |
commit | ac32673a424043641bd6b83fe47209d1ab466759 (patch) | |
tree | fadf781a1925c6938890062a6132bed7dde43bce | |
parent | 2cf4484abb6e461a9858a80988dd317e479bdade (diff) | |
download | samba-ac32673a424043641bd6b83fe47209d1ab466759.tar.gz |
Fix for directory copies on Win2k.
typo in oplock.c spotted by J.F.
Jeremy.
-rw-r--r-- | source/smbd/open.c | 53 | ||||
-rw-r--r-- | source/smbd/oplock.c | 2 |
2 files changed, 39 insertions, 16 deletions
diff --git a/source/smbd/open.c b/source/smbd/open.c index 749a8e470b6..67a8f22b35d 100644 --- a/source/smbd/open.c +++ b/source/smbd/open.c @@ -1130,25 +1130,48 @@ int open_directory(files_struct *fsp,connection_struct *conn, { extern struct current_user current_user; SMB_STRUCT_STAT st; + BOOL got_stat = False; - if (smb_ofun & 0x10) { - /* - * Create the directory. - */ + if(dos_stat(fname, &st) == 0) { + got_stat = True; + } - if(dos_mkdir(fname, unix_mode(conn,aDIR)) < 0) { - DEBUG(0,("open_directory: unable to create %s. Error was %s\n", - fname, strerror(errno) )); - return -1; - } + if (got_stat && (GET_FILE_OPEN_DISPOSITION(smb_ofun) == FILE_EXISTS_FAIL)) { + errno = EEXIST; + return -1; + } + + if (GET_FILE_CREATE_DISPOSITION(smb_ofun) == FILE_CREATE_IF_NOT_EXIST) { + + if (got_stat) { - *action = FILE_WAS_CREATED; + if(!S_ISDIR(st.st_mode)) { + DEBUG(0,("open_directory: %s is not a directory !\n", fname )); + return -1; + } + *action = FILE_WAS_OPENED; + + } else { + + /* + * Try and create the directory. + */ + + if(dos_mkdir(fname, unix_mode(conn,aDIR)) < 0) { + DEBUG(0,("open_directory: unable to create %s. Error was %s\n", + fname, strerror(errno) )); + return -1; + } + *action = FILE_WAS_CREATED; + + } } else { + /* - * Check that it *was* a directory. + * Don't create - just check that it *was* a directory. */ - if(dos_stat(fname, &st) < 0) { + if(!got_stat) { DEBUG(0,("open_directory: unable to stat name = %s. Error was %s\n", fname, strerror(errno) )); return -1; @@ -1158,6 +1181,7 @@ int open_directory(files_struct *fsp,connection_struct *conn, DEBUG(0,("open_directory: %s is not a directory !\n", fname )); return -1; } + *action = FILE_WAS_OPENED; } @@ -1202,10 +1226,9 @@ int open_directory(files_struct *fsp,connection_struct *conn, return 0; } - /******************************************************************* -check if the share mode on a file allows it to be deleted or unlinked -return True if sharing doesn't prevent the operation + Check if the share mode on a file allows it to be deleted or unlinked. + Return True if sharing doesn't prevent the operation. ********************************************************************/ BOOL check_file_sharing(connection_struct *conn,char *fname, BOOL rename_op) diff --git a/source/smbd/oplock.c b/source/smbd/oplock.c index db8e7984464..e74c3ca431d 100644 --- a/source/smbd/oplock.c +++ b/source/smbd/oplock.c @@ -205,7 +205,7 @@ Error was %s.\n", strerror(errno) )); } dev = (SMB_DEV_T)os.os_dev; - inode = (SMB_DEV_T)os.os_ino; + inode = (SMB_INO_T)os.os_ino; DEBUG(5,("receive_local_message: kernel oplock break request received for \ dev = %x, inode = %.0f\n", (unsigned int)dev, (double)inode )); |