Re: Solved: Re: [hatari-users] ICD hard drive image |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/hatari-users Archives
]
- To: hatari-users@xxxxxxxxxxxxxxxxxxx
- Subject: Re: Solved: Re: [hatari-users] ICD hard drive image
- From: Charles Curley <charlescurley@xxxxxxxxxxxxxxxxx>
- Date: Mon, 20 May 2019 14:40:11 -0600
- Dkim-signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=charlescurley.com; s=default; h=Content-Type:MIME-Version:References: In-Reply-To:Message-ID:Subject:To:From:Date:Sender:Reply-To:Cc: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=O+joNTM7td0t791fGzVWs4rp5Eq27kbN1F+APQOqC1s=; b=uuIt8WcRzEOVKe64YySUOQGkn WizFTJ0c2qxYDRVuGArE71L6Xwnmu4YN1iHHgOn74OWHu+jQrN+9yZU5oH4lA6V0Df+x4wUI3Z0XP XbvS8z26dtXeCeL/968CaxsuuXJmEljiqIQrbeeYoQVVBVNQSiMi6NqLHqjsnm4QVYgsBZZ6l8LP/ vSJ7ksQpvrEHRS62sZ6RtwOh8g0Kn/wMyEgqJTcHZJHfdBbHTsoBLJDGcbwPScOVPlmeDnT2JXDoj MOZbT6X6RACrunfKEi+Agw6Dv9A6xocrrgw5jnGFaMCO00rCDDGczmSyaip+HR52k11PQuQMlHw58 Ctr0SavVg==;
- Organization: occasionally
On Mon, 20 May 2019 21:57:31 +0300
Eero Tamminen <oak@xxxxxxxxxxxxxx> wrote:
> > I had set the image to read only. Allowing writes to it let the
> > desktop import several of the partitions. So read-only images are
> > not allowed. Bug? Or if that's a feature, please document it.
>
> Could you test attached patch that changes this?
I applied the patch ("git apply ro-asci-support.patch") and compiled.
I ran it with the write permission removed, and got no debug message.
DEBUG: Sound: Disabled
INFO : Mounting hard drive image '/home/charles/projects/hatari/fast.forth.img'
INFO : Mounting hard drive image '/home/charles/projects/hatari/drived.img'
INFO : Mounting hard drive image '/home/charles/projects/hatari/atari.micropolis.img'
DEBUG: Checking GEMDOS O: HDD: /home/charles/projects/hatari/cdrive
INFO : GEMDOS HDD emulation, O: <-> /home/charles/projects/hatari/cdrive.
DEBUG: memory_map_Standard_RAM total=2097152 ram0=2097152 ram1=0 mmu0=131072 mmu1=131072
With that, I tried creating a directory in the test image. That
produced seven instances of "ERROR: Could not write all bytes to hard
disk image."
I then inverted the logic of the return from File_Lock. That was *not*
what I wanted.
DEBUG: Sound: Disabled
INFO : Mounting hard drive image '/home/charles/projects/hatari/fast.forth.img'
ERROR: Cannot lock HD file for writing!
INFO : Mounting hard drive image '/home/charles/projects/hatari/drived.img'
ERROR: Cannot lock HD file for writing!
INFO : Mounting hard drive image '/home/charles/projects/hatari/atari.micropolis.img'
DEBUG: Checking GEMDOS O: HDD: /home/charles/projects/hatari/cdrive
INFO : GEMDOS HDD emulation, O: <-> /home/charles/projects/hatari/cdrive.
DEBUG: memory_map_Standard_RAM total=2097152 ram0=2097152 ram1=0 mmu0=131072 mmu1=131072
So I went back to your patch, and inserted a new message right after
the first fopen. That showed up properly. See the attached patch file,
which replaces yours. It's a diff against master,
7f47e042ae7dd5f9d3681c631bb65cbcce2c4b8d.
DEBUG: Sound: Disabled
INFO : Mounting hard drive image '/home/charles/projects/hatari/fast.forth.img'
INFO : Mounting hard drive image '/home/charles/projects/hatari/drived.img'
INFO : Mounting hard drive image '/home/charles/projects/hatari/atari.micropolis.img'
ERROR: Cannot lock HD file for writing!
DEBUG: Checking GEMDOS O: HDD: /home/charles/projects/hatari/cdrive
INFO : GEMDOS HDD emulation, O: <-> /home/charles/projects/hatari/cdrive.
DEBUG: memory_map_Standard_RAM total=2097152 ram0=2097152 ram1=0 mmu0=131072 mmu1=131072
Apparently File_Lock doesn't detect read-only files, at least not on
Linux. I'm no expert on BSD-style file locking, and don't even know if
Linux supports it.
>
>
> > So here's what I see: I have two other disk images, one partition
> > each. They show up as C: and D:. Then four partitions from the new
> > image, E: through H:. I: is my GEMDOS mounted directory. J: to O:
> > are further partitions from the new image. Is that the drive
> > ordering you want, or should the GEMDOS drive show up as O:? I was
> > expecting it at O:.
>
> Hatari default for GEMDOS HD partition ID is "skip", i.e. place it
> after partitions that Hatari HD code recognizes.
>
> In any of the cases where on-disk HD driver and Hatari interpretation
> of the partition tables mismatches, GEMDOS HD won't be the last one.
> This mismatch can happen easily because Hatari doesn't know which
> HD driver is on the HD image or what partition types that recognizes
> / supports (partition support *does* differ between different
> drivers).
>
> As a result, GEMDOS HD can mask one of the real HD partitions (or
> more, if there are multiple GEMDOS HD partitions specified).
>
> That's why there's an option to explicitly set the GEMDOS HD partition
> ID:
> --gemdos-drive X
Nice. Exactly what I needed. Thank you.
--
"When we talk of civilization, we are too apt to limit the meaning of
the word to its mere embellishments, such as arts and sciences; but
the true distinction between it and barbarism is, that the one
presents a state of society under the protection of just and
well-administered law, and the other is left to the chance government
of brute force."
- The Rev. James White, Eighteen Christian Centuries, 1889
Key fingerprint = CE5C 6645 A45A 64E4 94C0 809C FFF6 4C48 4ECD DFDB
https://charlescurley.com
diff --git a/src/hdc.c b/src/hdc.c
index 838a4f3b..723cd46a 100644
--- a/src/hdc.c
+++ b/src/hdc.c
@@ -828,13 +828,16 @@ int HDC_InitDevice(SCSI_DEV *dev, char *filename, unsigned long blockSize)
if (filesize < 0)
return filesize;
- fp = fopen(filename, "rb+");
- if (fp == NULL)
+ if (!(fp = fopen(filename, "rb+")))
{
- Log_Printf(LOG_ERROR, "Cannot open HD file read/write!\n");
- return -ENOENT;
+ Log_Printf(LOG_ERROR, "Cannot lock HD file for writing!\n");
+ if (!(fp = fopen(filename, "rb")))
+ {
+ Log_Printf(LOG_ERROR, "Cannot open HD file for reading!\n");
+ return -ENOENT;
+ }
}
- if (!File_Lock(fp))
+ else if (!File_Lock(fp))
{
Log_Printf(LOG_ERROR, "Cannot lock HD file for writing!\n");
fclose(fp);