From dad88cb3573fd204971365fed6f7797c4b355946 Mon Sep 17 00:00:00 2001 From: Karel Zak Date: Tue, 26 Feb 2013 14:16:02 +0100 Subject: libmount: optimize tab files parsing - ignore empty files - ignore empty tables Signed-off-by: Karel Zak --- libmount/src/utils.c | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'libmount/src/utils.c') 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; -- cgit v1.2.3-55-g7522