diff options
author | Nick Kralevich <nnk@google.com> | 2015-03-05 12:50:23 -0800 |
---|---|---|
committer | Nick Kralevich <nnk@google.com> | 2015-03-05 12:50:23 -0800 |
commit | 24751743d7daa0da7ff60c43afe2f5e8ea4fc8eb (patch) | |
tree | 1adc755fc23c78b14e896d049dd7fb4c8fd543f2 /fstrim.c | |
parent | 5054f7ee4fa6e747eb8d08f60ec91ba6a9363878 (diff) | |
download | android_system_vold-24751743d7daa0da7ff60c43afe2f5e8ea4fc8eb.tar.gz android_system_vold-24751743d7daa0da7ff60c43afe2f5e8ea4fc8eb.tar.bz2 android_system_vold-24751743d7daa0da7ff60c43afe2f5e8ea4fc8eb.zip |
fstrim.c: use open(O_DIRECTORY) instead of stat
open(O_DIRECTORY) returns an error if the open attempt
is against anything other than a directory. This basically
duplicates the check that the stat() call was trying to do.
Eliminate the unnecessary stat() call and use O_DIRECTORY
instead.
Change-Id: I1821abbed325f29a7214fdc41ed27cd9e26817d0
Diffstat (limited to 'fstrim.c')
-rw-r--r-- | fstrim.c | 14 |
1 files changed, 1 insertions, 13 deletions
@@ -62,7 +62,6 @@ static void *do_fstrim_filesystems(void *thread_arg) int fd; int ret = 0; struct fstrim_range range = { 0 }; - struct stat sb; extern struct fstab *fstab; int deep_trim = !!thread_arg; @@ -90,18 +89,7 @@ static void *do_fstrim_filesystems(void *thread_arg) continue; /* Should we trim fat32 filesystems? */ } - if (stat(fstab->recs[i].mount_point, &sb) == -1) { - SLOGE("Cannot stat mount point %s\n", fstab->recs[i].mount_point); - ret = -1; - continue; - } - if (!S_ISDIR(sb.st_mode)) { - SLOGE("%s is not a directory\n", fstab->recs[i].mount_point); - ret = -1; - continue; - } - - fd = open(fstab->recs[i].mount_point, O_RDONLY); + fd = open(fstab->recs[i].mount_point, O_RDONLY | O_DIRECTORY | O_CLOEXEC | O_NOFOLLOW); if (fd < 0) { SLOGE("Cannot open %s for FITRIM\n", fstab->recs[i].mount_point); ret = -1; |