From 6d369278493e796af16416a42ba8464c0ef26110 Mon Sep 17 00:00:00 2001 From: Gwenhael Le Moine Date: Thu, 29 Aug 2024 13:03:44 +0200 Subject: [PATCH] Drop mkcard. `dd` is standard and can replace it (see setup-x48ng-home.sh) dd if=/dev/zero of="$DOTX48NG"/port2 bs=1k count=4096 --- Makefile | 5 ++- src/legacy_tools/mkcard.c | 72 --------------------------------------- 2 files changed, 2 insertions(+), 75 deletions(-) delete mode 100644 src/legacy_tools/mkcard.c diff --git a/Makefile b/Makefile index 3ad74db..a07fd03 100644 --- a/Makefile +++ b/Makefile @@ -5,7 +5,8 @@ # https://git.kernel.org/pub/scm/fs/fsverity/fsverity-utils.git/ # The governing license can be found in the LICENSE file or at # https://opensource.org/license/MIT. -TARGETS = dist/x48ng dist/x48ng-mkcard dist/x48ng-checkrom dist/x48ng-dump2rom + +TARGETS = dist/x48ng dist/x48ng-checkrom dist/x48ng-dump2rom PREFIX = /usr DOCDIR = $(PREFIX)/doc/x48ng @@ -131,7 +132,6 @@ endif all: $(TARGETS) dist/x48ng-dump2rom: src/legacy_tools/dump2rom.o -dist/x48ng-mkcard: src/legacy_tools/mkcard.o dist/x48ng-checkrom: src/legacy_tools/checkrom.o src/romio.o dist/x48ng: $(DOTOS) @@ -171,7 +171,6 @@ install: all dist/config.lua chmod 755 $(DESTDIR)$(PREFIX)/share/x48ng/setup-x48ng-home.sh install -m 755 -d -- $(DESTDIR)$(PREFIX)/libexec - install -c -m 755 dist/x48ng-mkcard $(DESTDIR)$(PREFIX)/libexec/x48ng-mkcard install -c -m 755 dist/x48ng-dump2rom $(DESTDIR)$(PREFIX)/libexec/x48ng-dump2rom install -c -m 755 dist/x48ng-checkrom $(DESTDIR)$(PREFIX)/libexec/x48ng-checkrom diff --git a/src/legacy_tools/mkcard.c b/src/legacy_tools/mkcard.c deleted file mode 100644 index dd7b11c..0000000 --- a/src/legacy_tools/mkcard.c +++ /dev/null @@ -1,72 +0,0 @@ -#include -#include -#include -#include -#include -#include - -bool write_mem_file( char* name, unsigned char* mem, size_t size ) -{ - FILE* fp; - - if ( NULL == ( fp = fopen( name, "w" ) ) ) { - fprintf( stderr, "can\'t open %s\n", name ); - return false; - } - - if ( fwrite( mem, 1, size, fp ) != size ) { - fprintf( stderr, "can\'t write %s\n", name ); - fclose( fp ); - return false; - } - - fclose( fp ); - return true; -} - -int main( int argc, char** argv ) -{ - size_t size; - char* name; - char* asize; - unsigned char* core; - - if ( argc < 2 ) { - fprintf( stderr, "usage: %s [32K | 128K | 1M | 2M | 4M] file-name\n", argv[ 0 ] ); - exit( 1 ); - } - - name = argv[ 2 ]; - asize = argv[ 1 ]; - if ( !strcmp( asize, "32K" ) ) - size = 0x8000; - else if ( !strcmp( asize, "128K" ) ) - size = 0x20000; - else if ( !strcmp( asize, "256K" ) ) - size = 0x40000; - else if ( !strcmp( asize, "512K" ) ) - size = 0x80000; - else if ( !strcmp( asize, "1M" ) ) - size = 0x100000; - else if ( !strcmp( asize, "2M" ) ) - size = 0x200000; - else if ( !strcmp( asize, "4M" ) ) - size = 0x400000; - else { - fprintf( stderr, "size must be one of 32K, 128K, 256K, 512K, 1M, 2M, or 4M\n" ); - exit( 1 ); - } - - if ( ( core = ( unsigned char* )malloc( size ) ) == NULL ) { - fprintf( stderr, "can\'t malloc %ld bytes\n", size ); - exit( 1 ); - } - memset( core, 0, size ); - - if ( !write_mem_file( name, core, size ) ) { - fprintf( stderr, "can\'t write to %s\n", name ); - exit( 1 ); - } - - exit( 0 ); -}