Added --update flag to see if we need to try opening the output before creating it
authorRobert Pengelly <robertapengelly@hotmail.com>
Thu, 18 Jul 2024 11:33:17 +0000 (12:33 +0100)
committerRobert Pengelly <robertapengelly@hotmail.com>
Thu, 18 Jul 2024 11:33:17 +0000 (12:33 +0100)
Makefile.zpg [new file with mode: 0644]
lib.c
parted.c
parted.h

diff --git a/Makefile.zpg b/Makefile.zpg
new file mode 100644 (file)
index 0000000..f2b4730
--- /dev/null
@@ -0,0 +1,27 @@
+#******************************************************************************
+# @file             Makefile.zpg
+#******************************************************************************
+
+# makefile.zpg should have been run in pdpclib first
+
+CC=gcc370
+COPTS=-S -Os -fno-common -U__MVS__ -D__MF32__ -D__PDOSGEN__ \
+    -D__NOBIVA__ -D__PDOS__ \
+    -I . -I../pdos/pdpclib -I../pdos/src -I../pdos/generic
+AS=as370
+LD=pdld --oformat mainframe -e __crt0
+
+COBJ=lib.obj parted.obj report.obj write7x.obj
+
+all: clean parted.exe
+
+parted.exe: $(COBJ)
+  $(LD) -s -o parted.exe ../pdos/pdpclib/pgastart.o $(COBJ)
+
+.c.obj:
+  $(CC) $(COPTS) $<
+  $(AS) -o $@ $*.s
+  rm -f $*.s
+
+clean:
+  rm -f *.obj parted.exe
diff --git a/lib.c b/lib.c
index 2f9c94765140cd45a6bd98b7e45883354a11c440..091fcac92be02bbdf16a652bfb80c059df513487 100644 (file)
--- a/lib.c
+++ b/lib.c
@@ -28,7 +28,8 @@ enum options {
     OPTION_BOOT,
     OPTION_HELP,
     OPTION_LABEL,
-    OPTION_PART
+    OPTION_PART,
+    OPTION_UPDATE
 
 };
 
@@ -36,7 +37,10 @@ static struct option opts[] = {
 
     { "-arca",      OPTION_ARCA,        OPTION_NO_ARG   },
     { "-boot",      OPTION_BOOT,        OPTION_HAS_ARG  },
+    
     { "-help",      OPTION_HELP,        OPTION_NO_ARG   },
+    { "-update",    OPTION_UPDATE,      OPTION_NO_ARG   },
+    
     { 0,            0,                  0               }
 
 };
@@ -488,6 +492,13 @@ void parse_args (int *pargc, char ***pargv, int optind) {
             
             }
             
+            case OPTION_UPDATE: {
+            
+                state->update = 1;
+                break;
+            
+            }
+            
             default: {
             
                 report_at (program_name, 0, REPORT_ERROR, "unsupported option '%s'", r);
index dd809e772a1ec2640b3111b0b58325db16803a9c..acb27011bbb12713201e9ceac0282188842896cc 100644 (file)
--- a/parted.c
+++ b/parted.c
@@ -430,7 +430,7 @@ int main (int argc, char **argv) {
     state->image_size += 512;
     state->image_size += sizeof (footer);
     
-    if ((ofp = fopen (state->outfile, "r+b")) == NULL) {
+    if (!state->update || (ofp = fopen (state->outfile, "r+b")) == NULL) {
     
         void *zero;
         long len;
index bee4997e2ac3304dd9d5e0d915b527ccd1fd6368..07cbcf76db8a5655d4ab589914d6522e3f860b76 100644 (file)
--- a/parted.h
+++ b/parted.h
@@ -19,7 +19,7 @@ struct parted_state {
     long nb_parts;
     
     long image_size;
-    int chs_align;
+    int chs_align, update;
 
 };