s3 onefs: Add missing newlines to debug statements in the onefs module
[ira/wip.git] / source3 / modules / onefs_open.c
index 1f5f8551ffb0e1196c70841d4a9e4aaad6417f59..d628443ef90e113f50f0db3104a01815c29c5fe5 100644 (file)
  * along with this program; if not, see <http://www.gnu.org/licenses/>.
  */
 
+#include "includes.h"
 #include "onefs.h"
+#include "onefs_config.h"
+#include "oplock_onefs.h"
 #include "smbd/globals.h"
 
 extern const struct generic_mapping file_generic_mapping;
@@ -193,7 +196,7 @@ static NTSTATUS onefs_open_file(files_struct *fsp,
                                                      &base, &stream);
        }
        /* It's a stream, so pass in the base_fd */
-       if (stream != NULL) {
+       if ((conn->fs_capabilities & FILE_NAMED_STREAMS) && stream != NULL) {
                SMB_ASSERT(fsp->base_fsp);
 
                /*
@@ -204,15 +207,16 @@ static NTSTATUS onefs_open_file(files_struct *fsp,
                 */
                if ((oplock_request & ~SAMBA_PRIVATE_OPLOCK_MASK) !=
                     NO_OPLOCK) {
-                       DEBUG(0,("Oplock(%d) being requested on a stream! "
-                               "Ignoring oplock request: base=%s, stream=%s",
-                               oplock_request & ~SAMBA_PRIVATE_OPLOCK_MASK,
-                               base, stream));
+                       DEBUG(0, ("Oplock(%d) being requested on a stream! "
+                                 "Ignoring oplock request: base=%s, "
+                                 "stream=%s\n",
+                                 oplock_request & ~SAMBA_PRIVATE_OPLOCK_MASK,
+                                 base, stream));
                        /* Recover by requesting NO_OPLOCK instead. */
                        oplock_request &= SAMBA_PRIVATE_OPLOCK_MASK;
                }
 
-               DEBUG(10,("Opening a stream: base=%s(%d), stream=%s",
+               DEBUG(10,("Opening a stream: base=%s(%d), stream=%s\n",
                          base, fsp->base_fsp->fh->fd, stream));
 
                base_fd = fsp->base_fsp->fh->fd;
@@ -383,15 +387,6 @@ static void defer_open(struct share_mode_lock *lck,
                exit_server("push_deferred_smb_message failed");
        }
        add_deferred_open(lck, req->mid, request_time, state->id);
-
-       /*
-        * Push the MID of this packet on the signing queue.
-        * We only do this once, the first time we push the packet
-        * onto the deferred open queue, as this has a side effect
-        * of incrementing the response sequence number.
-        */
-
-       srv_defer_sign_response(req->mid);
 }
 
 static void schedule_defer_open(struct share_mode_lock *lck,
@@ -1185,7 +1180,7 @@ NTSTATUS onefs_open_file_ntcreate(connection_struct *conn,
        SMB_ASSERT(lck != NULL);
 
        /* Delete streams if create_disposition requires it */
-       if (file_existed && clear_ads) {
+       if (file_existed && clear_ads && !is_ntfs_stream_name(fname)) {
                status = delete_all_streams(conn, fname);
                if (!NT_STATUS_IS_OK(status)) {
                        TALLOC_FREE(lck);
@@ -1645,119 +1640,6 @@ static NTSTATUS onefs_open_directory(connection_struct *conn,
        return NT_STATUS_OK;
 }
 
-/*
- * If a main file is opened for delete, all streams need to be checked for
- * !FILE_SHARE_DELETE. Do this by opening with DELETE_ACCESS.
- * If that works, delete them all by setting the delete on close and close.
- */
-
-static NTSTATUS open_streams_for_delete(connection_struct *conn,
-                                       const char *fname)
-{
-       struct stream_struct *stream_info;
-       files_struct **streams;
-       int i;
-       unsigned int num_streams;
-       TALLOC_CTX *frame = talloc_stackframe();
-       NTSTATUS status;
-
-       status = SMB_VFS_STREAMINFO(conn, NULL, fname, talloc_tos(),
-                                   &num_streams, &stream_info);
-
-       if (NT_STATUS_EQUAL(status, NT_STATUS_NOT_IMPLEMENTED)
-           || NT_STATUS_EQUAL(status, NT_STATUS_OBJECT_NAME_NOT_FOUND)) {
-               DEBUG(10, ("no streams around\n"));
-               TALLOC_FREE(frame);
-               return NT_STATUS_OK;
-       }
-
-       if (!NT_STATUS_IS_OK(status)) {
-               DEBUG(10, ("SMB_VFS_STREAMINFO failed: %s\n",
-                          nt_errstr(status)));
-               goto fail;
-       }
-
-       DEBUG(10, ("open_streams_for_delete found %d streams\n",
-                  num_streams));
-
-       if (num_streams == 0) {
-               TALLOC_FREE(frame);
-               return NT_STATUS_OK;
-       }
-
-       streams = TALLOC_ARRAY(talloc_tos(), files_struct *, num_streams);
-       if (streams == NULL) {
-               DEBUG(0, ("talloc failed\n"));
-               status = NT_STATUS_NO_MEMORY;
-               goto fail;
-       }
-
-       /* Open the base file */
-
-       for (i=0; i<num_streams; i++) {
-               char *streamname;
-
-               if (strequal(stream_info[i].name, "::$DATA")) {
-                       streams[i] = NULL;
-                       continue;
-               }
-
-               streamname = talloc_asprintf(talloc_tos(), "%s%s", fname,
-                                            stream_info[i].name);
-
-               if (streamname == NULL) {
-                       DEBUG(0, ("talloc_aprintf failed\n"));
-                       status = NT_STATUS_NO_MEMORY;
-                       goto fail;
-               }
-
-               status = onefs_create_file_unixpath
-                       (conn,                  /* conn */
-                        NULL,                  /* req */
-                        streamname,            /* fname */
-                        DELETE_ACCESS,         /* access_mask */
-                        FILE_SHARE_READ | FILE_SHARE_WRITE
-                        | FILE_SHARE_DELETE,   /* share_access */
-                        FILE_OPEN,             /* create_disposition*/
-                        NTCREATEX_OPTIONS_PRIVATE_STREAM_DELETE, /* create_options */
-                        FILE_ATTRIBUTE_NORMAL, /* file_attributes */
-                        0,                     /* oplock_request */
-                        0,                     /* allocation_size */
-                        NULL,                  /* sd */
-                        NULL,                  /* ea_list */
-                        &streams[i],           /* result */
-                        NULL,                  /* pinfo */
-                        NULL,                  /* fsp_data */
-                        NULL);                 /* psbuf */
-
-               TALLOC_FREE(streamname);
-
-               if (!NT_STATUS_IS_OK(status)) {
-                       DEBUG(10, ("Could not open stream %s: %s\n",
-                                  streamname, nt_errstr(status)));
-                       break;
-               }
-       }
-
-       /*
-        * don't touch the variable "status" beyond this point :-)
-        */
-
-       for (i -= 1 ; i >= 0; i--) {
-               if (streams[i] == NULL) {
-                       continue;
-               }
-
-               DEBUG(10, ("Closing stream # %d, %s\n", i,
-                          streams[i]->fsp_name));
-               close_file(NULL, streams[i], NORMAL_CLOSE);
-       }
-
- fail:
-       TALLOC_FREE(frame);
-       return status;
-}
-
 /*
  * Wrapper around onefs_open_file_ntcreate and onefs_open_directory.
  */