X-Git-Url: http://git.samba.org/?a=blobdiff_plain;f=source3%2Fmodules%2Fonefs_system.c;h=07272cc86b5ffc9e9bf5d223079aceba224fbcab;hb=bfe4a2baeec6bc4558a617ec67532ea11f865861;hp=d2f853f9ee9edeaf6159289b815a32af7756f3bb;hpb=ba95882155db4f8c10725f47f70ae482d5343f9a;p=samba.git diff --git a/source3/modules/onefs_system.c b/source3/modules/onefs_system.c index d2f853f9ee9..07272cc86b5 100644 --- a/source3/modules/onefs_system.c +++ b/source3/modules/onefs_system.c @@ -19,6 +19,7 @@ */ #include "includes.h" +#include "smbd/smbd.h" #include "onefs.h" #include "onefs_config.h" #include "oplock_onefs.h" @@ -98,9 +99,23 @@ int onefs_sys_create_file(connection_struct *conn, int ret_fd = -1; uint32_t onefs_dos_attributes; struct ifs_createfile_flags cf_flags = CF_FLAGS_NONE; + char *mapped_name = NULL; + NTSTATUS result; START_PROFILE(syscall_createfile); + /* Translate the name to UNIX before calling ifs_createfile */ + mapped_name = talloc_strdup(talloc_tos(), path); + if (mapped_name == NULL) { + errno = ENOMEM; + goto out; + } + result = SMB_VFS_TRANSLATE_NAME(conn, &mapped_name, + vfs_translate_to_unix); + if (!NT_STATUS_IS_OK(result)) { + goto out; + } + /* Setup security descriptor and get secinfo. */ if (sd != NULL) { NTSTATUS status; @@ -148,7 +163,7 @@ int onefs_sys_create_file(connection_struct *conn, PARM_ALLOW_EXECUTE_ALWAYS_DEFAULT) && (open_access_mask & FILE_EXECUTE)) { - DEBUG(3, ("Stripping execute bit from %s: (0x%x)\n", path, + DEBUG(3, ("Stripping execute bit from %s: (0x%x)\n", mapped_name, open_access_mask)); /* Strip execute. */ @@ -164,31 +179,31 @@ int onefs_sys_create_file(connection_struct *conn, open_access_mask)); } - DEBUG(10,("onefs_sys_create_file: base_fd = %d, fname = %s" + DEBUG(10,("onefs_sys_create_file: base_fd = %d, fname = %s " "open_access_mask = 0x%x, flags = 0x%x, mode = 0%o, " "desired_oplock = %s, id = 0x%x, secinfo = 0x%x, sd = %p, " "dos_attributes = 0x%x, path = %s, " - "default_acl=%s\n", base_fd, path, + "default_acl=%s\n", base_fd, mapped_name, (unsigned int)open_access_mask, (unsigned int)flags, (unsigned int)mode, onefs_oplock_str(onefs_oplock), (unsigned int)id, sec_info_effective, sd, - (unsigned int)onefs_dos_attributes, path, + (unsigned int)onefs_dos_attributes, mapped_name, cf_flags_and_bool(cf_flags, CF_FLAGS_DEFAULT_ACL) ? "true" : "false")); /* Initialize smlock struct for files/dirs but not internal opens */ if (!(oplock_request & INTERNAL_OPEN_ONLY)) { - smlock_init(conn, &sml, is_executable(path), access_mask, + smlock_init(conn, &sml, is_executable(mapped_name), access_mask, share_access, create_options); psml = &sml; } smlock_dump(10, psml); - ret_fd = ifs_createfile(base_fd, path, + ret_fd = ifs_createfile(base_fd, mapped_name, (enum ifs_ace_rights)open_access_mask, flags & ~O_ACCMODE, mode, onefs_oplock, id, psml, sec_info_effective, pifs_sd, onefs_dos_attributes, cf_flags, &onefs_granted_oplock); @@ -206,6 +221,7 @@ int onefs_sys_create_file(connection_struct *conn, out: END_PROFILE(syscall_createfile); aclu_free_sd(pifs_sd, false); + TALLOC_FREE(mapped_name); return ret_fd; } @@ -214,7 +230,7 @@ int onefs_sys_create_file(connection_struct *conn, * FreeBSD based sendfile implementation that allows for atomic semantics. */ static ssize_t onefs_sys_do_sendfile(int tofd, int fromfd, - const DATA_BLOB *header, SMB_OFF_T offset, size_t count, bool atomic) + const DATA_BLOB *header, off_t offset, size_t count, bool atomic) { size_t total=0; struct sf_hdtr hdr; @@ -242,7 +258,7 @@ static ssize_t onefs_sys_do_sendfile(int tofd, int fromfd, total = count; while (total + hdtrl.iov_len) { - SMB_OFF_T nwritten; + off_t nwritten; int ret; /* @@ -254,7 +270,11 @@ static ssize_t onefs_sys_do_sendfile(int tofd, int fromfd, do { ret = sendfile(fromfd, tofd, offset, total, &hdr, &nwritten, flags); - } while (ret == -1 && errno == EINTR); +#if defined(EWOULDBLOCK) + } while (ret == -1 && (errno == EINTR || errno == EAGAIN || errno == EWOULDBLOCK)); +#else + } while (ret == -1 && (errno == EINTR || errno == EAGAIN)); +#endif /* On error we're done. */ if (ret == -1) { @@ -310,7 +330,7 @@ static ssize_t onefs_sys_do_sendfile(int tofd, int fromfd, * Handles the subtleties of using sendfile with CIFS. */ ssize_t onefs_sys_sendfile(connection_struct *conn, int tofd, int fromfd, - const DATA_BLOB *header, SMB_OFF_T offset, + const DATA_BLOB *header, off_t offset, size_t count) { bool atomic = false; @@ -516,7 +536,7 @@ static char *get_spill_buffer(size_t new_count) * from the socket into the buffer, the spill buffer is then written with a * standard pwrite. */ -ssize_t onefs_sys_recvfile(int fromfd, int tofd, SMB_OFF_T offset, +ssize_t onefs_sys_recvfile(int fromfd, int tofd, off_t offset, size_t count) { char *spill_buffer = NULL;