info-mtools
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Mtools] patch: specify conf details on command line


From: Joe Soroka
Subject: [Mtools] patch: specify conf details on command line
Date: Wed, 23 May 2007 00:47:07 -0700

I'm building some disk images as part of a makefile, and they need to
have proper partitions.  Setting up dummy conf files and getting them
to load isn't appropriate, so I hacked up this quick patch.  Use a
pipe character in the "-i filename" style and everything after is
considered part of an anonymous conf file.

e.g.
mpartition -i 'myimage.dat|partition=1 other_opt=X' ... ::
or,
mpartition -i '|file="myimage.dat" partition=1 other_opt=X' ... ::

------------------------------------------------------------------------------
diff -Naur config.c config.c.patched
--- config.c    2007-05-22 02:23:44.859375000 -0700
+++ config.c.patched    2007-05-23 00:14:34.218750000 -0700
@@ -205,7 +205,7 @@

static int mtools_getline(void)
{
-    if(!fgets(buffer, MAX_LINE_LEN, fp))
+    if(!fp || !fgets(buffer, MAX_LINE_LEN, fp))
        return -1;
    linenumber++;
    pos = buffer;
@@ -511,6 +511,8 @@
        mstoupper[i] = get_number();
}

+static int parse_one(int privilege);
+
void set_cmd_line_image(char *img, int flags) {
  prepend();
  devices[cur_dev].drive = ':';
@@ -521,6 +523,19 @@
  devices[cur_dev].heads = 0;
  devices[cur_dev].sectors = 0;
  devices[cur_dev].offset = 0;
+  if (strchr(devices[cur_dev].name, '|')) {
+    char *pipechar = strchr(devices[cur_dev].name, '|');
+    *pipechar = 0;
+    strncpy(buffer, pipechar+1, MAX_LINE_LEN);
+    buffer[MAX_LINE_LEN] = '\0';
+    fp = NULL;
+    filename = "{command line}";
+    linenumber = 0;
+    lastTokenLinenumber = 0;
+    pos = buffer;
+    token = 0;
+    while (parse_one(0));
+  }
}

static void parse_old_device_line(char drive)


reply via email to

[Prev in Thread] Current Thread [Next in Thread]