summaryrefslogtreecommitdiff
path: root/syslinux-nomtools.c
diff options
context:
space:
mode:
authorhpa <hpa>2003-07-11 01:17:44 +0000
committerhpa <hpa>2003-07-11 01:17:44 +0000
commit80e84b3714db5a355729a535cfad6ad2cfd1ef30 (patch)
tree42ac33b8d43650ff740311070018245098d040a7 /syslinux-nomtools.c
parenta4c27d72bbd9286666eb8610ce47cbd7c142b46f (diff)
downloadsyslinux-80e84b3714db5a355729a535cfad6ad2cfd1ef30.tar.gz
New win32 installer; librarize some stuffsyslinux-2.05-pre3
Diffstat (limited to 'syslinux-nomtools.c')
-rw-r--r--syslinux-nomtools.c111
1 files changed, 3 insertions, 108 deletions
diff --git a/syslinux-nomtools.c b/syslinux-nomtools.c
index f2dba342..b4b95ecd 100644
--- a/syslinux-nomtools.c
+++ b/syslinux-nomtools.c
@@ -52,61 +52,6 @@ uid_t ruid; /* Real uid */
uid_t euid; /* Initial euid */
pid_t mypid;
-enum bs_offsets {
- bsJump = 0x00,
- bsOemName = 0x03,
- bsBytesPerSec = 0x0b,
- bsSecPerClust = 0x0d,
- bsResSectors = 0x0e,
- bsFATs = 0x10,
- bsRootDirEnts = 0x11,
- bsSectors = 0x13,
- bsMedia = 0x15,
- bsFATsecs = 0x16,
- bsSecPerTrack = 0x18,
- bsHeads = 0x1a,
- bsHiddenSecs = 0x1c,
- bsHugeSectors = 0x20,
- bsDriveNumber = 0x24,
- bsReserved1 = 0x25,
- bsBootSignature = 0x26,
- bsVolumeID = 0x27,
- bsVolumeLabel = 0x2b,
- bsFileSysType = 0x36,
- bsCode = 0x3e,
- bsSignature = 0x1fe
-};
-
-/*
- * Access functions for littleendian numbers, possibly misaligned.
- */
-static u_int16_t get_16(unsigned char *p)
-{
- return (u_int16_t)p[0] + ((u_int16_t)p[1] << 8);
-}
-
-static u_int32_t get_32(unsigned char *p)
-{
- return (u_int32_t)p[0] + ((u_int32_t)p[1] << 8) +
- ((u_int32_t)p[2] << 16) + ((u_int32_t)p[3] << 24);
-}
-
-#if 0 /* Not needed */
-static void set_16(unsigned char *p, u_int16_t v)
-{
- p[0] = (v & 0xff);
- p[1] = ((v >> 8) & 0xff);
-}
-
-static void set_32(unsigned char *p, u_int32_t v)
-{
- p[0] = (v & 0xff);
- p[1] = ((v >> 8) & 0xff);
- p[2] = ((v >> 16) & 0xff);
- p[3] = ((v >> 24) & 0xff);
-}
-#endif
-
void usage(void)
{
fprintf(stderr, "Usage: %s [-sf] [-o offset] device\n", program);
@@ -177,8 +122,7 @@ int main(int argc, char *argv[])
const unsigned char *cdp;
int dev_fd, fd;
struct stat st;
- int nb, left, veryold;
- unsigned int sectors, clusters;
+ int nb, left;
int err = 0;
pid_t f, w;
int status;
@@ -256,62 +200,13 @@ int main(int argc, char *argv[])
xpread(dev_fd, sectbuf, 512, offset);
fsync(dev_fd);
-
+
/*
* Check to see that what we got was indeed an MS-DOS boot sector/superblock
*/
-
- if ( sectbuf[bsBootSignature] == 0x29 ) {
- /* It's DOS, and it has all the new nice fields */
-
- veryold = 0;
-
- sectors = get_16(sectbuf+bsSectors);
- sectors = sectors ? sectors : get_32(sectbuf+bsHugeSectors);
- clusters = sectors / sectbuf[bsSecPerClust];
-
- if ( !memcmp(sectbuf+bsFileSysType, "FAT12 ", 8) ) {
- if ( clusters > 4086 ) {
- fprintf(stderr, "%s: ERROR: FAT12 but claims more than 4086 clusters\n",
- device);
- exit(1);
- }
- } else if ( !memcmp(sectbuf+bsFileSysType, "FAT16 ", 8) ) {
- if ( clusters <= 4086 ) {
- fprintf(stderr, "%s: ERROR: FAT16 but claims less than 4086 clusters\n",
- device);
- exit(1);
- }
- } else if ( !memcmp(sectbuf+bsFileSysType, "FAT ", 8) ) {
- /* OS/2 sets up the filesystem as just `FAT'. */
- } else {
- fprintf(stderr, "%s: filesystem type \"%8.8s\" not supported\n",
- device, sectbuf+bsFileSysType);
- exit(1);
- }
- } else {
- veryold = 1;
-
- if ( sectbuf[bsSecPerClust] & (sectbuf[bsSecPerClust] - 1) ||
- sectbuf[bsSecPerClust] == 0 ) {
- fprintf(stderr, "%s: This doesn't look like a FAT filesystem\n",
- device);
- }
-
- sectors = get_16(sectbuf+bsSectors);
- sectors = sectors ? sectors : get_32(sectbuf+bsHugeSectors);
- clusters = sectors / sectbuf[bsSecPerClust];
- }
-
- if ( get_16(sectbuf+bsBytesPerSec) != 512 ) {
- fprintf(stderr, "%s: Sector sizes other than 512 not supported\n",
- device);
+ if(!syslinux_check_bootsect(sectbuf,device)) {
exit(1);
}
- if ( sectbuf[bsSecPerClust] > 32 ) {
- fprintf(stderr, "%s: Cluster sizes larger than 16K not supported\n",
- device);
- }
/*
* Now mount the device.