Skip to content

Instantly share code, notes, and snippets.

@miketweaver
Last active May 24, 2020 17:54
Show Gist options
  • Save miketweaver/92c61293f16ef3016f9a57472fff1ff3 to your computer and use it in GitHub Desktop.
Save miketweaver/92c61293f16ef3016f9a57472fff1ff3 to your computer and use it in GitHub Desktop.
UnRaid Filesystem Issues
#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);
}
}
#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