summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2008-01-24 14:22:29 -0800
committerH. Peter Anvin <hpa@zytor.com>2008-01-24 14:22:29 -0800
commit5a8e4fc8351b5d40bc05ad99d88a2355337dd899 (patch)
treeffca1960e0dafeac9a05d2238cea1d7719913eba
parent6ae24916aca569363cb9808ee5866ec536b96c64 (diff)
downloadsyslinux-5a8e4fc8351b5d40bc05ad99d88a2355337dd899.tar.gz
extlinux: early check for ext2/ext3-ness of filesystemsyslinux-3.61-pre5
Verify that we have an ext2 or ext3 filesystem early on.
-rw-r--r--extlinux/extlinux.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/extlinux/extlinux.c b/extlinux/extlinux.c
index 58261b44..742859a9 100644
--- a/extlinux/extlinux.c
+++ b/extlinux/extlinux.c
@@ -36,6 +36,7 @@ typedef uint64_t u64;
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/mount.h>
+#include <sys/vfs.h>
#include <linux/fd.h> /* Floppy geometry */
#include <linux/hdreg.h> /* Hard disk geometry */
@@ -804,6 +805,7 @@ install_loader(const char *path, int update_only)
struct stat st, fst;
int devfd, rv;
const char *devname = NULL;
+ struct statfs sfs;
#ifndef __KLIBC__
struct mntent *mnt = NULL;
struct stat dst;
@@ -815,6 +817,16 @@ install_loader(const char *path, int update_only)
return 1;
}
+ if ( statfs(path, &sfs) ) {
+ fprintf(stderr, "%s: statfs %s: %s\n", program, path, strerror(errno));
+ return 1;
+ }
+
+ if ( sfs.f_type != EXT2_SUPER_MAGIC ) {
+ fprintf(stderr, "%s: not an ext2/ext3 filesystem: %s\n", program, path);
+ return 1;
+ }
+
devfd = -1;
#ifdef __KLIBC__