diff options
author | Bill Richardson <wfrichar@chromium.org> | 2015-01-30 12:22:28 -0800 |
---|---|---|
committer | ChromeOS Commit Bot <chromeos-commit-bot@chromium.org> | 2015-01-31 05:42:48 +0000 |
commit | 2559338dbdacbcbd3ae426337403196135bbc7e8 (patch) | |
tree | fb87c9b5b7058e14349f16cac2dc81966942ea87 /futility/futility.h | |
parent | 65ce99b3e2c75bbb416b6edf78b5ea0d7f8c3a94 (diff) | |
download | vboot-2559338dbdacbcbd3ae426337403196135bbc7e8.tar.gz |
futility: refactor file type detection into new files
This moves the what-kind-of-file-is-this logic into a separate
file, and makes it work by calling distinct recognizers until one
hits. A new "-t" option to the show command prints what it's
doing.
BUG=chromium:228932
BRANCH=ToT
TEST=make runtests
Change-Id: Id8f60bdf3fe6a9adf41b4555b3448a261fa52fea
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/245122
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Diffstat (limited to 'futility/futility.h')
-rw-r--r-- | futility/futility.h | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/futility/futility.h b/futility/futility.h index 652b5fbc..5f9a5b78 100644 --- a/futility/futility.h +++ b/futility/futility.h @@ -85,11 +85,29 @@ int print_hwid_digest(GoogleBinaryBlockHeader *gbb, /* Copies a file or dies with an error message */ void futil_copy_file_or_die(const char *infile, const char *outfile); -/* Wrapper for mmap/munmap. Returns 0 on success. Skips stupidly large files. */ +/* Possible file operation errors */ +enum futil_file_err { + FILE_ERR_NONE, + FILE_ERR_STAT, + FILE_ERR_SIZE, + FILE_ERR_MMAP, + FILE_ERR_MSYNC, + FILE_ERR_MUNMAP, + FILE_ERR_OPEN, + FILE_ERR_CLOSE, + FILE_ERR_DIR, + FILE_ERR_CHR, + FILE_ERR_FIFO, + FILE_ERR_SOCK, +}; + +/* Wrapper for mmap/munmap. Skips stupidly large files. */ #define MAP_RO 0 #define MAP_RW 1 -int futil_map_file(int fd, int writeable, uint8_t **buf, uint32_t *len); -int futil_unmap_file(int fd, int writeable, uint8_t *buf, uint32_t len); +enum futil_file_err futil_map_file(int fd, int writeable, + uint8_t **buf, uint32_t *len); +enum futil_file_err futil_unmap_file(int fd, int writeable, + uint8_t *buf, uint32_t len); /* The CPU architecture is occasionally important */ enum arch_t { |