325
327
fsp->wcp = NULL; /* Write cache pointer. */
327
329
DEBUG(2,("%s opened file %s read=%s write=%s (numopen=%d)\n",
328
conn->server_info->unix_name,
330
conn->session_info->unix_name,
329
331
smb_fname_str_dbg(smb_fname),
330
332
BOOLSTR(fsp->can_read), BOOLSTR(fsp->can_write),
331
333
conn->num_files_open));
358
360
if (procid_is_me(&e->pid) && (e->op_mid == req->mid)) {
359
361
DEBUG(0, ("Trying to defer an already deferred "
360
"request: mid=%d, exiting\n", req->mid));
362
"request: mid=%llu, exiting\n",
363
(unsigned long long)req->mid));
361
364
exit_server("attempt to defer a deferred request");
365
368
/* End paranoia check */
367
370
DEBUG(10,("defer_open_sharing_error: time [%u.%06u] adding deferred "
368
"open entry for mid %u\n",
371
"open entry for mid %llu\n",
369
372
(unsigned int)request_time.tv_sec,
370
373
(unsigned int)request_time.tv_usec,
371
(unsigned int)req->mid));
374
(unsigned long long)req->mid));
373
if (!push_deferred_smb_message(req, request_time, timeout,
374
(char *)state, sizeof(*state))) {
375
exit_server("push_deferred_smb_message failed");
376
if (!push_deferred_open_message_smb(req, request_time, timeout,
377
state->id, (char *)state, sizeof(*state))) {
378
exit_server("push_deferred_open_message_smb failed");
377
380
add_deferred_open(lck, req->mid, request_time, state->id);
455
459
mode_t unx_mode = (mode_t)0;
457
461
uint32 existing_dos_attributes = 0;
458
struct pending_message_list *pml = NULL;
459
462
struct timeval request_time = timeval_zero();
460
463
struct share_mode_lock *lck = NULL;
461
464
uint32 open_access_mask = access_mask;
481
484
DEBUG(10, ("onefs_open_file_ntcreate: printer open fname=%s\n",
482
485
smb_fname_str_dbg(smb_fname)));
484
return print_fsp_open(req, conn, smb_fname->base_name,
487
return print_spool_open(fsp, smb_fname->base_name,
488
491
if (!parent_dirname(talloc_tos(), smb_fname->base_name, &parent_dir,
495
498
unx_mode = (mode_t)(new_dos_attributes & ~FILE_FLAG_POSIX_SEMANTICS);
496
499
new_dos_attributes = 0;
498
/* We add aARCH to this as this mode is only used if the file is
501
/* We add FILE_ATTRIBUTE_ARCHIVE to this as this mode is only used if the file is
499
502
* created new. */
500
unx_mode = unix_mode(conn, new_dos_attributes | aARCH,
503
unx_mode = unix_mode(conn, new_dos_attributes | FILE_ATTRIBUTE_ARCHIVE,
501
504
smb_fname, parent_dir);
540
543
* Only non-internal opens can be deferred at all
544
&& ((pml = get_open_deferred_message(req->mid)) != NULL)) {
545
struct deferred_open_record *state =
546
(struct deferred_open_record *)pml->private_data.data;
548
/* Remember the absolute time of the original
549
request with this mid. We'll use it later to
550
see if this has timed out. */
552
request_time = pml->request_time;
554
/* Remove the deferred open entry under lock. */
555
lck = get_share_mode_lock(talloc_tos(), state->id, NULL, NULL,
558
DEBUG(0, ("could not get share mode lock\n"));
560
del_deferred_open_entry(lck, req->mid);
564
/* Ensure we don't reprocess this message. */
565
remove_deferred_open_smb_message(req->mid);
568
* When receiving a semlock_async_failure message, the
569
* deferred open will be marked as "failed". Returning
573
DEBUG(0, ("onefs_open_file_ntcreate: "
574
"semlock_async_failure detected!\n"));
575
return NT_STATUS_INTERNAL_ERROR;
548
if (get_deferred_open_message_state(req,
551
struct deferred_open_record *state = (struct deferred_open_record *)ptr;
553
/* Remember the absolute time of the original
554
request with this mid. We'll use it later to
555
see if this has timed out. */
557
/* Remove the deferred open entry under lock. */
558
remove_deferred_open_entry(state->id, req->mid);
560
/* Ensure we don't reprocess this message. */
561
remove_deferred_open_message_smb(req->mid);
564
* When receiving a semlock_async_failure message, the
565
* deferred open will be marked as "failed". Returning
569
DEBUG(0, ("onefs_open_file_ntcreate: "
570
"semlock_async_failure detected!\n"));
571
return NT_STATUS_INTERNAL_ERROR;
591
588
/* Setup dos_attributes to be set by ifs_createfile */
592
589
if (lp_store_dos_attributes(SNUM(conn))) {
593
createfile_attributes = (new_dos_attributes | aARCH) &
590
createfile_attributes = (new_dos_attributes | FILE_ATTRIBUTE_ARCHIVE) &
594
591
~(FILE_ATTRIBUTE_NONINDEXED | FILE_ATTRIBUTE_COMPRESSED);
597
594
/* Ignore oplock requests if oplocks are disabled. */
598
if (!lp_oplocks(SNUM(conn)) || global_client_failed_oplock_break ||
595
if (!lp_oplocks(SNUM(conn)) ||
599
596
IS_VETO_OPLOCK_PATH(conn, smb_fname->base_name)) {
600
597
/* Mask off everything except the private Samba bits. */
601
598
oplock_request &= SAMBA_PRIVATE_OPLOCK_MASK;
818
815
DEBUG(10, ("fsp = %p\n", fsp));
820
817
fsp->share_access = share_access;
821
fsp->fh->private_options = create_options;
818
fsp->fh->private_options = private_flags;
822
819
fsp->access_mask = open_access_mask; /* We change this to the
823
820
* requested access_mask after
824
821
* the open is done. */
1261
1258
* deny mode is compatible with all current opens.
1264
/* Record the options we were opened with. */
1265
fsp->share_access = share_access;
1266
fsp->fh->private_options = create_options;
1268
1262
* According to Samba4, SEC_FILE_READ_ATTRIBUTE is always granted,
1316
1310
new_file_created = True;
1319
set_share_mode(lck, fsp, conn->server_info->utok.uid, 0,
1313
set_share_mode(lck, fsp, get_current_uid(conn),
1320
1315
fsp->oplock_type);
1322
1317
/* Handle strange delete on close create semantics. */
1488
1483
mode = (mode_t)(file_attributes & ~FILE_FLAG_POSIX_SEMANTICS);
1489
1484
file_attributes = 0;
1491
mode = unix_mode(conn, aDIR, smb_dname, parent_dir);
1486
mode = unix_mode(conn, FILE_ATTRIBUTE_DIRECTORY, smb_dname, parent_dir);
1629
1624
fsp->can_write = False;
1631
1626
fsp->share_access = share_access;
1632
fsp->fh->private_options = create_options;
1627
fsp->fh->private_options = 0;
1634
1629
* According to Samba4, SEC_FILE_READ_ATTRIBUTE is always granted,
1636
1631
fsp->access_mask = access_mask | FILE_READ_ATTRIBUTES;
1637
fsp->print_file = False;
1632
fsp->print_file = NULL;
1638
1633
fsp->modified = False;
1639
1634
fsp->oplock_type = NO_OPLOCK;
1640
1635
fsp->sent_oplock_break = NO_BREAK_SENT;
1672
1667
return NT_STATUS_DELETE_PENDING;
1675
set_share_mode(lck, fsp, conn->server_info->utok.uid, 0, NO_OPLOCK);
1670
set_share_mode(lck, fsp, get_current_uid(conn),
1671
req ? req->mid : 0, NO_OPLOCK);
1678
1674
* For directories the delete on close bit at open time seems
1732
1729
DEBUG(10,("onefs_create_file_unixpath: access_mask = 0x%x "
1733
1730
"file_attributes = 0x%x, share_access = 0x%x, "
1734
1731
"create_disposition = 0x%x create_options = 0x%x "
1735
"oplock_request = 0x%x ea_list = 0x%p, sd = 0x%p, "
1732
"oplock_request = 0x%x private_flags = 0x%x "
1733
"ea_list = 0x%p, sd = 0x%p, "
1736
1734
"fname = %s\n",
1737
1735
(unsigned int)access_mask,
1738
1736
(unsigned int)file_attributes,
1740
1738
(unsigned int)create_disposition,
1741
1739
(unsigned int)create_options,
1742
1740
(unsigned int)oplock_request,
1741
(unsigned int)private_flags,
1743
1742
ea_list, sd, smb_fname_str_dbg(smb_fname)));
1745
1744
if (create_options & FILE_OPEN_BY_FILE_ID) {
2080
2081
DEBUG(10,("onefs_create_file: access_mask = 0x%x "
2081
2082
"file_attributes = 0x%x, share_access = 0x%x, "
2082
2083
"create_disposition = 0x%x create_options = 0x%x "
2083
"oplock_request = 0x%x "
2084
"oplock_request = 0x%x private_flags = 0x%x"
2084
2085
"root_dir_fid = 0x%x, ea_list = 0x%p, sd = 0x%p, "
2085
2086
"fname = %s\n",
2086
2087
(unsigned int)access_mask,
2089
2090
(unsigned int)create_disposition,
2090
2091
(unsigned int)create_options,
2091
2092
(unsigned int)oplock_request,
2093
(unsigned int)private_flags,
2092
2094
(unsigned int)root_dir_fid,
2093
2095
ea_list, sd, smb_fname_str_dbg(smb_fname)));
2114
if (is_ntfs_stream_smb_fname(smb_fname)) {
2115
if (!(conn->fs_capabilities & FILE_NAMED_STREAMS)) {
2116
status = NT_STATUS_OBJECT_NAME_NOT_FOUND;
2120
if (is_ntfs_default_stream_smb_fname(smb_fname)) {
2122
smb_fname->stream_name = NULL;
2123
/* We have to handle this error here. */
2124
if (create_options & FILE_DIRECTORY_FILE) {
2125
status = NT_STATUS_NOT_A_DIRECTORY;
2128
if (lp_posix_pathnames()) {
2129
ret = SMB_VFS_LSTAT(conn, smb_fname);
2131
ret = SMB_VFS_STAT(conn, smb_fname);
2134
if (ret == 0 && VALID_STAT_OF_DIR(smb_fname->st)) {
2135
status = NT_STATUS_FILE_IS_A_DIRECTORY;
2112
2141
status = onefs_create_file_unixpath(
2113
2142
conn, /* conn */