fixed. Support building in one binary
This commit is contained in:
parent
7d0207ace2
commit
33b89e64da
38 changed files with 285 additions and 163 deletions
53
libmu/mode_to_str.c
Normal file
53
libmu/mode_to_str.c
Normal file
|
@ -0,0 +1,53 @@
|
|||
#include <stdio.h>
|
||||
#include <sys/stat.h>
|
||||
#include "mode_to_str.h"
|
||||
|
||||
char *mu_mode_2_str(mode_t file_mode) {
|
||||
snprintf(mode, sizeof(mode), "----------");
|
||||
|
||||
if (file_mode & S_IRUSR)
|
||||
mode[1] = 'r';
|
||||
|
||||
if (file_mode & S_IRGRP)
|
||||
mode[4] = 'r';
|
||||
|
||||
if (file_mode & S_IROTH)
|
||||
mode[7] = 'r';
|
||||
|
||||
if (file_mode & S_IWUSR)
|
||||
mode[2] = 'w';
|
||||
|
||||
if (file_mode & S_IWGRP)
|
||||
mode[5] = 'w';
|
||||
|
||||
if (file_mode & S_IWOTH)
|
||||
mode[8] = 'w';
|
||||
|
||||
if (file_mode & S_IXUSR)
|
||||
mode[3] = 'x';
|
||||
|
||||
if (file_mode & S_IXGRP)
|
||||
mode[6] = 'x';
|
||||
|
||||
if (file_mode & S_IXOTH)
|
||||
mode[9] = 'x';
|
||||
|
||||
if (file_mode & S_ISUID) {
|
||||
if (file_mode & S_IXUSR)
|
||||
mode[3] = 's';
|
||||
|
||||
else
|
||||
mode[3] = 'S';
|
||||
}
|
||||
|
||||
if (file_mode & S_ISGID) {
|
||||
if (file_mode & S_IRGRP)
|
||||
mode[6] = 's';
|
||||
|
||||
else
|
||||
mode[6] = 'S';
|
||||
}
|
||||
|
||||
return mode;
|
||||
}
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue