Start of the move towards handle-based code for directory access.
Currently makes fstat/fchown code work for directories rather than
falling back to pathnames.
Jeremy.
Autobuild-User: Jeremy Allison <jra@samba.org>
Autobuild-Date: Tue Feb 8 06:34:41 CET 2011 on sn-devel-104
{
memset(psbuf, 0, sizeof(SMB_STRUCT_STAT));
- if (fsp->is_directory || fsp->fh->fd == -1) {
+ if (fsp->fh->fd == -1) {
return smbacl4_GetFileOwner(fsp->conn,
fsp->fsp_name->base_name, psbuf);
}
{
SMB_STRUCT_STAT sbuf;
- if (fsp->is_directory || fsp->fh->fd == -1) {
+ if (fsp->fh->fd == -1) {
/* Get the stat struct for the owner info. */
return afs_to_nt_acl(afs_acl, fsp->conn, fsp->fsp_name,
security_info, ppdesc);
mtimespec = smb_dname->st.st_ex_mtime;
+#ifdef O_DIRECTORY
+ status = fd_open(conn, fsp, O_RDONLY|O_DIRECTORY, 0);
+ if (!NT_STATUS_IS_OK(status)) {
+ DEBUG(5, ("open_directory: Could not open fd for "
+ "%s (%s)\n",
+ smb_fname_str_dbg(smb_dname),
+ nt_errstr(status)));
+ file_free(req, fsp);
+ return status;
+ }
+#endif
+
lck = get_share_mode_lock(talloc_tos(), fsp->file_id,
conn->connectpath, smb_dname, &mtimespec);
if (lck == NULL) {
DEBUG(0, ("open_directory: Could not get share mode lock for "
"%s\n", smb_fname_str_dbg(smb_dname)));
+ fd_close(fsp);
file_free(req, fsp);
return NT_STATUS_SHARING_VIOLATION;
}
if (!NT_STATUS_IS_OK(status)) {
TALLOC_FREE(lck);
+ fd_close(fsp);
file_free(req, fsp);
return status;
}
status = can_set_delete_on_close(fsp, 0);
if (!NT_STATUS_IS_OK(status) && !NT_STATUS_EQUAL(status, NT_STATUS_DIRECTORY_NOT_EMPTY)) {
TALLOC_FREE(lck);
+ fd_close(fsp);
file_free(req, fsp);
return status;
}
/* We know this name is ok, it's already passed the checks. */
- } else if (fsp && (fsp->is_directory || fsp->fh->fd == -1)) {
+ } else if (fsp && fsp->fh->fd == -1) {
/*
* This is actually a QFILEINFO on a directory
* handle (returned from an NT SMB). NT5.0 seems
file_info_level = SMB2_FILE_RENAME_INFORMATION_INTERNAL;
}
- if (fsp->is_directory || fsp->fh->fd == -1) {
+ if (fsp->fh->fd == -1) {
/*
* This is actually a SETFILEINFO on a directory
* handle (returned from an NT SMB). NT5.0 seems
uint16 num_file_acls = 0;
uint16 num_def_acls = 0;
- if (fsp && !fsp->is_directory && (fsp->fh->fd != -1)) {
+ if (fsp && fsp->fh->fd != -1) {
file_acl = SMB_VFS_SYS_ACL_GET_FD(fsp);
} else {
file_acl =
enum brl_type lock_type;
/* We need an open file with a real fd for this. */
- if (!fsp || fsp->is_directory || fsp->fh->fd == -1) {
+ if (!fsp || fsp->fh->fd == -1) {
return NT_STATUS_INVALID_LEVEL;
}
/* We know this name is ok, it's already passed the checks. */
- } else if(fsp->is_directory || fsp->fh->fd == -1) {
+ } else if(fsp->fh->fd == -1) {
/*
* This is actually a QFILEINFO on a directory
* handle (returned from an NT SMB). NT5.0 seems
/*
* Original code - this is an open file.
*/
- if (!check_fsp(conn, req, fsp)) {
- return;
- }
-
if (SMB_VFS_FSTAT(fsp, &smb_fname->st) != 0) {
DEBUG(3, ("fstat of fnum %d failed (%s)\n",
fsp->fnum, strerror(errno)));
return;
}
- if(fsp->is_directory || fsp->fh->fd == -1) {
+ if(fsp->fh->fd == -1) {
/*
* This is actually a SETFILEINFO on a directory
* handle (returned from an NT SMB). NT5.0 seems
/*
* Original code - this is an open file.
*/
- if (!check_fsp(conn, req, fsp)) {
- return;
- }
-
if (SMB_VFS_FSTAT(fsp, &smb_fname->st) != 0) {
DEBUG(3,("call_trans2setfilepathinfo: fstat "
"of fnum %d failed (%s)\n", fsp->fnum,
{
int ret;
- if(fsp->is_directory || fsp->fh->fd == -1) {
+ if(fsp->fh->fd == -1) {
if (fsp->posix_open) {
ret = SMB_VFS_LSTAT(fsp->conn, fsp->fsp_name);
} else {
{
int ret;
- if (!fsp->is_directory && fsp->fh->fd != -1) {
+ if (fsp->fh->fd != -1) {
/* Try fchown. */
ret = SMB_VFS_FCHOWN(fsp, uid, gid);
if (ret == 0) {