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);
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)) {
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.
****************************************************************************/
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)) {