remove inode printing
This commit is contained in:
parent
6bcc4f1694
commit
0b288364c1
|
@ -43,7 +43,7 @@ void listdir (const char *name) {
|
|||
}
|
||||
else{
|
||||
file_cnt++;
|
||||
printf("[f] %d %s/%s\n", (int)entry->d_ino, name, entry->d_name);
|
||||
printf("[f] %s/%s\n", name, entry->d_name);
|
||||
|
||||
char path[4096];
|
||||
int len = snprintf(path, sizeof(path) - 1, "%s/%s", name, entry->d_name);
|
||||
|
@ -60,7 +60,10 @@ void listdir (const char *name) {
|
|||
}
|
||||
|
||||
int main (int argc, char** argv) {
|
||||
const char* dirpath = argc > 1 ? argv[1] : ".";
|
||||
char dirpath[4096];
|
||||
if (argc > 1) realpath(argv[1], dirpath);
|
||||
else realpath(".", dirpath);
|
||||
|
||||
listdir(dirpath);
|
||||
printf("\ntotals\nfile count: %d\tdir count: %d\tlink count: %d\nspace used: %lu blocks\n\t%lu bytes\n", file_cnt, dir_cnt, link_cnt, space_used, space_used*512);
|
||||
return 0;
|
||||
|
|
|
@ -32,6 +32,7 @@ bool listFileAndType(const string &dir) {
|
|||
else {
|
||||
if (ht[dp->d_ino]) continue;
|
||||
string statpath;
|
||||
// char *linkname;
|
||||
|
||||
statpath = dir + "/" + file;
|
||||
stat(statpath.c_str(), &buf);
|
||||
|
@ -44,8 +45,9 @@ bool listFileAndType(const string &dir) {
|
|||
break;
|
||||
case DT_LNK:
|
||||
lnkcnt++;
|
||||
// char* linkname;
|
||||
char linkname[buf.st_size + 1];
|
||||
// linkname = malloc(buf.st_size + 1);
|
||||
char* linkname;
|
||||
ssize_t r;
|
||||
r = readlink(statpath.c_str(), linkname, buf.st_size + 1);
|
||||
linkname[buf.st_size] = '\0';
|
||||
|
|
Loading…
Reference in New Issue