diff --git a/userspace/ls/main.cpp b/userspace/ls/main.cpp index b18a0c5e6c..bdaf01c4d3 100644 --- a/userspace/ls/main.cpp +++ b/userspace/ls/main.cpp @@ -17,15 +17,15 @@ const char* mode_string(mode_t mode) (mode & 0770000) == S_IFBLK ? 'b' : (mode & 0770000) == S_IFCHR ? 'c' : '-'; - buffer[1] = mode & S_IRUSR ? 'r' : '-'; - buffer[2] = mode & S_IWUSR ? 'w' : '-'; - buffer[3] = mode & S_IXUSR ? 'x' : '-'; - buffer[4] = mode & S_IRGRP ? 'r' : '-'; - buffer[5] = mode & S_IWGRP ? 'w' : '-'; - buffer[6] = mode & S_IXGRP ? 'x' : '-'; - buffer[7] = mode & S_IROTH ? 'r' : '-'; - buffer[8] = mode & S_IWOTH ? 'w' : '-'; - buffer[9] = mode & S_IXOTH ? 'x' : '-'; + buffer[1] = (mode & S_IRUSR) ? 'r' : '-'; + buffer[2] = (mode & S_IWUSR) ? 'w' : '-'; + buffer[3] = (mode & S_ISUID) ? ((mode & S_IXUSR) ? 's' : 'S') : (mode & S_IXUSR) ? 'x' : '-'; + buffer[4] = (mode & S_IRGRP) ? 'r' : '-'; + buffer[5] = (mode & S_IWGRP) ? 'w' : '-'; + buffer[6] = (mode & S_ISGID) ? ((mode & S_IXGRP) ? 's' : 'S') : (mode & S_IXGRP) ? 'x' : '-'; + buffer[7] = (mode & S_IROTH) ? 'r' : '-'; + buffer[8] = (mode & S_IWOTH) ? 'w' : '-'; + buffer[9] = (mode & S_ISVTX) ? ((mode & S_IXOTH) ? 't' : 'T') : (mode & S_IXOTH) ? 'x' : '-'; buffer[10] = '\0'; return buffer; diff --git a/userspace/stat/main.cpp b/userspace/stat/main.cpp index d26fc341a9..af230e687e 100644 --- a/userspace/stat/main.cpp +++ b/userspace/stat/main.cpp @@ -55,19 +55,19 @@ int main(int argc, char** argv) access[1] = (st.st_mode & S_IRUSR) ? 'r' : '-'; access[2] = (st.st_mode & S_IWUSR) ? 'w' : '-'; - access[3] = (st.st_mode & S_IXUSR) ? 'x' : '-'; + access[3] = (st.st_mode & S_ISUID) ? ((st.st_mode & S_IXUSR) ? 's' : 'S') : (st.st_mode & S_IXUSR) ? 'x' : '-'; access[4] = (st.st_mode & S_IRGRP) ? 'r' : '-'; access[5] = (st.st_mode & S_IWGRP) ? 'w' : '-'; - access[6] = (st.st_mode & S_IXGRP) ? 'x' : '-'; + access[6] = (st.st_mode & S_ISGID) ? ((st.st_mode & S_IXGRP) ? 's' : 'S') : (st.st_mode & S_IXGRP) ? 'x' : '-'; access[7] = (st.st_mode & S_IROTH) ? 'r' : '-'; access[8] = (st.st_mode & S_IWOTH) ? 'w' : '-'; - access[9] = (st.st_mode & S_IXOTH) ? 'x' : '-'; + access[9] = (st.st_mode & S_ISVTX) ? ((st.st_mode & S_IXOTH) ? 't' : 'T') : (st.st_mode & S_IXOTH) ? 'x' : '-'; access[10] = '\0'; printf(" File: %s\n", argv[i]); printf(" Size: %-15ld Blocks: %-10ld IO Block: %-6ld %s\n", st.st_size, st.st_blocks, st.st_blksize, type); printf("Device: %lu,%-5lu Inode: %-11lu Links: %-5lu Device type: %lu,%lu\n", major(st.st_dev), minor(st.st_dev), st.st_ino, st.st_nlink, major(st.st_rdev), minor(st.st_rdev)); - printf("Access: (%04o/%s) Uid: %5d Gid: %5d\n", st.st_mode & S_IRWXMASK, access, st.st_uid, st.st_gid); + printf("Access: (%04o/%s) Uid: %5d Gid: %5d\n", st.st_mode & (S_IRWXU | S_IRWXG | S_IRWXO | S_ISUID | S_ISGID | S_ISVTX), access, st.st_uid, st.st_gid); printf("Access: "); print_timestamp(st.st_atim); printf("\n"); printf("Modify: "); print_timestamp(st.st_mtim); printf("\n"); printf("Change: "); print_timestamp(st.st_ctim); printf("\n");