Last active
May 24, 2020 17:54
-
-
Save miketweaver/92c61293f16ef3016f9a57472fff1ff3 to your computer and use it in GitHub Desktop.
UnRaid Filesystem Issues
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
#include <dirent.h> | |
int | |
main(void) | |
{ | |
struct dirent **namelist; | |
int n; | |
n = scandir("/mnt/user/games/GAMES/BLUS31606", &namelist, NULL, alphasort); | |
if (n < 0) | |
perror("scandir"); | |
else { | |
while (n--) { | |
printf("\n%s, ", namelist[n]->d_name); | |
switch(namelist[n]->d_type) { | |
case DT_DIR: | |
printf("d_type: DT_DIR"); | |
break; | |
case DT_UNKNOWN: | |
printf("d_type: DT_UNKNOWN"); | |
break; | |
case DT_LNK: | |
printf("d_type: DT_LNK"); | |
break; | |
case DT_FIFO: | |
printf("d_type: DT_FIFO"); | |
break; | |
case DT_REG: | |
printf("d_type: DT_REG"); | |
break; | |
default: | |
printf("d_type: other"); | |
} | |
free(namelist[n]); | |
} | |
free(namelist); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
#include <dirent.h> | |
#include <sys/stat.h> | |
int | |
main(void) | |
{ | |
struct dirent **namelist; | |
int n; | |
n = scandir("/mnt/user/games/GAMES/BLUS31606", &namelist, NULL, alphasort); | |
if (n < 0) | |
perror("scandir"); | |
else { | |
while (n--) { | |
printf("%s, ", namelist[n]->d_name); | |
struct stat filestat; | |
stat(namelist[n]->d_name,&filestat); | |
if( S_ISDIR(filestat.st_mode) ) | |
printf("unknown is a Directory!"); | |
if( S_ISREG(filestat.st_mode) ) | |
printf("unknown is a File!"); | |
if( S_ISCHR(filestat.st_mode) ) | |
printf("unknown is a CHR!"); | |
if( S_ISFIFO(filestat.st_mode) ) | |
printf("unknown is a FIFO!"); | |
if( S_ISLNK(filestat.st_mode) ) | |
printf("unknown is a LNK!"); | |
free(namelist[n]); | |
printf("\n"); | |
} | |
free(namelist); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment