Files
oldlinux-files/bin-src/build.c.patch
2024-02-19 00:21:55 -05:00

90 lines
2.2 KiB
Diff

*** build.c.orig Sat Nov 9 21:50:51 1991
--- build.c Sat Nov 9 22:23:13 1991
***************
*** 17,24 ****
--- 17,27 ----
*/
#include <stdio.h> /* fprintf */
+ #include <string.h>
#include <stdlib.h> /* contains exit */
#include <sys/types.h> /* unistd.h needs this */
+ #include <sys/stat.h>
+ #include <linux/fs.h>
#include <unistd.h> /* contains read/write */
#include <fcntl.h>
***************
*** 25,30 ****
--- 28,36 ----
#define MINIX_HEADER 32
#define GCC_HEADER 1024
+ #define DEFAULT_MAJOR_ROOT 3
+ #define DEFAULT_MINOR_ROOT 6
+
/* max nr of sectors of setup: don't change unless you also change
* bootsect etc */
#define SETUP_SECTS 4
***************
*** 46,54 ****
{
int i,c,id;
char buf[1024];
! if (argc != 4)
usage();
for (i=0;i<sizeof buf; i++) buf[i]=0;
if ((id=open(argv[1],O_RDONLY,0))<0)
die("Unable to open 'boot'");
--- 52,85 ----
{
int i,c,id;
char buf[1024];
+ char major_root, minor_root;
+ struct stat sb;
! if ((argc != 4) && (argc != 5))
usage();
+ if (argc == 5) {
+ if (strcmp(argv[4], "FLOPPY")) {
+ if (stat(argv[4], &sb)) {
+ perror(argv[4]);
+ die("Couldn't stat root device.");
+ }
+ major_root = MAJOR(sb.st_rdev);
+ minor_root = MINOR(sb.st_rdev);
+ } else {
+ major_root = 0;
+ minor_root = 0;
+ }
+ } else {
+ major_root = DEFAULT_MAJOR_ROOT;
+ minor_root = DEFAULT_MINOR_ROOT;
+ }
+ fprintf(stderr, "Root device is (%d, %d)\n", major_root, minor_root);
+ if ((major_root != 2) && (major_root != 3) &&
+ (major_root != 0)) {
+ fprintf(stderr, "Illegal root device (major = %d)\n",
+ major_root);
+ die("Bad root device --- major #");
+ }
for (i=0;i<sizeof buf; i++) buf[i]=0;
if ((id=open(argv[1],O_RDONLY,0))<0)
die("Unable to open 'boot'");
***************
*** 72,77 ****
--- 103,110 ----
die("Boot block must be exactly 512 bytes");
if ((*(unsigned short *)(buf+510)) != 0xAA55)
die("Boot block hasn't got boot flag (0xAA55)");
+ buf[508] = (char) minor_root;
+ buf[509] = (char) major_root;
i=write(1,buf,512);
if (i!=512)
die("Write call failed");