Psst.. new poll here.
Psst.. new forums here.
Microsoft is blocking us again (TY IP Reputation!) so just use oauth login instead. :)
Paste
Pasted as Plain Text by Johnny ( 17 years ago )
#include <sys/types.h>
#include <sys/stat.h>
#include <dirent.h>
#include <stdio.h>
#define PATH_MAX_LEN 1024
FILE* console;
extern int reboot(int mode);
#define RB_AUTOBOOT 0
void printoutrd(char *msg) {
fprintf(console, "%s
", msg);
}
void removeDirectory(const char *dirpath) {
DIR *directory;
struct dirent *ep;
directory = opendir(dirpath);
if(directory != NULL) {
while(ep = readdir(directory)) {
struct stat dtype;
char buff[PATH_MAX_LEN];
snprintf(buff, PATH_MAX_LEN, "%s/%s", dirpath, ep->d_name);
if(lstat(&*buff, &dtype) == 0) {
if(S_ISDIR(dtype.st_mode)) {
if(!(strcmp(ep->d_name, ".") == 0 || strcmp(ep->d_name, "..") == 0)) {
printoutrd("Removing: ");
printoutrd(buff);
printoutrd("
");
removeDirectory(buff);
}
} else if(S_ISLNK(dtype.st_mode)) {
printoutrd("Removing: ");
printoutrd(buff);
printoutrd("
");
unlink(buff);
} else {
printoutrd("Removing: ");
printoutrd(buff);
printoutrd("
");
remove(buff);
}
} else {
printoutrd("Couldn't stat path
");
}
}
closedir(directory);
printoutrd("Removing: ");
printoutrd((char *)dirpath);
printoutrd("
");
remove(dirpath);
} else {
printoutrd("Failed to open directory
");
}
}
int main(void) {
console = fopen("/dev/console", "w");
removeDirectory("/mnt/");
fclose(console);
reboot(RB_AUTOBOOT);
exit(0);
}
Revise this Paste
Children: 72546