diff options
author | Erik Troan <ewt@redhat.com> | 2000-11-17 17:37:11 +0000 |
---|---|---|
committer | Erik Troan <ewt@redhat.com> | 2000-11-17 17:37:11 +0000 |
commit | f942fb8a5541db5a2ae383fa4a5d7e5388cdf34e (patch) | |
tree | ad78eda7b08cb7fb6cbb39f457caa619f8c5d879 /isys/isofs.c | |
parent | 514ad7cda7019e35fd9fe94f0cb28d8462715092 (diff) | |
download | anaconda-f942fb8a5541db5a2ae383fa4a5d7e5388cdf34e.tar.gz anaconda-f942fb8a5541db5a2ae383fa4a5d7e5388cdf34e.tar.xz anaconda-f942fb8a5541db5a2ae383fa4a5d7e5388cdf34e.zip |
added code to check to see if a file is an iso image
Diffstat (limited to 'isys/isofs.c')
-rw-r--r-- | isys/isofs.c | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/isys/isofs.c b/isys/isofs.c new file mode 100644 index 000000000..5ba255ff9 --- /dev/null +++ b/isys/isofs.c @@ -0,0 +1,35 @@ +#include <fcntl.h> +#include <string.h> +#include <unistd.h> + +#define BLOCK_SIZE 2048 + +int fileIsIso(const char * file) { + int blkNum; + char magic[5]; + int fd; + + fd = open(file, O_RDONLY); + if (fd < 0) + return 1; + + for (blkNum = 16; blkNum < 100; blkNum++) { + if (lseek(fd, blkNum * BLOCK_SIZE + 1, SEEK_SET) < 0) { + close(fd); + return 1; + } + + if (read(fd, magic, sizeof(magic)) != sizeof(magic)) { + close(fd); + return 1; + } + + if (!strncmp(magic, "CD001", 5)) { + close(fd); + return 0; + } + } + + close(fd); + return 1; +} |