Get one EA value. Fill in a struct ea_struct.
****************************************************************************/
-NTSTATUS get_ea_value(TALLOC_CTX *mem_ctx, connection_struct *conn,
- files_struct *fsp, const char *fname,
- const char *ea_name, struct ea_struct *pea)
+NTSTATUS get_ea_value(TALLOC_CTX *mem_ctx,
+ connection_struct *conn,
+ files_struct *fsp,
+ const struct smb_filename *smb_fname,
+ const char *ea_name,
+ struct ea_struct *pea)
{
/* Get the value of this xattr. Max size is 64k. */
size_t attr_size = 256;
if (fsp && fsp->fh->fd != -1) {
sizeret = SMB_VFS_FGETXATTR(fsp, ea_name, val, attr_size);
} else {
- sizeret = SMB_VFS_GETXATTR(conn, fname, ea_name, val, attr_size);
+ sizeret = SMB_VFS_GETXATTR(conn, smb_fname,
+ ea_name, val, attr_size);
}
if (sizeret == -1 && errno == ERANGE && attr_size != 65536) {
ea_namelist_size);
} else {
sizeret = SMB_VFS_LISTXATTR(conn,
- smb_fname->base_name,
+ smb_fname,
ea_namelist,
ea_namelist_size);
}
ea_namelist_size);
} else {
sizeret = SMB_VFS_LISTXATTR(conn,
- smb_fname->base_name,
+ smb_fname,
ea_namelist,
ea_namelist_size);
}
status = get_ea_value(listp,
conn,
fsp,
- smb_fname->base_name,
+ smb_fname,
names[i],
&listp->ea);
DEBUG(10,("set_ea: deleting ea name %s on file %s.\n",
unix_ea_name, smb_fname->base_name));
ret = SMB_VFS_REMOVEXATTR(conn,
- smb_fname->base_name,
+ smb_fname,
unix_ea_name);
}
#ifdef ENOATTR
DEBUG(10,("set_ea: setting ea name %s on file %s.\n",
unix_ea_name, smb_fname->base_name));
ret = SMB_VFS_SETXATTR(conn,
- smb_fname->base_name,
+ smb_fname,
unix_ea_name,
ea_list->ea.value.data,
ea_list->ea.value.length,
uint32_t create_disposition;
uint32_t create_options = 0;
uint32_t private_flags = 0;
- uint32_t ucf_flags = (req->posix_pathnames ? UCF_POSIX_PATHNAMES : 0);
+ uint32_t ucf_flags = ucf_flags_from_smb_request(req);
TALLOC_CTX *ctx = talloc_tos();
/*
status = filename_convert(ctx,
conn,
- req->flags2 & FLAGS2_DFS_PATHNAMES,
fname,
ucf_flags,
NULL,
****************************************************************************/
static bool check_msdfs_link(connection_struct *conn,
- const char *pathname,
- SMB_STRUCT_STAT *psbuf)
+ struct smb_filename *smb_fname)
{
int saved_errno = errno;
if(lp_host_msdfs() &&
lp_msdfs_root(SNUM(conn)) &&
- is_msdfs_link(conn, pathname, psbuf)) {
+ is_msdfs_link(conn, smb_fname)) {
DEBUG(5,("check_msdfs_link: Masquerading msdfs link %s "
"as a directory\n",
- pathname));
- psbuf->st_ex_mode = (psbuf->st_ex_mode & 0xFFF) | S_IFDIR;
+ smb_fname->base_name));
+ smb_fname->st.st_ex_mode =
+ (smb_fname->st.st_ex_mode & 0xFFF) | S_IFDIR;
errno = saved_errno;
return true;
}
* directories */
ms_dfs_link = check_msdfs_link(state->conn,
- smb_fname->base_name,
- &smb_fname->st);
+ smb_fname);
if (!ms_dfs_link) {
DEBUG(5,("smbd_dirptr_lanman2_mode_fn: "
"Couldn't stat [%s] (%s)\n",
struct dptr_struct *dirptr = NULL;
struct smbd_server_connection *sconn = req->sconn;
uint32_t ucf_flags = UCF_SAVE_LCOMP | UCF_ALWAYS_ALLOW_WCARD_LCOMP |
- (req->posix_pathnames ? UCF_POSIX_PATHNAMES : 0);
+ ucf_flags_from_smb_request(req);
bool backup_priv = false;
bool as_root = false;
&smb_dname);
} else {
ntstatus = filename_convert(talloc_tos(), conn,
- req->flags2 & FLAGS2_DFS_PATHNAMES,
directory,
ucf_flags,
&mask_contains_wcard,
cBytesSector=%u, cUnitTotal=%u, cUnitAvail=%d\n", (unsigned int)st.st_ex_dev, (unsigned int)bsize, (unsigned int)sectors_per_unit,
(unsigned int)bytes_per_sector, (unsigned int)dsize, (unsigned int)dfree));
+ /*
+ * For large drives, return max values and not modulo.
+ */
+ dsize = MIN(dsize, UINT32_MAX);
+ dfree = MIN(dfree, UINT32_MAX);
+
SIVAL(pdata,l1_idFileSystem,st.st_ex_dev);
SIVAL(pdata,l1_cSectorUnit,sectors_per_unit);
SIVAL(pdata,l1_cUnit,dsize);
return NT_STATUS_INVALID_LEVEL;
}
- rc = SMB_VFS_STATVFS(conn, filename, &svfs);
+ rc = SMB_VFS_STATVFS(conn, &smb_fname, &svfs);
if (!rc) {
data_len = 56;
return NT_STATUS_DOS(ERRDOS, ERRbadlink);
#endif
link_len = SMB_VFS_READLINK(conn,
- smb_fname->base_name,
+ smb_fname,
buffer, PATH_MAX);
if (link_len == -1) {
return map_nt_error_from_unix(errno);
} else {
file_acl =
SMB_VFS_SYS_ACL_GET_FILE(conn,
- smb_fname->base_name,
+ smb_fname,
SMB_ACL_TYPE_ACCESS,
talloc_tos());
}
def_acl =
SMB_VFS_SYS_ACL_GET_FILE(
conn,
- fsp->fsp_name->base_name,
+ fsp->fsp_name,
SMB_ACL_TYPE_DEFAULT,
talloc_tos());
} else {
def_acl =
SMB_VFS_SYS_ACL_GET_FILE(
conn,
- smb_fname->base_name,
+ smb_fname,
SMB_ACL_TYPE_DEFAULT,
talloc_tos());
}
} else {
uint32_t name_hash;
char *fname = NULL;
- uint32_t ucf_flags = (req->posix_pathnames ?
- UCF_POSIX_PATHNAMES : 0);
+ uint32_t ucf_flags = ucf_flags_from_smb_request(req);
/* qpathinfo */
if (total_params < 7) {
status = filename_convert(req,
conn,
- req->flags2 & FLAGS2_DFS_PATHNAMES,
fname,
ucf_flags,
NULL,
DEBUG(10,("hardlink_internals: doing hard link %s -> %s\n",
smb_fname_old->base_name, smb_fname_new->base_name));
- if (SMB_VFS_LINK(conn, smb_fname_old->base_name,
- smb_fname_new->base_name) != 0) {
+ if (SMB_VFS_LINK(conn, smb_fname_old, smb_fname_new) != 0) {
status = map_nt_error_from_unix(errno);
DEBUG(3,("hardlink_internals: Error %s hard link %s -> %s\n",
nt_errstr(status), smb_fname_old->base_name,
struct smb_request *req,
const char *pdata,
int total_data,
- const struct smb_filename *smb_fname)
+ const struct smb_filename *new_smb_fname)
{
char *link_target = NULL;
- const char *newname = smb_fname->base_name;
TALLOC_CTX *ctx = talloc_tos();
/* Set a symbolic link. */
}
DEBUG(10,("smb_set_file_unix_link: SMB_SET_FILE_UNIX_LINK doing symlink %s -> %s\n",
- newname, link_target ));
+ new_smb_fname->base_name, link_target ));
- if (SMB_VFS_SYMLINK(conn,link_target,newname) != 0) {
+ if (SMB_VFS_SYMLINK(conn,link_target,new_smb_fname) != 0) {
return map_nt_error_from_unix(errno);
}
{
char *oldname = NULL;
struct smb_filename *smb_fname_old = NULL;
- uint32_t ucf_flags = (req->posix_pathnames ? UCF_POSIX_PATHNAMES : 0);
+ uint32_t ucf_flags = ucf_flags_from_smb_request(req);
TALLOC_CTX *ctx = talloc_tos();
NTSTATUS status = NT_STATUS_OK;
status = filename_convert(ctx,
conn,
- req->flags2 & FLAGS2_DFS_PATHNAMES,
oldname,
ucf_flags,
NULL,
char *newname = NULL;
struct smb_filename *smb_fname_dst = NULL;
uint32_t ucf_flags = UCF_SAVE_LCOMP |
- (req->posix_pathnames ? UCF_POSIX_PATHNAMES : 0);
+ ucf_flags_from_smb_request(req);
NTSTATUS status = NT_STATUS_OK;
TALLOC_CTX *ctx = talloc_tos();
status = filename_convert(ctx,
conn,
- req->flags2 & FLAGS2_DFS_PATHNAMES,
newname,
ucf_flags,
NULL,
struct smb_filename *smb_fname_dst = NULL;
NTSTATUS status = NT_STATUS_OK;
uint32_t ucf_flags = UCF_SAVE_LCOMP |
- (req->posix_pathnames ? UCF_POSIX_PATHNAMES : 0);
+ ucf_flags_from_smb_request(req);
TALLOC_CTX *ctx = talloc_tos();
if (!fsp) {
status = filename_convert(ctx,
conn,
- req->flags2 & FLAGS2_DFS_PATHNAMES,
newname,
ucf_flags,
NULL,
DEBUG(10,("smb_file_rename_information: got name |%s|\n",
newname));
- status = resolve_dfspath_wcard(ctx, conn,
- req->flags2 & FLAGS2_DFS_PATHNAMES,
+ if (req->flags2 & FLAGS2_DFS_PATHNAMES) {
+ status = resolve_dfspath_wcard(ctx, conn,
newname,
UCF_COND_ALLOW_WCARD_LCOMP,
!conn->sconn->using_smb2,
&newname,
&dest_has_wcard);
- if (!NT_STATUS_IS_OK(status)) {
- return status;
+ if (!NT_STATUS_IS_OK(status)) {
+ return status;
+ }
}
/* Check the new name has no '/' characters. */
* the newname instead.
*/
char *base_name = NULL;
+ uint32_t ucf_flags = UCF_SAVE_LCOMP |
+ ucf_flags_from_smb_request(req);
+
+ if (dest_has_wcard) {
+ ucf_flags |= UCF_ALWAYS_ALLOW_WCARD_LCOMP;
+ }
/* newname must *not* be a stream name. */
if (newname[0] == ':') {
}
status = unix_convert(ctx, conn, base_name, &smb_fname_dst,
- (UCF_SAVE_LCOMP |
- (dest_has_wcard ?
- UCF_ALWAYS_ALLOW_WCARD_LCOMP :
- 0)));
+ ucf_flags);
/* If an error we expect this to be
* NT_STATUS_OBJECT_PATH_NOT_FOUND */
(unsigned int)num_def_acls));
if (valid_file_acls && !set_unix_posix_acl(conn, fsp,
- smb_fname->base_name, num_file_acls,
+ smb_fname, num_file_acls,
pdata + SMB_POSIX_ACL_HEADER_SIZE)) {
return map_nt_error_from_unix(errno);
}
if (valid_def_acls && !set_unix_posix_default_acl(conn,
- smb_fname->base_name, &smb_fname->st, num_def_acls,
+ smb_fname, num_def_acls,
pdata + SMB_POSIX_ACL_HEADER_SIZE +
(num_file_acls*SMB_POSIX_ACL_ENTRY_SIZE))) {
return map_nt_error_from_unix(errno);
(unsigned int)unixmode, smb_fname_str_dbg(smb_fname)));
/* Ok - do the mknod. */
- if (SMB_VFS_MKNOD(conn, smb_fname->base_name, unixmode, dev) != 0) {
+ if (SMB_VFS_MKNOD(conn, smb_fname, unixmode, dev) != 0) {
return map_nt_error_from_unix(errno);
}
&parent, NULL)) {
return NT_STATUS_NO_MEMORY;
}
- inherit_access_posix_acl(conn, parent, smb_fname->base_name,
+ inherit_access_posix_acl(conn, parent, smb_fname,
unixmode);
TALLOC_FREE(parent);
}
/* XXX: we should be using SMB_VFS_FCHFLAGS here. */
return NT_STATUS_NOT_SUPPORTED;
} else {
- if (SMB_VFS_CHFLAGS(conn, smb_fname->base_name,
+ if (SMB_VFS_CHFLAGS(conn, smb_fname,
stat_fflags) != 0) {
return map_nt_error_from_unix(errno);
}
}
} else {
char *fname = NULL;
- uint32_t ucf_flags = (req->posix_pathnames ?
- UCF_POSIX_PATHNAMES : 0);
+ uint32_t ucf_flags = ucf_flags_from_smb_request(req);
/* set path info */
if (total_params < 7) {
}
status = filename_convert(req, conn,
- req->flags2 & FLAGS2_DFS_PATHNAMES,
fname,
ucf_flags,
NULL,
char *directory = NULL;
NTSTATUS status = NT_STATUS_OK;
struct ea_list *ea_list = NULL;
- uint32_t ucf_flags = (req->posix_pathnames ? UCF_POSIX_PATHNAMES : 0);
+ uint32_t ucf_flags = ucf_flags_from_smb_request(req);
TALLOC_CTX *ctx = talloc_tos();
if (!CAN_WRITE(conn)) {
status = filename_convert(ctx,
conn,
- req->flags2 & FLAGS2_DFS_PATHNAMES,
directory,
ucf_flags,
NULL,