From: hpa Date: Mon, 20 Dec 2004 04:57:44 +0000 (+0000) Subject: More fixes to the extlinux installer; change back to writable types X-Git-Tag: syslinux-3.11~270 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=d2139276051478c77d6b866fe2217fe9f479826b;p=profile%2Fivi%2Fsyslinux.git More fixes to the extlinux installer; change back to writable types for ulint.h because of stupid constipational warnings. --- diff --git a/extlinux/extlinux.c b/extlinux/extlinux.c index de85fc9..cb8e75a 100644 --- a/extlinux/extlinux.c +++ b/extlinux/extlinux.c @@ -297,7 +297,7 @@ uint64_t get_size(int devfd) * Get device geometry and partition offset */ struct geometry_table { - off_t bytes; + uint64_t bytes; struct hd_big_geometry g; }; @@ -309,7 +309,8 @@ static const struct geometry_table standard_geometries[] = { { 1440*1024, { 2, 18, 80, 0 } }, { 1680*1024, { 2, 21, 80, 0 } }, { 1722*1024, { 2, 21, 80, 0 } }, - { 3840*1024, { 2, 36, 80, 0 } }, + { 2880*1024, { 2, 36, 80, 0 } }, + { 3840*1024, { 2, 48, 80, 0 } }, { 0, {0,0,0,0} } }; @@ -335,6 +336,7 @@ get_geometry(int devfd, uint64_t totalbytes, struct hd_big_geometry *geo) geo->sectors = fd_str.sect; geo->cylinders = fd_str.track; geo->start = 0; + return 0; } /* Didn't work. Let's see if this is one of the standard geometries */ @@ -555,7 +557,7 @@ int install_loader(char *path) { struct stat st, dst, fst; - struct mntent *mnt; + struct mntent *mnt = NULL; int devfd, rv; FILE *mtab; @@ -564,28 +566,45 @@ install_loader(char *path) return 1; } - if ( !(mtab = setmntent("/etc/mtab", "r")) ) { - fprintf(stderr, "%s: cannot open /etc/mtab\n", program); - return 1; + devfd = -1; + + if ( (mtab = setmntent("/proc/mounts", "r")) ) { + while ( (mnt = getmntent(mtab)) ) { + if ( (!strcmp(mnt->mnt_type, "ext2") || + !strcmp(mnt->mnt_type, "ext3")) && + !stat(mnt->mnt_fsname, &dst) && + dst.st_rdev == st.st_dev ) { + fprintf(stderr, "%s is device %s\n", path, mnt->mnt_fsname); + if ( (devfd = open(mnt->mnt_fsname, O_RDWR|O_SYNC)) < 0 ) { + fprintf(stderr, "%s: cannot open device %s\n", program, mnt->mnt_fsname); + return 1; + } + break; + } + } } - devfd = -1; - while ( (mnt = getmntent(mtab)) ) { - if ( (!strcmp(mnt->mnt_type, "ext2") || - !strcmp(mnt->mnt_type, "ext3")) && - !stat(mnt->mnt_fsname, &dst) && - dst.st_rdev == st.st_dev ) { - fprintf(stderr, "%s is device %s\n", path, mnt->mnt_fsname); - if ( (devfd = open(mnt->mnt_fsname, O_RDWR|O_SYNC)) < 0 ) { - fprintf(stderr, "%s: cannot open device %s\n", program, mnt->mnt_fsname); - return 1; + if ( devfd < 0 ) { + /* Didn't find it in /proc/mounts, try /etc/mtab */ + if ( (mtab = setmntent("/etc/mtab", "r")) ) { + while ( (mnt = getmntent(mtab)) ) { + if ( (!strcmp(mnt->mnt_type, "ext2") || + !strcmp(mnt->mnt_type, "ext3")) && + !stat(mnt->mnt_fsname, &dst) && + dst.st_rdev == st.st_dev ) { + fprintf(stderr, "%s is device %s\n", path, mnt->mnt_fsname); + if ( (devfd = open(mnt->mnt_fsname, O_RDWR|O_SYNC)) < 0 ) { + fprintf(stderr, "%s: cannot open device %s\n", program, mnt->mnt_fsname); + return 1; + } + break; + } } - break; } } if ( devfd < 0 ) { - fprintf(stderr, "%s: cannot find device for path %s", program, path); + fprintf(stderr, "%s: cannot find device for path %s\n", program, path); return 1; } diff --git a/libfat/ulint.h b/libfat/ulint.h index c4cf5b4..82a46ac 100644 --- a/libfat/ulint.h +++ b/libfat/ulint.h @@ -47,7 +47,7 @@ write8(le8_t *_p, uint8_t _v) /* Littleendian architectures which support unaligned memory accesses */ static inline unsigned short -read16(const le16_t *_p) +read16(le16_t *_p) { return *((const uint16_t *)_p); } @@ -59,7 +59,7 @@ write16(le16_t *_p, unsigned short _v) } static inline unsigned int -read32(const le32_t *_p) +read32(le32_t *_p) { return *((const uint32_t *)_p); } @@ -75,7 +75,7 @@ write32(le32_t *_p, uint32_t _v) /* Generic, mostly portable versions */ static inline unsigned short -read16(const le16_t *_p) +read16(le16_t *_p) { uint16_t _v; @@ -92,7 +92,7 @@ write16(le16_t *_p, uint16_t _v) } static inline unsigned int -read32(const le32_t *_p) +read32(le32_t *_p) { _v = _p[0]; _v |= _p[1] << 8;