mirror of
https://github.com/samba-team/samba.git
synced 2024-12-22 13:34:15 +03:00
libsmb: Move unix_filetype_to_wire() to libcli/smb
Mostly symmetry reasons, we have the opposite function here as well Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
This commit is contained in:
parent
4c9aa5fa15
commit
6084914e22
@ -33,6 +33,7 @@ char *attrib_string(TALLOC_CTX *mem_ctx, uint32_t attrib);
|
||||
uint32_t unix_perms_to_wire(mode_t perms);
|
||||
mode_t wire_perms_to_unix(uint32_t perms);
|
||||
mode_t wire_filetype_to_unix(uint32_t wire_type);
|
||||
uint32_t unix_filetype_to_wire(mode_t mode);
|
||||
|
||||
bool smb_buffer_oob(uint32_t bufsize, uint32_t offset, uint32_t length);
|
||||
|
||||
|
@ -182,6 +182,19 @@ mode_t wire_filetype_to_unix(uint32_t wire_type)
|
||||
return unix_filetypes[wire_type];
|
||||
}
|
||||
|
||||
uint32_t unix_filetype_to_wire(mode_t mode)
|
||||
{
|
||||
mode_t type = mode & S_IFMT;
|
||||
size_t i;
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(unix_filetypes); i++) {
|
||||
if (type == unix_filetypes[i]) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return UNIX_TYPE_UNKNOWN;
|
||||
}
|
||||
|
||||
bool smb_buffer_oob(uint32_t bufsize, uint32_t offset, uint32_t length)
|
||||
{
|
||||
if ((offset + length < offset) || (offset + length < length)) {
|
||||
|
@ -887,41 +887,6 @@ static struct ea_list *ea_list_union(struct ea_list *name_list, struct ea_list *
|
||||
return name_list;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
Return the filetype for UNIX extensions.
|
||||
****************************************************************************/
|
||||
|
||||
static uint32_t unix_filetype(mode_t mode)
|
||||
{
|
||||
if(S_ISREG(mode))
|
||||
return UNIX_TYPE_FILE;
|
||||
else if(S_ISDIR(mode))
|
||||
return UNIX_TYPE_DIR;
|
||||
#ifdef S_ISLNK
|
||||
else if(S_ISLNK(mode))
|
||||
return UNIX_TYPE_SYMLINK;
|
||||
#endif
|
||||
#ifdef S_ISCHR
|
||||
else if(S_ISCHR(mode))
|
||||
return UNIX_TYPE_CHARDEV;
|
||||
#endif
|
||||
#ifdef S_ISBLK
|
||||
else if(S_ISBLK(mode))
|
||||
return UNIX_TYPE_BLKDEV;
|
||||
#endif
|
||||
#ifdef S_ISFIFO
|
||||
else if(S_ISFIFO(mode))
|
||||
return UNIX_TYPE_FIFO;
|
||||
#endif
|
||||
#ifdef S_ISSOCK
|
||||
else if(S_ISSOCK(mode))
|
||||
return UNIX_TYPE_SOCKET;
|
||||
#endif
|
||||
|
||||
DEBUG(0,("unix_filetype: unknown filetype %u\n", (unsigned)mode));
|
||||
return UNIX_TYPE_UNKNOWN;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
Map wire perms onto standard UNIX permissions. Obey share restrictions.
|
||||
****************************************************************************/
|
||||
@ -2797,7 +2762,7 @@ char *store_file_unix_basic(connection_struct *conn,
|
||||
SIVAL(pdata,4,0);
|
||||
pdata += 8;
|
||||
|
||||
SIVAL(pdata,0,unix_filetype(psbuf->st_ex_mode));
|
||||
SIVAL(pdata, 0, unix_filetype_to_wire(psbuf->st_ex_mode));
|
||||
pdata += 4;
|
||||
|
||||
if (S_ISBLK(psbuf->st_ex_mode) || S_ISCHR(psbuf->st_ex_mode)) {
|
||||
|
Loading…
Reference in New Issue
Block a user