mirror of
https://gitlab.com/sortix/sortix.git
synced 2023-02-13 20:55:38 -05:00
Add S_ISGID and S_ISUID.
I originally left them out because Sortix doesn't have setuid and setgid executable support, but this created considerable compatibility issues and it is better to supply them as the mode bits still exist and can be set.
This commit is contained in:
parent
c7165cdcb4
commit
ef45218660
4 changed files with 13 additions and 18 deletions
|
@ -96,12 +96,8 @@ mode_t HostModeFromExtMode(uint32_t extmode)
|
|||
{
|
||||
mode_t hostmode = extmode & 0777;
|
||||
if ( extmode & EXT2_S_ISVTX ) hostmode |= S_ISVTX;
|
||||
#if defined(S_ISGID) // Not on Sortix.
|
||||
if ( extmode & EXT2_S_ISGID ) hostmode |= S_ISGID;
|
||||
#endif
|
||||
#if defined(S_ISUID) // Not on Sortix.
|
||||
if ( extmode & EXT2_S_ISUID ) hostmode |= S_ISUID;
|
||||
#endif
|
||||
if ( EXT2_S_ISSOCK(extmode) ) hostmode |= S_IFSOCK;
|
||||
if ( EXT2_S_ISLNK(extmode) ) hostmode |= S_IFLNK;
|
||||
if ( EXT2_S_ISREG(extmode) ) hostmode |= S_IFREG;
|
||||
|
@ -116,12 +112,8 @@ uint32_t ExtModeFromHostMode(mode_t hostmode)
|
|||
{
|
||||
uint32_t extmode = hostmode & 0777;
|
||||
if ( hostmode & S_ISVTX ) extmode |= EXT2_S_ISVTX;
|
||||
#if defined(S_ISGID) // Not on Sortix.
|
||||
if ( hostmode & S_ISGID ) extmode |= EXT2_S_ISGID;
|
||||
#endif
|
||||
#if defined(S_ISUID) // Not on Sortix.
|
||||
if ( hostmode & EXT2_S_ISUID ) extmode |= EXT2_S_ISUID;
|
||||
#endif
|
||||
if ( hostmode & S_ISUID ) extmode |= EXT2_S_ISUID;
|
||||
if ( S_ISSOCK(hostmode) ) extmode |= EXT2_S_IFSOCK;
|
||||
if ( S_ISLNK(hostmode) ) extmode |= EXT2_S_IFLNK;
|
||||
if ( S_ISREG(hostmode) ) extmode |= EXT2_S_IFREG;
|
||||
|
|
|
@ -53,9 +53,8 @@ __BEGIN_DECLS
|
|||
#define INITRD_S_IFDIR 0x4000
|
||||
#define INITRD_S_IFCHR 0x2000
|
||||
#define INITRD_S_IFIFO 0x1000
|
||||
/* Intentionally not part of Sortix. */
|
||||
/*#define INITRD_S_ISUID 0x0800 */
|
||||
/*#define INITRD_S_ISGID 0x0400 */
|
||||
#define INITRD_S_ISUID 0x0800
|
||||
#define INITRD_S_ISGID 0x0400
|
||||
#define INITRD_S_ISVTX 0x0200
|
||||
#define INITRD_S_ISSOCK(mode) ((mode & INITRD_S_IFMT) == INITRD_S_IFSOCK)
|
||||
#define INITRD_S_ISLNK(mode) ((mode & INITRD_S_IFMT) == INITRD_S_IFLNK)
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*******************************************************************************
|
||||
|
||||
Copyright(C) Jonas 'Sortie' Termansen 2012, 2013, 2014.
|
||||
Copyright(C) Jonas 'Sortie' Termansen 2012, 2013, 2014, 2015.
|
||||
|
||||
This file is part of Sortix.
|
||||
|
||||
|
@ -75,9 +75,8 @@ struct stat
|
|||
#define S_IFDIR __DTTOIF(__DT_DIR)
|
||||
#define S_IFCHR __DTTOIF(__DT_CHR)
|
||||
#define S_IFIFO __DTTOIF(__DT_FIFO)
|
||||
/* Intentionally not part of Sortix. */
|
||||
/*#define S_ISUID 0x0800 */
|
||||
/*#define S_ISGID 0x0400 */
|
||||
#define S_ISUID 0x0800
|
||||
#define S_ISGID 0x0400
|
||||
#define S_ISVTX 0x0200
|
||||
#define S_SETABLE (0777 | 0x0200 | 0x0400 | 0x0800)
|
||||
#define S_ISSOCK(mode) (((mode) & S_IFMT) == S_IFSOCK)
|
||||
|
|
|
@ -306,7 +306,6 @@ int handle_entry_internal(const char* fullpath, const char* name, unsigned char
|
|||
return 0;
|
||||
}
|
||||
char perms[11];
|
||||
perms[0] = '?';
|
||||
switch ( type )
|
||||
{
|
||||
case DT_UNKNOWN: perms[0] = '?'; break;
|
||||
|
@ -325,6 +324,13 @@ int handle_entry_internal(const char* fullpath, const char* name, unsigned char
|
|||
bool set = st.st_mode & (1UL<<i);
|
||||
perms[9-i] = stat_error ? '?' : set ? flagnames[i % 3] : '-';
|
||||
}
|
||||
if ( st.st_mode & S_ISUID )
|
||||
perms[3] = st.st_mode & 0100 ? 's' : 'S';
|
||||
if ( st.st_mode & S_ISGID )
|
||||
perms[6] = st.st_mode & 0010 ? 's' : 'S';
|
||||
if ( st.st_mode & S_ISVTX )
|
||||
perms[9] = st.st_mode & 0001 ? 't' : 'T';
|
||||
perms[10] = 0;
|
||||
const char* sizeunit = "B";
|
||||
off_t size = st.st_size;
|
||||
if ( 1023 < size ) { size /= 1024UL; sizeunit = "K"; }
|
||||
|
@ -332,7 +338,6 @@ int handle_entry_internal(const char* fullpath, const char* name, unsigned char
|
|||
if ( 1023 < size ) { size /= 1024UL; sizeunit = "G"; }
|
||||
if ( 1023 < size ) { size /= 1024UL; sizeunit = "T"; }
|
||||
if ( 1023 < size ) { size /= 1024UL; sizeunit = "P"; }
|
||||
perms[10] = 0;
|
||||
struct tm mod_tm;
|
||||
localtime_r(&st.st_mtim.tv_sec, &mod_tm);
|
||||
char time_str[64];
|
||||
|
|
Loading…
Reference in a new issue