mirror of
https://github.com/deater/dos33fsprogs.git
synced 2024-12-24 13:32:23 +00:00
Add commands to change name of HELLO program
Both dos33 and mkdos33fs now support this
This commit is contained in:
parent
310cb6b3e0
commit
dc16365eea
5
CHANGES
5
CHANGES
@ -44,3 +44,8 @@ RELEASE 0.0.8
|
||||
+ Fix some minor bugs
|
||||
|
||||
RELEASE 0.0.10
|
||||
|
||||
21 September 2012
|
||||
+ Add -f option to mkdos33fs that lets you specify the name of
|
||||
the HELLO file
|
||||
+ Add HELLO option to dos33 that does something similar
|
||||
|
59
dos33.c
59
dos33.c
@ -959,7 +959,7 @@ keep_deleting:
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int dump_sector() {
|
||||
static int dump_sector(void) {
|
||||
int i,j;
|
||||
|
||||
for(i=0;i<16;i++) {
|
||||
@ -983,8 +983,19 @@ static int dos33_dump(int fd) {
|
||||
unsigned char tslist[BYTES_PER_SECTOR];
|
||||
int result;
|
||||
|
||||
/* Read Track 1 Sector 9 */
|
||||
lseek(fd,DISK_OFFSET(1,9),SEEK_SET);
|
||||
result=read(fd,sector_buffer,BYTES_PER_SECTOR);
|
||||
|
||||
printf("Finding name of startup file, Track 1 Sector 9 offset $75\n");
|
||||
dump_sector();
|
||||
printf("Startup Filename: ");
|
||||
for(i=0;i<30;i++) printf("%c",sector_buffer[0x75+i]&0x7f);
|
||||
printf("\n");
|
||||
|
||||
dos33_read_vtoc(fd);
|
||||
|
||||
printf("\nVTOC Sector:\n");
|
||||
dump_sector();
|
||||
|
||||
printf("\n\n");
|
||||
@ -1032,7 +1043,7 @@ repeat_catalog:
|
||||
lseek(fd,DISK_OFFSET(catalog_t,catalog_s),SEEK_SET);
|
||||
result=read(fd,sector_buffer,BYTES_PER_SECTOR);
|
||||
|
||||
dump_sector(sector_buffer);
|
||||
dump_sector();
|
||||
|
||||
for(file=0;file<7;file++) {
|
||||
printf("\n\n");
|
||||
@ -1105,7 +1116,27 @@ continue_dump:;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int dos33_rename_hello(int fd, char *new_name) {
|
||||
char buffer[BYTES_PER_SECTOR];
|
||||
int i;
|
||||
|
||||
lseek(fd,DISK_OFFSET(1,9),SEEK_SET);
|
||||
read(fd,buffer,BYTES_PER_SECTOR);
|
||||
|
||||
for(i=0;i<30;i++) {
|
||||
if (i<strlen(new_name)) {
|
||||
buffer[0x75+i]=new_name[i]|0x80;
|
||||
}
|
||||
else {
|
||||
buffer[0x75+i]=' '|0x80;
|
||||
}
|
||||
}
|
||||
|
||||
lseek(fd,DISK_OFFSET(1,9),SEEK_SET);
|
||||
write(fd,buffer,BYTES_PER_SECTOR);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int display_help(char *name) {
|
||||
printf("\ndos33 version %s\n",VERSION);
|
||||
@ -1125,7 +1156,8 @@ int display_help(char *name) {
|
||||
printf("\tUNLOCK apple_file\n");
|
||||
printf("\tRENAME apple_file_old apple_file_new\n");
|
||||
printf("\tUNDELETE apple_file\n");
|
||||
printf("\tDUMP\n");
|
||||
printf("\tDUMP\n");
|
||||
printf("\tHELLO apple_file\n");
|
||||
#if 0
|
||||
printf("\tINIT\n");
|
||||
printf("\tCOPY\n");
|
||||
@ -1146,6 +1178,7 @@ int display_help(char *name) {
|
||||
#define COMMAND_RENAME 9
|
||||
#define COMMAND_COPY 10
|
||||
#define COMMAND_DUMP 11
|
||||
#define COMMAND_HELLO 12
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
|
||||
@ -1235,6 +1268,9 @@ int main(int argc, char **argv) {
|
||||
else if (!strncmp(temp_string,"DUMP",4)) {
|
||||
command=COMMAND_DUMP;
|
||||
}
|
||||
else if (!strncmp(temp_string,"HELLO",5)) {
|
||||
command=COMMAND_HELLO;
|
||||
}
|
||||
else {
|
||||
display_help(argv[0]);
|
||||
goto exit_program;
|
||||
@ -1487,7 +1523,22 @@ int main(int argc, char **argv) {
|
||||
dos33_undelete_file(dos_fd,catalog_entry,apple_filename);
|
||||
|
||||
break;
|
||||
case COMMAND_HELLO:
|
||||
if (argc+extra_ops<4) {
|
||||
fprintf(stderr,"Error! Need file_name\n");
|
||||
fprintf(stderr,"%s %s HELLO apple_filename\n",argv[0],image);
|
||||
goto exit_and_close;
|
||||
}
|
||||
catalog_entry=dos33_check_file_exists(dos_fd,argv[firstarg+2],
|
||||
FILE_NORMAL);
|
||||
if (catalog_entry<0) {
|
||||
fprintf(stderr,
|
||||
"Warning! File %s does not exist\n",argv[firstarg+2]);
|
||||
}
|
||||
|
||||
dos33_rename_hello(dos_fd,argv[firstarg+2]);
|
||||
|
||||
break;
|
||||
case COMMAND_INIT:
|
||||
/* use common code from mkdos33fs? */
|
||||
case COMMAND_COPY:
|
||||
|
34
mkdos33fs.c
34
mkdos33fs.c
@ -14,11 +14,12 @@ void usage(char *binary,int help) {
|
||||
printf("\thttp://www.deater.net/weave/vmwprod/apple/\n\n");
|
||||
if (help) {
|
||||
printf("Usage:\t%s [-t track] [-s sector] [-b size] "
|
||||
"[-d filename] device_name\n\n",binary);
|
||||
"[-d filename] [-f filename] device_name\n\n",binary);
|
||||
printf("\t-t tracks : number of tracks in filesystem\n");
|
||||
printf("\t-s sectors : number of sectors in filesystem\n");
|
||||
printf("\t-b blocksize : size of sector, in bytes\n");
|
||||
printf("\t-d filename : file to copy first 3 tracks over from\n");
|
||||
printf("\t-f filename : name of BASIC file to autoboot. Default is HELLO\n");
|
||||
printf("\n\n");
|
||||
}
|
||||
exit(0);
|
||||
@ -33,10 +34,12 @@ int main(int argc, char **argv) {
|
||||
char *buffer,*endptr;
|
||||
int i,c,copy_dos=0;
|
||||
int result;
|
||||
|
||||
char boot_filename[30]="HELLO ";
|
||||
|
||||
/* Parse Command Line Arguments */
|
||||
|
||||
while ((c = getopt (argc, argv,"t:s:b:d:hv"))!=-1) {
|
||||
while ((c = getopt (argc, argv,"t:s:b:d:f:hv"))!=-1) {
|
||||
switch (c) {
|
||||
|
||||
case 't': num_tracks=strtol(optarg,&endptr,10);
|
||||
@ -54,6 +57,16 @@ int main(int argc, char **argv) {
|
||||
strncpy(dos_src,optarg,BUFSIZ);
|
||||
break;
|
||||
|
||||
case 'f':
|
||||
if (strlen(optarg)>30) {
|
||||
fprintf(stderr,"Auto boot filename too long!\n");
|
||||
exit(1);
|
||||
}
|
||||
memcpy(boot_filename,optarg,strlen(optarg));
|
||||
for(i=strlen(optarg);i<30;i++) boot_filename[i]=' ';
|
||||
// printf("Writing boot filename \"%s\"\n",boot_filename);
|
||||
break;
|
||||
|
||||
case 'v': usage(argv[0],0);
|
||||
case 'h': usage(argv[0],1);
|
||||
|
||||
@ -92,7 +105,7 @@ int main(int argc, char **argv) {
|
||||
buffer=calloc(1,sizeof(char)*block_size);
|
||||
|
||||
/* Open device */
|
||||
fd=open(device,O_WRONLY|O_CREAT,0666);
|
||||
fd=open(device,O_RDWR|O_CREAT,0666);
|
||||
if (fd<0) {
|
||||
fprintf(stderr,"Error opening %s\n",device);
|
||||
goto end_of_program;
|
||||
@ -119,6 +132,18 @@ int main(int argc, char **argv) {
|
||||
}
|
||||
close(dos_fd);
|
||||
|
||||
/* Set boot filename */
|
||||
|
||||
/* Track 1 sector 9 */
|
||||
lseek(fd,((1*num_sectors)+9)*block_size,SEEK_SET);
|
||||
result=read(fd,buffer,block_size);
|
||||
|
||||
/* filename begins at offset 75 */
|
||||
for(i=0;i<30;i++) {
|
||||
buffer[0x75+i]=boot_filename[i]|0x80;
|
||||
}
|
||||
lseek(fd,((1*num_sectors)+9)*block_size,SEEK_SET);
|
||||
result=write(fd,buffer,block_size);
|
||||
}
|
||||
|
||||
/* clear buffer */
|
||||
@ -159,6 +184,7 @@ int main(int argc, char **argv) {
|
||||
buffer[VTOC_FREE_BITMAPS+2]=0x00;
|
||||
buffer[VTOC_FREE_BITMAPS+3]=0x00;
|
||||
|
||||
/* if copying dos reserve tracks 1 and 2 as well */
|
||||
if (copy_dos) {
|
||||
buffer[VTOC_FREE_BITMAPS+4]=0x00;
|
||||
buffer[VTOC_FREE_BITMAPS+5]=0x00;
|
||||
@ -176,8 +202,6 @@ int main(int argc, char **argv) {
|
||||
buffer[VTOC_FREE_BITMAPS+17*4+1]=0x00;
|
||||
buffer[VTOC_FREE_BITMAPS+17*4+2]=0x00;
|
||||
buffer[VTOC_FREE_BITMAPS+17*4+3]=0x00;
|
||||
|
||||
|
||||
|
||||
/* Write out VTOC to disk */
|
||||
lseek(fd,((17*num_sectors)+0)*block_size,SEEK_SET);
|
||||
|
Loading…
Reference in New Issue
Block a user