diff options
author | Karel Zak | 2013-02-26 14:16:02 +0100 |
---|---|---|
committer | Karel Zak | 2013-02-26 14:16:53 +0100 |
commit | dad88cb3573fd204971365fed6f7797c4b355946 (patch) | |
tree | cdb49606c0c0fa05ada3e5a3b6bbe9baea230ead /libmount/src/utils.c | |
parent | umount: improve --recursive docs (diff) | |
download | kernel-qcow2-util-linux-dad88cb3573fd204971365fed6f7797c4b355946.tar.gz kernel-qcow2-util-linux-dad88cb3573fd204971365fed6f7797c4b355946.tar.xz kernel-qcow2-util-linux-dad88cb3573fd204971365fed6f7797c4b355946.zip |
libmount: optimize tab files parsing
- ignore empty files
- ignore empty tables
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'libmount/src/utils.c')
-rw-r--r-- | libmount/src/utils.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/libmount/src/utils.c b/libmount/src/utils.c index 1c37062e6..1d4fd0e4b 100644 --- a/libmount/src/utils.c +++ b/libmount/src/utils.c @@ -54,6 +54,17 @@ int startswith(const char *s, const char *sx) return !strncmp(s, sx, off); } +/* + * Return 1 if the file does not accessible of empty + */ +int is_file_empty(const char *name) +{ + struct stat st; + assert(name); + + return (stat(name, &st) != 0 || st.st_size == 0); +} + int mnt_parse_offset(const char *str, size_t len, uintmax_t *res) { char *p; |