Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(577)

Unified Diff: runtime/bin/directory_linux.cc

Issue 2556313002: Handle non-regular file types in the directory lister (Closed)
Patch Set: Fix typos Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/bin/directory_android.cc ('k') | runtime/bin/directory_macos.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/directory_linux.cc
diff --git a/runtime/bin/directory_linux.cc b/runtime/bin/directory_linux.cc
index 43ee54833aee95a4a4110d2f65280e853dc95515..6917f21b7e1aa70f0c560b1cab14ecb319714315 100644
--- a/runtime/bin/directory_linux.cc
+++ b/runtime/bin/directory_linux.cc
@@ -127,6 +127,10 @@ ListType DirectoryListingEntry::Next(DirectoryListing* listing) {
return Next(listing);
}
return kListDirectory;
+ case DT_BLK:
+ case DT_CHR:
+ case DT_FIFO:
+ case DT_SOCK:
case DT_REG:
return kListFile;
case DT_LNK:
@@ -182,15 +186,23 @@ ListType DirectoryListingEntry::Next(DirectoryListing* listing) {
return Next(listing);
}
return kListDirectory;
- } else if (S_ISREG(entry_info.st_mode)) {
+ } else if (S_ISREG(entry_info.st_mode) || S_ISCHR(entry_info.st_mode) ||
+ S_ISBLK(entry_info.st_mode) ||
+ S_ISFIFO(entry_info.st_mode) ||
+ S_ISSOCK(entry_info.st_mode)) {
return kListFile;
} else if (S_ISLNK(entry_info.st_mode)) {
return kListLink;
+ } else {
+ FATAL1("Unexpected st_mode: %d\n", entry_info.st_mode);
+ return kListError;
}
}
default:
- break;
+ // We should have covered all the bases. If not, let's get an error.
+ FATAL1("Unexpected d_type: %d\n", entry->d_type);
+ return kListError;
}
}
done_ = true;
« no previous file with comments | « runtime/bin/directory_android.cc ('k') | runtime/bin/directory_macos.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698