summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDongHun Kwak <dh0128.kwak@samsung.com>2022-01-14 10:51:43 +0900
committerDongHun Kwak <dh0128.kwak@samsung.com>2022-01-14 10:51:43 +0900
commit1f0988e68435f0d7a471e7aac191c87f7db4d09d (patch)
tree612442ec92e194944a41618fd695f30d9c3082fa
parente09dd35edaa16ccfa9ef005b231800fddf2419da (diff)
downloadmtools-1f0988e68435f0d7a471e7aac191c87f7db4d09d.tar.gz
mtools-1f0988e68435f0d7a471e7aac191c87f7db4d09d.tar.bz2
mtools-1f0988e68435f0d7a471e7aac191c87f7db4d09d.zip
Imported Upstream version 4.0.31upstream/4.0.31
-rw-r--r--NEWS22
-rw-r--r--buffer.c5
-rwxr-xr-xconfigure2
-rw-r--r--configure.in2
-rw-r--r--debian/changelog24
-rw-r--r--devices.c160
-rw-r--r--file_name.c2
-rw-r--r--floppyd.12
-rw-r--r--floppyd.c18
-rw-r--r--floppyd_installtest.12
-rw-r--r--init.c6
-rw-r--r--mattrib.12
-rw-r--r--mattrib.c30
-rw-r--r--mbadblocks.12
-rw-r--r--mcat.12
-rw-r--r--mcd.12
-rw-r--r--mclasserase.12
-rw-r--r--mcopy.12
-rw-r--r--mcopy.c2
-rw-r--r--mdel.12
-rw-r--r--mdeltree.12
-rw-r--r--mdir.12
-rw-r--r--mdu.12
-rw-r--r--mformat.12
-rw-r--r--mformat.c221
-rw-r--r--minfo.12
-rw-r--r--mkmanifest.12
-rw-r--r--mlabel.12
-rw-r--r--mmd.12
-rw-r--r--mmount.12
-rw-r--r--mmove.12
-rw-r--r--mpartition.12
-rw-r--r--mpartition.c5
-rw-r--r--mrd.12
-rw-r--r--mren.12
-rw-r--r--mshortname.12
-rw-r--r--mshowfat.12
-rw-r--r--mtools.14
-rw-r--r--mtools.54
-rw-r--r--mtools.info6
-rw-r--r--mtools.spec24
-rw-r--r--mtools.tmpl.14
-rw-r--r--mtools.tmpl.54
-rw-r--r--mtoolstest.12
-rw-r--r--mtype.12
-rw-r--r--mzip.12
-rw-r--r--open_image.c6
-rw-r--r--open_image.h6
-rw-r--r--patchlevel.c6
-rw-r--r--plain_io.c9
-rw-r--r--stream.c3
-rw-r--r--sysincludes.h3
-rw-r--r--version.texi4
-rw-r--r--xdf_io.c4
54 files changed, 371 insertions, 269 deletions
diff --git a/NEWS b/NEWS
index 0bcc41e..ed7fa51 100644
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,25 @@
+v4_0_31
+ - Move Linux-specific block device sizing code into
+ linux-specific section of devices.c
+ - Error messages for all failure cases on fs_init failure
+ - Fix compilation without XDF support (OpenImage signature)
+ - Fix polarity of format_xdf command-line parameter of mformat
+ - In XDF_IO retry enough times to actually succeed, even if
+ FDC was in a bad state before
+ - Remove useless buffer flushing triggered when giving up a
+ reference to a stream node that is still referenced
+ elsewhere.
+ - Clearer error message if neither size nor geometry of drive
+ to be mformatted is known
+ - In mformat, make Fs dynamically allocated rather than
+ on-stack, so as to be able to use utilities supplied by
+ stream.c
+ - Remove duplicate writing of backup boot sector
+ - Allow to infer geometry if only size is specified
+ - Protect against attempt to create zero-sized buffer
+ - Code simplification in mattrib
+ - Remove dead code in mpartition
+
v4_0_30
- Fixed XDF floppy disk access
- Fixed faulty behavior at end of image in mcat
diff --git a/buffer.c b/buffer.c
index 0f10c30..a34270b 100644
--- a/buffer.c
+++ b/buffer.c
@@ -355,6 +355,11 @@ Stream_t *buf_init(Stream_t *Next, size_t size,
Buffer_t *Buffer;
Stream_t *Stream;
+#ifdef HAVE_ASSERT_H
+ assert(size != 0);
+ assert(cylinderSize != 0);
+ assert(sectorSize != 0);
+#endif
if(size % cylinderSize != 0) {
fprintf(stderr, "size not multiple of cylinder size\n");
diff --git a/configure b/configure
index 68d48b9..03ea02c 100755
--- a/configure
+++ b/configure
@@ -4671,7 +4671,7 @@ $as_echo "#define HAVE_STDBOOL_H 1" >>confdefs.h
fi
-for ac_header in getopt.h stdlib.h stdbool.h unistd.h linux/unistd.h \
+for ac_header in assert.h getopt.h stdlib.h stdbool.h unistd.h linux/unistd.h \
libc.h fcntl.h limits.h sys/file.h sys/ioctl.h sys/time.h strings.h string.h \
sys/param.h memory.h malloc.h io.h signal.h sys/signal.h utime.h sgtty.h \
sys/floppy.h mntent.h sys/sysmacros.h netinet/in.h netinet/tcp.h assert.h \
diff --git a/configure.in b/configure.in
index df18141..801e605 100644
--- a/configure.in
+++ b/configure.in
@@ -93,7 +93,7 @@ dnl Checks for header files.
AC_HEADER_STDC
AC_HEADER_SYS_WAIT
AC_HEADER_STDBOOL
-AC_CHECK_HEADERS(getopt.h stdlib.h stdbool.h unistd.h linux/unistd.h \
+AC_CHECK_HEADERS(assert.h getopt.h stdlib.h stdbool.h unistd.h linux/unistd.h \
libc.h fcntl.h limits.h sys/file.h sys/ioctl.h sys/time.h strings.h string.h \
sys/param.h memory.h malloc.h io.h signal.h sys/signal.h utime.h sgtty.h \
sys/floppy.h mntent.h sys/sysmacros.h netinet/in.h netinet/tcp.h assert.h \
diff --git a/debian/changelog b/debian/changelog
index d08fe7e..a52adba 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,27 @@
+mtools (4.0.31) stable; urgency=low
+
+ * Move Linux-specific block device sizing code into
+ linux-specific section of devices.c
+ * Error messages for all failure cases on fs_init failure
+ * Fix compilation without XDF support (OpenImage signature)
+ * Fix polarity of format_xdf command-line parameter of mformat
+ * In XDF_IO retry enough times to actually succeed, even if
+ FDC was in a bad state before
+ * Remove useless buffer flushing triggered when giving up a
+ reference to a stream node that is still referenced
+ elsewhere.
+ * Clearer error message if neither size nor geometry of drive
+ to be mformatted is known
+ * In mformat, make Fs dynamically allocated rather than
+ on-stack, so as to be able to use utilities supplied by
+ stream.c
+ * Remove duplicate writing of backup boot sector
+ * Allow to infer geometry if only size is specified
+ * Protect against attempt to create zero-sized buffer
+ * Code simplification in mattrib
+ * Remove dead code in mpartition
+
+ -- Alain Knaff <alain@knaff.lu> Sat, 19 Jun 2021 17:22:27 +0200
mtools (4.0.30) stable; urgency=low
* Fixed XDF floppy disk access
diff --git a/devices.c b/devices.c
index f5cb00d..0d2dd23 100644
--- a/devices.c
+++ b/devices.c
@@ -798,6 +798,86 @@ static __inline__ int get_parameters(int fd, struct floppy_struct *floppy)
return ioctl(fd, FDGETPRM, floppy);
}
+#include "linux/hdreg.h"
+#include "linux/fs.h"
+
+static uint32_t ulong_to_sectors(unsigned long raw_sect) {
+ /* Number of sectors must fit into 32bit value */
+ if (raw_sect > ULONG_MAX) {
+ fprintf(stderr, "Too many sectors for FAT %8lx\n",raw_sect);
+ exit(1);
+ }
+ return (uint32_t) raw_sect;
+}
+
+int get_sector_size(int fd) {
+ int sec_size;
+ if (ioctl(fd, BLKSSZGET, &sec_size) != 0 || sec_size <= 0) {
+ fprintf(stderr, "Could not get sector size of device (%s)",
+ strerror(errno));
+ return -1;
+ }
+
+ /* Cap sector size at 4096 */
+ if(sec_size > 4096)
+ sec_size = 4096;
+ return sec_size;
+}
+
+static int get_block_geom(int fd, struct device *dev) {
+ struct hd_geometry geom;
+ int sec_size;
+ unsigned long size;
+ uint16_t heads=dev->heads;
+ uint16_t sectors=dev->sectors;
+ uint32_t sect_per_track;
+
+ if (ioctl(fd, HDIO_GETGEO, &geom) < 0) {
+ fprintf(stderr, "Could not get geometry of device (%s)",
+ strerror(errno));
+ return -1;
+ }
+
+ if (ioctl(fd, BLKGETSIZE, &size) < 0) {
+ fprintf(stderr, "Could not get size of device (%s)",
+ strerror(errno));
+ return -1;
+ }
+
+ sec_size = get_sector_size(fd);
+ if(sec_size < 0)
+ return -1;
+
+ dev->ssize = 0;
+ while (dev->ssize < 0x7F && (128 << dev->ssize) < sec_size)
+ dev->ssize++;
+
+ if(!heads)
+ heads = geom.heads;
+ if(!sectors)
+ sectors = geom.sectors;
+
+ sect_per_track = heads * sectors;
+ if(!dev->hidden) {
+ uint32_t hidden;
+ hidden = geom.start % sect_per_track;
+ if(hidden && hidden != sectors) {
+ fprintf(stderr,
+ "Hidden (%d) does not match sectors (%d)\n",
+ hidden, sectors);
+ return -1;
+ }
+ dev->hidden = hidden;
+ }
+ dev->heads = heads;
+ dev->sectors = sectors;
+ if(!dev->tracks)
+ dev->tracks = ulong_to_sectors((size + dev->hidden % sect_per_track) / sect_per_track);
+ return 0;
+}
+
+#define HAVE_GET_BLOCK_GEOM
+
#endif /* linux */
@@ -986,90 +1066,13 @@ struct device devices[] = {
#endif
#undef INIT_NOOP
-#include "linux/hdreg.h"
-#include "linux/fs.h"
-
-static uint32_t ulong_to_sectors(unsigned long raw_sect) {
- /* Number of sectors must fit into 32bit value */
- if (raw_sect > ULONG_MAX) {
- fprintf(stderr, "Too many sectors for FAT %8lx\n",raw_sect);
- exit(1);
- }
- return (uint32_t) raw_sect;
-}
-
-int get_sector_size(int fd) {
- int sec_size;
- if (ioctl(fd, BLKSSZGET, &sec_size) != 0 || sec_size <= 0) {
- fprintf(stderr, "Could not get sector size of device (%s)",
- strerror(errno));
- return -1;
- }
-
- /* Cap sector size at 4096 */
- if(sec_size > 4096)
- sec_size = 4096;
- return sec_size;
-}
-
-static int get_block_geom(int fd, struct device *dev) {
- struct hd_geometry geom;
- int sec_size;
- unsigned long size;
- uint16_t heads=dev->heads;
- uint16_t sectors=dev->sectors;
- uint32_t sect_per_track;
-
- if (ioctl(fd, HDIO_GETGEO, &geom) < 0) {
- fprintf(stderr, "Could not get geometry of device (%s)",
- strerror(errno));
- return -1;
- }
-
- if (ioctl(fd, BLKGETSIZE, &size) < 0) {
- fprintf(stderr, "Could not get size of device (%s)",
- strerror(errno));
- return -1;
- }
-
- sec_size = get_sector_size(fd);
- if(sec_size < 0)
- return -1;
-
- dev->ssize = 0;
- while (dev->ssize < 0x7F && (128 << dev->ssize) < sec_size)
- dev->ssize++;
-
- if(!heads)
- heads = geom.heads;
- if(!sectors)
- sectors = geom.sectors;
-
- sect_per_track = heads * sectors;
- if(!dev->hidden) {
- uint32_t hidden;
- hidden = geom.start % sect_per_track;
- if(hidden && hidden != sectors) {
- fprintf(stderr,
- "Hidden (%d) does not match sectors (%d)\n",
- hidden, sectors);
- return -1;
- }
- dev->hidden = hidden;
- }
- dev->heads = heads;
- dev->sectors = sectors;
- if(!dev->tracks)
- dev->tracks = ulong_to_sectors((size + dev->hidden % sect_per_track) / sect_per_track);
- return 0;
-}
-
int init_geom(int fd, struct device *dev, struct device *orig_dev,
struct MT_STAT *statbuf)
{
struct generic_floppy_struct floppy;
int change;
+#ifdef HAVE_GET_BLOCK_GEOM
/**
* Block device which *isn't* a floppy device
*/
@@ -1078,6 +1081,7 @@ int init_geom(int fd, struct device *dev, struct device *orig_dev,
get_block_geom(fd, dev);
return compare_geom(dev, orig_dev);
}
+#endif
/*
* succeed if we don't have a floppy
diff --git a/file_name.c b/file_name.c
index 5ea4191..d058849 100644
--- a/file_name.c
+++ b/file_name.c
@@ -112,7 +112,7 @@ void dos_name(doscp_t *toDos, const char *name, int verbose UNUSEDP,
name = &name[2];
/* zap the leading path */
- name = (char *) _basename(name);
+ name = _basename(name);
if ((s = strrchr(name, '\\')))
name = s + 1;
diff --git a/floppyd.1 b/floppyd.1
index 5acec74..844cac5 100644
--- a/floppyd.1
+++ b/floppyd.1
@@ -1,5 +1,5 @@
'\" t
-.TH floppyd 1 "17Jun21" mtools-4.0.30
+.TH floppyd 1 "19Jun21" mtools-4.0.31
.SH Name
floppyd - floppy daemon for remote access to floppy drive
'\" t
diff --git a/floppyd.c b/floppyd.c
index 4ba02aa..ef96222 100644
--- a/floppyd.c
+++ b/floppyd.c
@@ -108,7 +108,7 @@
unsigned int mtools_lock_timeout=30;
-void serve_client(int sock, char **device_name, unsigned int n_dev,
+void serve_client(int sock, const char *const*device_name, unsigned int n_dev,
int close_stderr);
@@ -750,9 +750,9 @@ static void alarm_signal(int a UNUSEDP)
/*
* This is the main loop when running as a server.
*/
-static void server_main_loop(int sock, char **device_name,
+static void server_main_loop(int sock, const char *const*device_name,
unsigned int n_dev) NORETURN;
-static void server_main_loop(int sock, char **device_name,
+static void server_main_loop(int sock, const char *const*device_name,
unsigned int n_dev)
{
struct sockaddr_in addr;
@@ -787,7 +787,7 @@ static void server_main_loop(int sock, char **device_name,
* Start the proxy work in the new socket.
*/
#endif
- serve_client(new_sock,device_name, n_dev, 0);
+ serve_client(new_sock, device_name, n_dev, 0);
exit(0);
#if DEBUG == 0
}
@@ -840,7 +840,7 @@ int main (int argc, char** argv)
char* username = strdup("nobody");
int sock;
- char **device_name = NULL;
+ const char *const* device_name = NULL;
const char *floppy0 = "/dev/fd0";
unsigned int n_dev;
@@ -884,10 +884,10 @@ int main (int argc, char** argv)
}
if(optind < argc) {
- device_name = argv + optind;
+ device_name = (const char * const *) argv + optind;
n_dev = (unsigned int) (argc - optind);
} else {
- device_name = (char **)&floppy0;
+ device_name = &floppy0;
n_dev = 1;
}
@@ -1054,8 +1054,8 @@ static void cleanup(int x UNUSEDP) {
#include "lockdev.h"
-void serve_client(int sockhandle, char **device_name, unsigned int n_dev,
- int close_stderr) {
+void serve_client(int sockhandle, const char *const*device_name,
+ unsigned int n_dev, int close_stderr) {
Packet opcode;
Packet parm;
diff --git a/floppyd_installtest.1 b/floppyd_installtest.1
index 9291f05..af75bdb 100644
--- a/floppyd_installtest.1
+++ b/floppyd_installtest.1
@@ -1,5 +1,5 @@
'\" t
-.TH floppyd_installtest 1 "17Jun21" mtools-4.0.30
+.TH floppyd_installtest 1 "19Jun21" mtools-4.0.31
.SH Name
floppyd_installtest - tests whether floppyd is installed and running
'\" t
diff --git a/init.c b/init.c
index c31fbb9..2b6440b 100644
--- a/init.c
+++ b/init.c
@@ -418,8 +418,10 @@ Stream_t *fs_init(char drive, int mode, int *isRop)
* else result of the AND would be 0x1xx
*/
struct OldDos_t *params=getOldDosByMedia(media);
- if(params == NULL)
+ if(params == NULL) {
+ fprintf(stderr, "Unknown media byte %02x\n", media);
return NULL;
+ }
This->cluster_size = params->cluster_size;
tot_sectors = cylinder_size * params->tracks;
This->fat_start = 1;
@@ -529,6 +531,7 @@ Stream_t *fs_init(char drive, int mode, int *isRop)
/* read the FAT sectors */
if(fat_read(This, &boot, tot_sectors, dev.use_2m&0x7f)){
+ fprintf(stderr, "Error reading FAT\n");
This->num_fat = 1;
FREE(&This->Next);
Free(This->Next);
@@ -538,6 +541,7 @@ Stream_t *fs_init(char drive, int mode, int *isRop)
/* Set the codepage */
This->cp = cp_open(dev.codepage);
if(This->cp == NULL) {
+ fprintf(stderr, "Error setting code page\n");
fs_free((Stream_t *)This);
FREE(&This->Next);
Free(This->Next);
diff --git a/mattrib.1 b/mattrib.1
index d35a5ef..4b1a01e 100644
--- a/mattrib.1
+++ b/mattrib.1
@@ -1,5 +1,5 @@
'\" t
-.TH mattrib 1 "17Jun21" mtools-4.0.30
+.TH mattrib 1 "19Jun21" mtools-4.0.31
.SH Name
mattrib - change MSDOS file attribute flags
'\" t
diff --git a/mattrib.c b/mattrib.c
index c684e76..5e939d0 100644
--- a/mattrib.c
+++ b/mattrib.c
@@ -25,11 +25,10 @@
#include "mainloop.h"
typedef struct Arg_t {
- unsigned char add;
- unsigned char remove;
- struct MainParam_t mp;
int recursive;
int doPrintName;
+ unsigned char add;
+ unsigned char remove;
} Arg_t;
static int attrib_file(direntry_t *entry, MainParam_t *mp)
@@ -163,6 +162,7 @@ void mattrib(int argc, char **argv, int type UNUSEDP) NORETURN;
void mattrib(int argc, char **argv, int type UNUSEDP)
{
Arg_t arg;
+ struct MainParam_t mp;
int view;
int c;
int concise;
@@ -230,29 +230,29 @@ void mattrib(int argc, char **argv, int type UNUSEDP)
if (optind >= argc)
usage(1);
- init_mp(&arg.mp);
+ init_mp(&mp);
if(view){
if(concise) {
- arg.mp.callback = concise_view_attrib;
+ mp.callback = concise_view_attrib;
arg.doPrintName = (argc - optind > 1 ||
arg.recursive ||
strpbrk(argv[optind], "*[?") != 0);
} else if (replay) {
- arg.mp.callback = replay_attrib;
+ mp.callback = replay_attrib;
} else
- arg.mp.callback = view_attrib;
- arg.mp.openflags = O_RDONLY;
+ mp.callback = view_attrib;
+ mp.openflags = O_RDONLY;
} else {
- arg.mp.callback = attrib_file;
- arg.mp.openflags = O_RDWR;
+ mp.callback = attrib_file;
+ mp.openflags = O_RDWR;
}
if(arg.recursive)
- arg.mp.dirCallback = recursive_attrib;
+ mp.dirCallback = recursive_attrib;
- arg.mp.arg = (void *) &arg;
- arg.mp.lookupflags = ACCEPT_PLAIN | ACCEPT_DIR;
+ mp.arg = (void *) &arg;
+ mp.lookupflags = ACCEPT_PLAIN | ACCEPT_DIR;
if(arg.recursive)
- arg.mp.lookupflags |= DO_OPEN_DIRS | NO_DOTS;
- exit(main_loop(&arg.mp, argv + optind, argc - optind));
+ mp.lookupflags |= DO_OPEN_DIRS | NO_DOTS;
+ exit(main_loop(&mp, argv + optind, argc - optind));
}
diff --git a/mbadblocks.1 b/mbadblocks.1
index 7cd17b4..e1d5f3a 100644
--- a/mbadblocks.1
+++ b/mbadblocks.1
@@ -1,5 +1,5 @@
'\" t
-.TH mbadblocks 1 "17Jun21" mtools-4.0.30
+.TH mbadblocks 1 "19Jun21" mtools-4.0.31
.SH Name
mbadblocks - tests a floppy disk, and marks the bad blocks in the FAT
'\" t
diff --git a/mcat.1 b/mcat.1
index 95216da..b51df32 100644
--- a/mcat.1
+++ b/mcat.1
@@ -1,5 +1,5 @@
'\" t
-.TH mcat 1 "17Jun21" mtools-4.0.30
+.TH mcat 1 "19Jun21" mtools-4.0.31
.SH Name
mcat - dump raw disk image
'\" t
diff --git a/mcd.1 b/mcd.1
index 6b8b944..b38f875 100644
--- a/mcd.1
+++ b/mcd.1
@@ -1,5 +1,5 @@
'\" t
-.TH mcd 1 "17Jun21" mtools-4.0.30
+.TH mcd 1 "19Jun21" mtools-4.0.31
.SH Name
mcd - change MSDOS directory
'\" t
diff --git a/mclasserase.1 b/mclasserase.1
index 3cc7cdb..17d79ff 100644
--- a/mclasserase.1
+++ b/mclasserase.1
@@ -1,5 +1,5 @@
'\" t
-.TH mclasserase 1 "17Jun21" mtools-4.0.30
+.TH mclasserase 1 "19Jun21" mtools-4.0.31
.SH Name
mclasserase - erase memory cards
'\" t
diff --git a/mcopy.1 b/mcopy.1
index b77e95b..122a3e2 100644
--- a/mcopy.1
+++ b/mcopy.1
@@ -1,5 +1,5 @@
'\" t
-.TH mcopy 1 "17Jun21" mtools-4.0.30
+.TH mcopy 1 "19Jun21" mtools-4.0.31
.SH Name
mcopy - copy MSDOS files to/from Unix
'\" t
diff --git a/mcopy.c b/mcopy.c
index 6264af8..8145118 100644
--- a/mcopy.c
+++ b/mcopy.c
@@ -45,7 +45,7 @@ static void set_mtime(const char *target, time_t mtime)
tv[0].tv_usec = 0;
tv[1].tv_sec = mtime;
tv[1].tv_usec = 0;
- utimes((char *)target, tv);
+ utimes(target, tv);
#else
#ifdef HAVE_UTIME
struct utimbuf utbuf;
diff --git a/mdel.1 b/mdel.1
index efe0b87..00c62a0 100644
--- a/mdel.1
+++ b/mdel.1
@@ -1,5 +1,5 @@
'\" t
-.TH mdel 1 "17Jun21" mtools-4.0.30
+.TH mdel 1 "19Jun21" mtools-4.0.31
.SH Name
mdel - delete an MSDOS file
'\" t
diff --git a/mdeltree.1 b/mdeltree.1
index 1a8410f..4a8541e 100644
--- a/mdeltree.1
+++ b/mdeltree.1
@@ -1,5 +1,5 @@
'\" t
-.TH mdeltree 1 "17Jun21" mtools-4.0.30
+.TH mdeltree 1 "19Jun21" mtools-4.0.31
.SH Name
mdeltree - recursively delete an MSDOS directory and its contents
'\" t
diff --git a/mdir.1 b/mdir.1
index 957f202..857744d 100644
--- a/mdir.1
+++ b/mdir.1
@@ -1,5 +1,5 @@
'\" t
-.TH mdir 1 "17Jun21" mtools-4.0.30
+.TH mdir 1 "19Jun21" mtools-4.0.31
.SH Name
mdir - display an MSDOS directory
'\" t
diff --git a/mdu.1 b/mdu.1
index efacf02..8dda217 100644
--- a/mdu.1
+++ b/mdu.1
@@ -1,5 +1,5 @@
'\" t
-.TH mdu 1 "17Jun21" mtools-4.0.30
+.TH mdu 1 "19Jun21" mtools-4.0.31
.SH Name
mdu - display the amount of space occupied by an MSDOS directory
'\" t
diff --git a/mformat.1 b/mformat.1
index 4b36d6c..61bb613 100644
--- a/mformat.1
+++ b/mformat.1
@@ -1,5 +1,5 @@
'\" t
-.TH mformat 1 "17Jun21" mtools-4.0.30
+.TH mformat 1 "19Jun21" mtools-4.0.31
.SH Name
mformat - add an MSDOS filesystem to a low-level formatted floppy disk
'\" t
diff --git a/mformat.c b/mformat.c
index cffdee9..968a8c4 100644
--- a/mformat.c
+++ b/mformat.c
@@ -27,7 +27,6 @@
#include "fsP.h"
#include "file.h"
#include "plain_io.h"
-#include "floppyd_io.h"
#include "nameclash.h"
#include "buffer.h"
#ifdef HAVE_ASSERT_H
@@ -182,9 +181,9 @@ static int comp_fat_bits(Fs_t *Fs, int estimate,
TOTAL_DISK_SIZE((bits), Fs->sector_size, (clusters), \
Fs->num_fat, MAX_BYTES_PER_CLUSTER/Fs->sector_size)
- if(tot_sectors > MAX_DISK_SIZE(12, FAT12-1))
+ if(tot_sectors > MAX_DISK_SIZE(12u, FAT12-1))
needed_fat_bits = 16;
- if(fat32 || tot_sectors > MAX_DISK_SIZE(16, FAT16-1))
+ if(fat32 || tot_sectors > MAX_DISK_SIZE(16u, FAT16-1))
needed_fat_bits = 32;
#undef MAX_DISK_SIZE
@@ -753,7 +752,7 @@ void mformat(int argc, char **argv, int dummy UNUSEDP) NORETURN;
void mformat(int argc, char **argv, int dummy UNUSEDP)
{
int r; /* generic return value */
- Fs_t Fs;
+ Fs_t *Fs;
unsigned int hs;
int hs_set;
unsigned int arguse_2m = 0;
@@ -818,22 +817,28 @@ void mformat(int argc, char **argv, int dummy UNUSEDP)
serial = 0;
fsVersion = 0;
- Fs.cluster_size = 0;
- Fs.refs = 1;
- Fs.dir_len = 0;
+ Fs = New(Fs_t);
+ if (!Fs) {
+ fprintf(stderr, "Out of memory\n");
+ exit(1);
+ }
+
+ Fs->cluster_size = 0;
+ Fs->refs = 1;
+ Fs->dir_len = 0;
if(getenv("MTOOLS_DIR_LEN")) {
- Fs.dir_len = atou16(getenv("MTOOLS_DIR_LEN"));
- if(Fs.dir_len <= 0)
- Fs.dir_len=0;
+ Fs->dir_len = atou16(getenv("MTOOLS_DIR_LEN"));
+ if(Fs->dir_len <= 0)
+ Fs->dir_len=0;
}
- Fs.fat_len = 0;
- Fs.num_fat = 2;
+ Fs->fat_len = 0;
+ Fs->num_fat = 2;
if(getenv("MTOOLS_NFATS")) {
- Fs.num_fat = atou8(getenv("MTOOLS_NFATS"));
- if(Fs.num_fat <= 0)
- Fs.num_fat=2;
+ Fs->num_fat = atou8(getenv("MTOOLS_NFATS"));
+ if(Fs->num_fat <= 0)
+ Fs->num_fat=2;
}
- Fs.Class = &FsClass;
+ Fs->Class = &FsClass;
rate_0 = mtools_rate_0;
rate_any = mtools_rate_any;
@@ -972,14 +977,14 @@ void mformat(int argc, char **argv, int dummy UNUSEDP)
break;
case 'c':
- Fs.cluster_size = atoui(optarg);
+ Fs->cluster_size = atoui(optarg);
break;
case 'r':
- Fs.dir_len = strtou16(optarg,&endptr,0);
+ Fs->dir_len = strtou16(optarg,&endptr,0);
break;
case 'L':
- Fs.fat_len = strtoui(optarg,&endptr,0);
+ Fs->fat_len = strtoui(optarg,&endptr,0);
break;
@@ -1004,7 +1009,7 @@ void mformat(int argc, char **argv, int dummy UNUSEDP)
argheads = atou16(optarg);
break;
case 'd':
- Fs.num_fat = atou8(optarg);
+ Fs->num_fat = atou8(optarg);
break;
case 'm':
mediaDesc = strtou8(optarg,&endptr,0);
@@ -1052,10 +1057,10 @@ void mformat(int argc, char **argv, int dummy UNUSEDP)
/* check out a drive whose letter and parameters match */
sprintf(errmsg, "Drive '%c:' not supported", drive);
- Fs.Direct = NULL;
+ Fs->Direct = NULL;
blocksize = 0;
for(dev=devices;dev->drive;dev++) {
- FREE(&(Fs.Direct));
+ FREE(&(Fs->Direct));
/* drive letter */
if (dev->drive != drive)
continue;
@@ -1075,52 +1080,58 @@ void mformat(int argc, char **argv, int dummy UNUSEDP)
#endif
#ifdef USE_XDF
- if(!format_xdf)
+ if(format_xdf)
used_dev.misc_flags |= USE_XDF_FLAG;
#endif
if(tot_sectors)
used_dev.tot_sectors = tot_sectors;
- Fs.Direct = OpenImage(&used_dev, dev, name,
+ Fs->Direct = OpenImage(&used_dev, dev, name,
O_RDWR|create, errmsg,
ALWAYS_GET_GEOMETRY,
O_RDWR,
- &maxSize, NULL, &info);
+ &maxSize, NULL,
+#ifdef USE_XDF
+ &info
+#else
+ NULL
+#endif
+ );
#ifdef USE_XDF
- if(Fs.Direct && info.FatSize) {
- if(!Fs.fat_len)
- Fs.fat_len = info.FatSize;
- if(!Fs.dir_len)
- Fs.dir_len = info.RootDirSize;
+ if(Fs->Direct && info.FatSize) {
+ if(!Fs->fat_len)
+ Fs->fat_len = info.FatSize;
+ if(!Fs->dir_len)
+ Fs->dir_len = info.RootDirSize;
}
#endif
- if (!Fs.Direct)
+ if (!Fs->Direct)
continue;
if(!tot_sectors)
tot_sectors = used_dev.tot_sectors;
- Fs.sector_size = 512;
+ Fs->sector_size = 512;
if( !(used_dev.use_2m & 0x7f)) {
- Fs.sector_size = (uint16_t) (128u << (used_dev.ssize & 0x7f));
+ Fs->sector_size = (uint16_t) (128u << (used_dev.ssize & 0x7f));
}
- SET_INT(Fs.sector_size, msize);
+ SET_INT(Fs->sector_size, msize);
{
unsigned int j;
for(j = 0; j < 31; j++) {
- if (Fs.sector_size == (unsigned int) (1 << j)) {
- Fs.sectorShift = j;
+ if (Fs->sector_size == (unsigned int) (1 << j)) {
+ Fs->sectorShift = j;
break;
}
}
- Fs.sectorMask = Fs.sector_size - 1;
+ Fs->sectorMask = Fs->sector_size - 1;
}
- if(!used_dev.blocksize || used_dev.blocksize < Fs.sector_size)
- blocksize = Fs.sector_size;
+ if(!used_dev.blocksize || used_dev.blocksize < Fs->sector_size)
+ blocksize = Fs->sector_size;
else
blocksize = used_dev.blocksize;
@@ -1130,15 +1141,15 @@ void mformat(int argc, char **argv, int dummy UNUSEDP)
if((mt_size_t) tot_sectors * blocksize > maxSize) {
snprintf(errmsg, sizeof(errmsg)-1,
"Requested size too large\n");
- FREE(&Fs.Direct);
+ FREE(&Fs->Direct);
continue;
}
/* do a "test" read */
if (!create &&
- READS(Fs.Direct, &boot.characters, 0, Fs.sector_size) !=
- (signed int) Fs.sector_size) {
+ READS(Fs->Direct, &boot.characters, 0, Fs->sector_size) !=
+ (signed int) Fs->sector_size) {
#ifdef HAVE_SNPRINTF
snprintf(errmsg, sizeof(errmsg)-1,
"Error reading from '%s', wrong parameters?",
@@ -1148,7 +1159,7 @@ void mformat(int argc, char **argv, int dummy UNUSEDP)
"Error reading from '%s', wrong parameters?",
name);
#endif
- FREE(&Fs.Direct);
+ FREE(&Fs->Direct);
continue;
}
break;
@@ -1156,13 +1167,14 @@ void mformat(int argc, char **argv, int dummy UNUSEDP)
/* print error msg if needed */
if ( dev->drive == 0 ){
- FREE(&Fs.Direct);
+ FREE(&Fs->Direct);
fprintf(stderr,"%s: %s\n", argv[0],errmsg);
exit(1);
}
/* calculate the total number of sectors */
- if(tot_sectors == 0) {
+ if(tot_sectors == 0 &&
+ used_dev.heads && used_dev.sectors && used_dev.tracks) {
uint32_t sect_per_track = used_dev.heads*used_dev.sectors;
mt_off_t rtot_sectors =
used_dev.tracks*(mt_off_t)sect_per_track;
@@ -1178,9 +1190,9 @@ void mformat(int argc, char **argv, int dummy UNUSEDP)
/* create the image file if needed */
if (create) {
- WRITES(Fs.Direct, &boot.characters,
- sectorsToBytes((Stream_t*)&Fs, tot_sectors-1),
- Fs.sector_size);
+ WRITES(Fs->Direct, &boot.characters,
+ sectorsToBytes((Stream_t*)Fs, tot_sectors-1),
+ Fs->sector_size);
}
/* the boot sector */
@@ -1202,15 +1214,15 @@ void mformat(int argc, char **argv, int dummy UNUSEDP)
close(fd);
}
if(!keepBoot && !(used_dev.use_2m & 0x7f))
- memset(boot.characters, '\0', Fs.sector_size);
+ memset(boot.characters, '\0', Fs->sector_size);
- Fs.Next = buf_init(Fs.Direct,
- blocksize * used_dev.heads * used_dev.sectors,
- blocksize * used_dev.heads * used_dev.sectors,
- blocksize);
- Fs.Buffer = 0;
+ Fs->Next = buf_init(Fs->Direct,
+ blocksize * used_dev.heads * used_dev.sectors,
+ blocksize * used_dev.heads * used_dev.sectors,
+ blocksize);
+ Fs->Buffer = 0;
- boot.boot.nfat = Fs.num_fat;
+ boot.boot.nfat = Fs->num_fat;
if(!keepBoot)
set_word(&boot.bytes[510], 0xaa55);
@@ -1218,7 +1230,7 @@ void mformat(int argc, char **argv, int dummy UNUSEDP)
set_word(boot.boot.nsect, used_dev.sectors);
set_word(boot.boot.nheads, used_dev.heads);
- used_dev.fat_bits = comp_fat_bits(&Fs,used_dev.fat_bits, tot_sectors, fat32);
+ used_dev.fat_bits = comp_fat_bits(Fs,used_dev.fat_bits, tot_sectors, fat32);
if(!keepBoot && !(used_dev.use_2m & 0x7f)) {
if(!used_dev.partition) {
@@ -1235,8 +1247,8 @@ void mformat(int argc, char **argv, int dummy UNUSEDP)
}
if(used_dev.fat_bits == 32) {
- Fs.primaryFat = 0;
- Fs.writeAllFats = 1;
+ Fs->primaryFat = 0;
+ Fs->writeAllFats = 1;
if(resvSects) {
if(resvSects < 3) {
fprintf(stderr,
@@ -1246,20 +1258,20 @@ void mformat(int argc, char **argv, int dummy UNUSEDP)
if(resvSects <= backupBoot && !backupBootSet)
backupBoot = resvSects - 1;
- Fs.fat_start = resvSects;
+ Fs->fat_start = resvSects;
} else
- Fs.fat_start = 32;
+ Fs->fat_start = 32;
- if(Fs.fat_start <= backupBoot) {
+ if(Fs->fat_start <= backupBoot) {
fprintf(stderr,
- "Reserved sectors (%d) must be more than backupBoot (%d)\n", Fs.fat_start, backupBoot);
+ "Reserved sectors (%d) must be more than backupBoot (%d)\n", Fs->fat_start, backupBoot);
backupBoot = 6;
- Fs.fat_start = 32;
+ Fs->fat_start = 32;
}
- calc_fs_parameters_32(tot_sectors, &Fs, &boot);
+ calc_fs_parameters_32(tot_sectors, Fs, &boot);
- Fs.clus_start = Fs.num_fat * Fs.fat_len + Fs.fat_start;
+ Fs->clus_start = Fs->num_fat * Fs->fat_len + Fs->fat_start;
/* extension flags: mirror fats, and use #0 as primary */
set_word(boot.boot.ext.fat32.extFlags,0);
@@ -1268,37 +1280,37 @@ void mformat(int argc, char **argv, int dummy UNUSEDP)
set_word(boot.boot.ext.fat32.fsVersion,fsVersion);
/* root directory */
- set_dword(boot.boot.ext.fat32.rootCluster, Fs.rootCluster = 2);
+ set_dword(boot.boot.ext.fat32.rootCluster, Fs->rootCluster = 2);
/* info sector */
- set_word(boot.boot.ext.fat32.infoSector, Fs.infoSectorLoc = 1);
- Fs.infoSectorLoc = 1;
+ set_word(boot.boot.ext.fat32.infoSector, Fs->infoSectorLoc = 1);
+ Fs->infoSectorLoc = 1;
/* no backup boot sector */
set_word(boot.boot.ext.fat32.backupBoot, backupBoot);
labelBlock = & boot.boot.ext.fat32.labelBlock;
} else {
- Fs.infoSectorLoc = 0;
+ Fs->infoSectorLoc = 0;
if(resvSects) {
if(resvSects < 1) {
fprintf(stderr,
"Reserved sectors need to be at least 1\n");
resvSects = 1;
}
- Fs.fat_start = resvSects;
+ Fs->fat_start = resvSects;
} else
- Fs.fat_start = 1;
- calc_fs_parameters(&used_dev, tot_sectors, &Fs, &boot);
- Fs.dir_start = Fs.num_fat * Fs.fat_len + Fs.fat_start;
- Fs.clus_start = Fs.dir_start + Fs.dir_len;
+ Fs->fat_start = 1;
+ calc_fs_parameters(&used_dev, tot_sectors, Fs, &boot);
+ Fs->dir_start = Fs->num_fat * Fs->fat_len + Fs->fat_start;
+ Fs->clus_start = Fs->dir_start + Fs->dir_len;
labelBlock = & boot.boot.ext.old.labelBlock;
}
/* Set the codepage */
- Fs.cp = cp_open(used_dev.codepage);
- if(Fs.cp == NULL)
+ Fs->cp = cp_open(used_dev.codepage);
+ if(Fs->cp == NULL)
exit(1);
if (!keepBoot)
@@ -1313,17 +1325,17 @@ void mformat(int argc, char **argv, int dummy UNUSEDP)
if (!serial_set)
serial=(uint32_t) random();
set_dword(labelBlock->serial, serial);
- label_name_pc(GET_DOSCONVERT((Stream_t *)&Fs),
+ label_name_pc(GET_DOSCONVERT((Stream_t *)Fs),
label[0] ? label : "NO NAME ", 0,
&mangled, &shortlabel);
strncpy(labelBlock->label, shortlabel.base, 8);
strncpy(labelBlock->label+8, shortlabel.ext, 3);
- sprintf(labelBlock->fat_type, "FAT%2.2d ", Fs.fat_bits);
+ sprintf(labelBlock->fat_type, "FAT%2.2d ", Fs->fat_bits);
labelBlock->fat_type[7] = ' ';
- set_word(boot.boot.secsiz, Fs.sector_size);
- boot.boot.clsiz = (unsigned char) Fs.cluster_size;
- set_word(boot.boot.nrsvsect, Fs.fat_start);
+ set_word(boot.boot.secsiz, Fs->sector_size);
+ boot.boot.clsiz = (unsigned char) Fs->cluster_size;
+ set_word(boot.boot.nrsvsect, Fs->fat_start);
bootOffset = init_geometry_boot(&boot, &used_dev, sectors0,
rate_0, rate_any,
@@ -1350,42 +1362,41 @@ void mformat(int argc, char **argv, int dummy UNUSEDP)
boot.boot.jump[2] = 0x90;
}
if(used_dev.use_2m & 0x7f)
- Fs.num_fat = 1;
+ Fs->num_fat = 1;
if(haveMediaDesc)
boot.boot.descr=mediaDesc;
- Fs.lastFatSectorNr = 0;
- Fs.lastFatSectorData = 0;
- zero_fat(&Fs, boot.boot.descr);
- Fs.freeSpace = Fs.num_clus;
- Fs.last = 2;
+ Fs->lastFatSectorNr = 0;
+ Fs->lastFatSectorData = 0;
+ zero_fat(Fs, boot.boot.descr);
+ Fs->freeSpace = Fs->num_clus;
+ Fs->last = 2;
#ifdef USE_XDF
if(format_xdf)
for(i=0;
- i < (info.BadSectors+Fs.cluster_size-1)/Fs.cluster_size;
+ i < (info.BadSectors+Fs->cluster_size-1)/Fs->cluster_size;
i++)
- fatEncode(&Fs, i+2, 0xfff7);
+ fatEncode(Fs, i+2, 0xfff7);
#endif
- format_root(&Fs, label, &boot);
- WRITES((Stream_t *)&Fs, boot.characters,
- (mt_off_t) 0, Fs.sector_size);
-
- if(used_dev.fat_bits == 32) {
- WRITES((Stream_t *)&Fs, boot.characters,
- (mt_off_t) backupBoot * Fs.sector_size, Fs.sector_size);
+ format_root(Fs, label, &boot);
+ if(WRITES((Stream_t *)Fs, boot.characters,
+ (mt_off_t) 0, Fs->sector_size) < 0) {
+ fprintf(stderr, "Error writing boot sector\n");
+ exit(1);
}
- if(Fs.fat_bits == 32 && WORD_S(ext.fat32.backupBoot) != MAX16) {
- WRITES((Stream_t *)&Fs, boot.characters,
- sectorsToBytes((Stream_t*)&Fs,
- WORD_S(ext.fat32.backupBoot)),
- Fs.sector_size);
+ if(Fs->fat_bits == 32 && WORD_S(ext.fat32.backupBoot) != MAX16) {
+ if(WRITES((Stream_t *)Fs, boot.characters,
+ sectorsToBytes((Stream_t*)Fs,
+ WORD_S(ext.fat32.backupBoot)),
+ Fs->sector_size) < 0) {
+ fprintf(stderr, "Error writing backup boot sector\n");
+ exit(1);
+ }
}
- FLUSH((Stream_t *)&Fs); /* flushes Fs.
- * This triggers the writing of the FAT */
- FREE(&Fs.Next);
- Fs.Class->freeFunc((Stream_t *)&Fs);
+
+ FREE((Stream_t **)&Fs);
#ifdef USE_XDF
if(format_xdf && isatty(0) && !getenv("MTOOLS_USE_XDF"))
fprintf(stderr,
diff --git a/minfo.1 b/minfo.1
index 5b6cec3..e4f35ef 100644
--- a/minfo.1
+++ b/minfo.1
@@ -1,5 +1,5 @@
'\" t
-.TH minfo 1 "17Jun21" mtools-4.0.30
+.TH minfo 1 "19Jun21" mtools-4.0.31
.SH Name
minfo - print the parameters of a MSDOS filesystem
'\" t
diff --git a/mkmanifest.1 b/mkmanifest.1
index ed0e796..3bc8928 100644
--- a/mkmanifest.1
+++ b/mkmanifest.1
@@ -1,5 +1,5 @@
'\" t
-.TH mkmanifest 1 "17Jun21" mtools-4.0.30
+.TH mkmanifest 1 "19Jun21" mtools-4.0.31
.SH Name
mkmanifest - makes list of file names and their DOS 8+3 equivalent
'\" t
diff --git a/mlabel.1 b/mlabel.1
index c42d58d..4df1856 100644
--- a/mlabel.1
+++ b/mlabel.1
@@ -1,5 +1,5 @@
'\" t
-.TH mlabel 1 "17Jun21" mtools-4.0.30
+.TH mlabel 1 "19Jun21" mtools-4.0.31
.SH Name
mlabel - make an MSDOS volume label
'\" t
diff --git a/mmd.1 b/mmd.1
index 8cc9841..cffbe19 100644
--- a/mmd.1
+++ b/mmd.1
@@ -1,5 +1,5 @@
'\" t
-.TH mmd 1 "17Jun21" mtools-4.0.30
+.TH mmd 1 "19Jun21" mtools-4.0.31
.SH Name
mmd - make an MSDOS subdirectory
'\" t
diff --git a/mmount.1 b/mmount.1
index f64d347..4899143 100644
--- a/mmount.1
+++ b/mmount.1
@@ -1,5 +1,5 @@
'\" t
-.TH mmount 1 "17Jun21" mtools-4.0.30
+.TH mmount 1 "19Jun21" mtools-4.0.31
.SH Name
mmount - mount an MSDOS disk
'\" t
diff --git a/mmove.1 b/mmove.1
index 8b9ecc2..5e69718 100644
--- a/mmove.1
+++ b/mmove.1
@@ -1,5 +1,5 @@
'\" t
-.TH mmove 1 "17Jun21" mtools-4.0.30
+.TH mmove 1 "19Jun21" mtools-4.0.31
.SH Name
mmove - move or rename an MSDOS file or subdirectory
'\" t
diff --git a/mpartition.1 b/mpartition.1
index 3055750..065ba07 100644
--- a/mpartition.1
+++ b/mpartition.1
@@ -1,5 +1,5 @@
'\" t
-.TH mpartition 1 "17Jun21" mtools-4.0.30
+.TH mpartition 1 "19Jun21" mtools-4.0.31
.SH Name
mpartition - partition an MSDOS hard disk
'\" t
diff --git a/mpartition.c b/mpartition.c
index 8281242..b60c27e 100644
--- a/mpartition.c
+++ b/mpartition.c
@@ -590,10 +590,7 @@ void mpartition(int argc, char **argv, int dummy UNUSEDP)
* boundaries here: apparently this was a thing of the past */
if(size_set) {
- if(!begin_set && end_set)
- begin = end - length;
- else
- end = begin + length;
+ end = begin + length;
} else if(!end_set) {
fprintf(stderr,"Unknown size\n");
exit(1);
diff --git a/mrd.1 b/mrd.1
index 9c6c735..6114aab 100644
--- a/mrd.1
+++ b/mrd.1
@@ -1,5 +1,5 @@
'\" t
-.TH mrd 1 "17Jun21" mtools-4.0.30
+.TH mrd 1 "19Jun21" mtools-4.0.31
.SH Name
mrd - remove an MSDOS subdirectory
'\" t
diff --git a/mren.1 b/mren.1
index 365cce1..5505452 100644
--- a/mren.1
+++ b/mren.1
@@ -1,5 +1,5 @@
'\" t
-.TH mren 1 "17Jun21" mtools-4.0.30
+.TH mren 1 "19Jun21" mtools-4.0.31
.SH Name
mren - rename an existing MSDOS file
'\" t
diff --git a/mshortname.1 b/mshortname.1
index 202ac9d..ee0c2fd 100644
--- a/mshortname.1
+++ b/mshortname.1
@@ -1,5 +1,5 @@
'\" t
-.TH mshortname 1 "17Jun21" mtools-4.0.30
+.TH mshortname 1 "19Jun21" mtools-4.0.31
.SH Name
mshortname - shows short name of a file
'\" t
diff --git a/mshowfat.1 b/mshowfat.1
index 52f03a8..10173a9 100644
--- a/mshowfat.1
+++ b/mshowfat.1
@@ -1,5 +1,5 @@
'\" t
-.TH mshowfat 1 "17Jun21" mtools-4.0.30
+.TH mshowfat 1 "19Jun21" mtools-4.0.31
.SH Name
mshowfat - shows FAT clusters allocated to file
'\" t
diff --git a/mtools.1 b/mtools.1
index 711fc1a..d655e14 100644
--- a/mtools.1
+++ b/mtools.1
@@ -1,5 +1,5 @@
'\" t
-.TH mtools 1 "31May21" mtools-4.0.29
+.TH mtools 1 "17Jun21" mtools-4.0.30
.SH Name
mtools - utilities to access DOS disks in Unix.
'\" t
@@ -36,7 +36,7 @@ Mtools can be found at the following places (and their mirrors):
.nf
.ft 3
.in +0.3i
-http://ftp.gnu.org/gnu/mtools/mtools-4.0.29.tar.gz
+http://ftp.gnu.org/gnu/mtools/mtools-4.0.30.tar.gz
.fi
.in -0.3i
.ft R
diff --git a/mtools.5 b/mtools.5
index f088b7b..6b1f70a 100644
--- a/mtools.5
+++ b/mtools.5
@@ -1,5 +1,5 @@
'\" t
-.TH mtools 5 "31May21" MTOOLS MTOOLS
+.TH mtools 5 "17Jun21" MTOOLS MTOOLS
.SH Name
mtools.conf - mtools configuration files
'\" t
@@ -13,7 +13,7 @@ mtools.conf - mtools configuration files
.tr \(if`
.tr \(pd"
-.ds St Mtools\ 4.0.29
+.ds St Mtools\ 4.0.30
.PP
.SH Description
.PP
diff --git a/mtools.info b/mtools.info
index b312b5a..b499456 100644
--- a/mtools.info
+++ b/mtools.info
@@ -1,6 +1,6 @@
This is mtools.info, produced by makeinfo version 6.5 from mtools.texi.
-This manual is for Mtools (version 4.0.30, June 2021), which is a
+This manual is for Mtools (version 4.0.31, June 2021), which is a
collection of tools to allow Unix systems to manipulate MS-DOS files.
Copyright (C) 2007, 2009 Free Software Foundation, Inc. Copyright
@@ -53,7 +53,7 @@ preliminary mounting or initialization (assuming the default
'/etc/mtools.conf' works on your machine). With mtools, one can change
floppies too without unmounting and mounting.
- This manual is for Mtools (version 4.0.30, June 2021), which is a
+ This manual is for Mtools (version 4.0.31, June 2021), which is a
collection of tools to allow Unix systems to manipulate MS-DOS files.
Copyright (C) 2007, 2009 Free Software Foundation, Inc. Copyright
@@ -87,7 +87,7 @@ File: mtools.info, Node: Location, Next: Common features, Prev: Top, Up: Top
*********************
Mtools can be found at the following places (and their mirrors):
- http://ftp.gnu.org/gnu/mtools/mtools-4.0.30.tar.gz
+ http://ftp.gnu.org/gnu/mtools/mtools-4.0.31.tar.gz
These patches are named 'mtools-'VERSION'-'DDMM'.taz', where version
stands for the base version, DD for the day and MM for the month. Due
diff --git a/mtools.spec b/mtools.spec
index 2c68e5e..16cba51 100644
--- a/mtools.spec
+++ b/mtools.spec
@@ -1,7 +1,7 @@
%define _binary_payload w9.gzdio
Name: mtools
Summary: mtools, read/write/list/format DOS disks under Unix
-Version: 4.0.30
+Version: 4.0.31
Release: 1
License: GPLv3+
Group: Utilities/System
@@ -135,6 +135,28 @@ if [ -f %{_bindir}/install-info ] ; then
fi
%changelog
+* Sat Jun 19 2021 Alain Knaff <alain@knaff.lu>
+- Move Linux-specific block device sizing code into
+ linux-specific section of devices.c
+- Error messages for all failure cases on fs_init failure
+- Fix compilation without XDF support (OpenImage signature)
+- Fix polarity of format_xdf command-line parameter of mformat
+- In XDF_IO retry enough times to actually succeed, even if
+ FDC was in a bad state before
+- Remove useless buffer flushing triggered when giving up a
+ reference to a stream node that is still referenced
+ elsewhere.
+- Clearer error message if neither size nor geometry of drive
+ to be mformatted is known
+- In mformat, make Fs dynamically allocated rather than
+ on-stack, so as to be able to use utilities supplied by
+ stream.c
+- Remove duplicate writing of backup boot sector
+- Allow to infer geometry if only size is specified
+- Protect against attempt to create zero-sized buffer
+- Code simplification in mattrib
+- Remove dead code in mpartition
+
* Thu Jun 17 2021 Alain Knaff <alain@knaff.lu>
- Fixed XDF floppy disk access
- Fixed faulty behavior at end of image in mcat
diff --git a/mtools.tmpl.1 b/mtools.tmpl.1
index 2931345..67c0252 100644
--- a/mtools.tmpl.1
+++ b/mtools.tmpl.1
@@ -1,5 +1,5 @@
'\" t
-.TH mtools 1 "17Jun21" mtools-4.0.30
+.TH mtools 1 "19Jun21" mtools-4.0.31
.SH Name
mtools - utilities to access DOS disks in Unix.
'\" t
@@ -36,7 +36,7 @@ Mtools can be found at the following places (and their mirrors):
.nf
.ft 3
.in +0.3i
-http://ftp.gnu.org/gnu/mtools/mtools-4.0.30.tar.gz
+http://ftp.gnu.org/gnu/mtools/mtools-4.0.31.tar.gz
.fi
.in -0.3i
.ft R
diff --git a/mtools.tmpl.5 b/mtools.tmpl.5
index fe8397e..ed10d08 100644
--- a/mtools.tmpl.5
+++ b/mtools.tmpl.5
@@ -1,5 +1,5 @@
'\" t
-.TH mtools 5 "17Jun21" MTOOLS MTOOLS
+.TH mtools 5 "19Jun21" MTOOLS MTOOLS
.SH Name
mtools.conf - mtools configuration files
'\" t
@@ -13,7 +13,7 @@ mtools.conf - mtools configuration files
.tr \(if`
.tr \(pd"
-.ds St Mtools\ 4.0.30
+.ds St Mtools\ 4.0.31
.PP
.SH Description
.PP
diff --git a/mtoolstest.1 b/mtoolstest.1
index 4de2048..c0cea73 100644
--- a/mtoolstest.1
+++ b/mtoolstest.1
@@ -1,5 +1,5 @@
'\" t
-.TH mtoolstest 1 "17Jun21" mtools-4.0.30
+.TH mtoolstest 1 "19Jun21" mtools-4.0.31
.SH Name
mtoolstest - tests and displays the configuration
'\" t
diff --git a/mtype.1 b/mtype.1
index 1a9f4a3..f60202a 100644
--- a/mtype.1
+++ b/mtype.1
@@ -1,5 +1,5 @@
'\" t
-.TH mtype 1 "17Jun21" mtools-4.0.30
+.TH mtype 1 "19Jun21" mtools-4.0.31
.SH Name
mtype - display contents of an MSDOS file
'\" t
diff --git a/mzip.1 b/mzip.1
index c019a50..df20569 100644
--- a/mzip.1
+++ b/mzip.1
@@ -1,5 +1,5 @@
'\" t
-.TH mzip 1 "17Jun21" mtools-4.0.30
+.TH mzip 1 "19Jun21" mtools-4.0.31
.SH Name
mzip - change protection mode and eject disk on Zip/Jaz drive
'\" t
diff --git a/open_image.c b/open_image.c
index e132dba..4201431 100644
--- a/open_image.c
+++ b/open_image.c
@@ -48,9 +48,11 @@ Buffer read/write module
Stream_t *OpenImage(struct device *out_dev, struct device *dev,
const char *name, int mode, char *errmsg,
int flags, int lockMode,
- mt_size_t *maxSize, int *geomFailureP
+ mt_size_t *maxSize, int *geomFailureP,
#ifdef USE_XDF
- , struct xdf_info *xdf_info
+ struct xdf_info *xdf_info
+#else
+ void *dummy UNUSEDP
#endif
)
{
diff --git a/open_image.h b/open_image.h
index 4b0cafc..9bab82a 100644
--- a/open_image.h
+++ b/open_image.h
@@ -8,8 +8,10 @@
Stream_t *OpenImage(struct device *out_dev, struct device *dev,
const char *name, int mode, char *errmsg,
int flags, int lockMode,
- mt_size_t *maxSize, int *geomFailureP
+ mt_size_t *maxSize, int *geomFailureP,
#ifdef USE_XDF
- , struct xdf_info *xdf_info
+ struct xdf_info *xdf_info
+#else
+ void *dummy
#endif
);
diff --git a/patchlevel.c b/patchlevel.c
index 6517895..e4ff79b 100644
--- a/patchlevel.c
+++ b/patchlevel.c
@@ -18,10 +18,10 @@
#include "sysincludes.h"
#include "msdos.h"
-const char *mversion="4.0.30";
+const char *mversion="4.0.31";
/* Multiple releases on same day should be marked with (b), (cd), (d) after
* date string below */
-const char *mdate = "June 17th, 2021";
+const char *mdate = "June 19th, 2021";
-const char *mformat_banner = "MTOO4030";
+const char *mformat_banner = "MTOO4031";
diff --git a/plain_io.c b/plain_io.c
index 123f793..efb1951 100644
--- a/plain_io.c
+++ b/plain_io.c
@@ -138,7 +138,14 @@ static int init_geom_with_reg(int fd, struct device *dev,
struct MT_STAT *statbuf) {
if(S_ISREG(statbuf->st_mode)) {
/* Regular file (image file) */
- mt_off_t sectors = statbuf->st_size /
+ mt_off_t sectors;
+ if(statbuf->st_size == 0) {
+ /* zero sized image => newly created.
+ Size not actually known...
+ */
+ return 0;
+ }
+ sectors = statbuf->st_size /
(dev->sector_size ? dev->sector_size : 512);
dev->tot_sectors =
(sectors > (mt_off_t) UINT32_MAX)
diff --git a/stream.c b/stream.c
index 2c8aa0e..fcd59ac 100644
--- a/stream.c
+++ b/stream.c
@@ -54,8 +54,7 @@ int free_stream(Stream_t **Stream)
if((*Stream)->Next)
ret |= free_stream(&(*Stream)->Next);
Free(*Stream);
- } else if ( (*Stream)->Next )
- ret |= flush_stream((*Stream)->Next);
+ }
*Stream = NULL;
return ret;
}
diff --git a/sysincludes.h b/sysincludes.h
index c466e08..989b1cc 100644
--- a/sysincludes.h
+++ b/sysincludes.h
@@ -138,6 +138,9 @@ typedef void *caddr_t;
#define _LARGEFILE64_SOURCE
#define _GNU_SOURCE
+#ifdef HAVE_ASSERT_H
+# include <assert.h>
+#endif
#ifdef HAVE_FEATURES_H
# include <features.h>
diff --git a/version.texi b/version.texi
index c8cac14..9b2a106 100644
--- a/version.texi
+++ b/version.texi
@@ -1,3 +1,3 @@
-@set EDITION 4.0.30
-@set VERSION 4.0.30
+@set EDITION 4.0.31
+@set VERSION 4.0.31
@set UPDATED June 2021
diff --git a/xdf_io.c b/xdf_io.c
index d82239e..3d7b69b 100644
--- a/xdf_io.c
+++ b/xdf_io.c
@@ -691,9 +691,9 @@ Stream_t *XdfOpen(struct device *dev, const char *name,
* for reading just the boot sector */
fill_boot(This);
This->rate = 0;
- if (load_data(This, 0, 1, 1) < 0 ) {
+ if (load_data(This, 0, 1, 4) < 0 ) {
This->rate = 0x43;
- if(load_data(This, 0, 1, 1) < 0)
+ if(load_data(This, 0, 1, 4) < 0)
goto exit_3;
}