From: Carlo Marcelo Arenas Belon <carenas@sajinet.com.pe>
To: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [RESEND] [PATCH] ide: fix GET_CONFIGURATION DVD-ROM support
Date: Sat, 5 Jan 2008 20:22:33 -0600 [thread overview]
Message-ID: <20080106022233.GB27577@tapir> (raw)
In-Reply-To: <20080105102834.GA3379@miranda.arrow>
[-- Attachment #1: Type: text/plain, Size: 1765 bytes --]
On Sat, Jan 05, 2008 at 10:28:34AM +0000, Stuart Brady wrote:
> On Fri, Jan 04, 2008 at 09:53:09PM -0600, Rob Landley wrote:
> > Except that according to http://en.wikipedia.org/wiki/CD-ROM it's actually 703
> > and 1/8 binary megabytes (360,000 sectors *2048 bytes), which would be
> > 1440000.
>
> Apparently that value comes from 75 sectors per second * 80 minutes...
> 75*80*60 = 360000, and of course, 360000*2048/512 = 1440000, although
> it actually seems that it should be one sector less than 80 minutes,
> which is 359999 2048-byte sectors or 1439996 512-byte chunks.
>
> BTW, there are/were also 90 and 99 minute 'CD-Rs' -- Wikipedia's page on
> CD-Rs describes them, but they were never very popular, and a lot of
> drives can't read the discs.
the exact number of sectors is really not that relevant, as the whole point
here is to try to detect if it is a CD (700MB) or a DVD (4.7GB) and the logic
is just assuming that if it has more sectors than you should normally expect
in a CD, then it is a DVD.
attached the program I used in the guests (only works on Linux) to poke the
emulated drive (or a physical drive if you feel like) and compare the responses
(you will need to take a look at the SPEC tables to interpret the data though)
for my own tests (using a linux guest with -cdrom /dev/cdrom in my linux
host that has a DVD-+RW drive) :
700MB CD-R = 1374880 (with FreeSBIE 2.0.1)
4.7GB DVD-R = 6939520 (with SXDE 9/07)
feel free to report back with the value to use then if you happen to have a CD
that is completely full but I had already enough problems trying to get this
merged without trying to change the code that much to try to guess a better
magic number than the one was originally used (I like 1440000 though)
Carlo
[-- Attachment #2: ide-atapi.c --]
[-- Type: text/plain, Size: 2012 bytes --]
/*
ide-atapi
Copyright (c) 2007 Carlo Marcelo Arenas Belon
ide-atapi is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License version 2
as published by the Free Software Foundation.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <sys/ioctl.h>
#include <linux/cdrom.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <string.h>
#include <stdio.h>
#include <unistd.h>
int main (int argc, char *argv[])
{
struct cdrom_generic_command cgc;
struct request_sense sense;
unsigned char buf[250];
int i;
if (argc < 2) {
printf("Usage: %s <device>\n", argv[0]);
printf("\n");
printf(" device: where the commands are send\n");
printf("\n");
return 1;
}
memset (&cgc, 0, sizeof(struct cdrom_generic_command));
memset (&sense, 0, sizeof(struct request_sense));
memset (&buf, 0, sizeof(buf));
int fd = open (argv[1], O_RDONLY | O_NONBLOCK);
if (fd < 0) {
printf("couldn't open device %s\n", argv[1]);
return 1;
}
cgc.cmd[0] = GPCMD_GET_CONFIGURATION;
cgc.cmd[1] = 0x00;
cgc.cmd[8] = sizeof(buf);
cgc.timeout = 100;
cgc.buffer = buf;
cgc.buflen = sizeof(buf);
cgc.data_direction = CGC_DATA_READ;
cgc.sense = &sense;
cgc.quiet = 0;
i = ioctl (fd, CDROM_SEND_PACKET, &cgc);
if (i < 0) {
printf("command failed\n");
close (fd);
return 1;
}
printf("Response raw dump:\n");
for (i = 0; i<sizeof(buf); i++) {
if (i % 16 == 0) printf("\n");
printf("%02x ", buf[i]);
}
printf("\n");
close (fd);
return 0;
}
next prev parent reply other threads:[~2008-01-06 2:13 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-12-26 7:36 [Qemu-devel] [RESEND] [PATCH] ide: fix GET_CONFIGURATION DVD-ROM support Carlo Marcelo Arenas Belon
2008-01-04 10:02 ` Carlo Marcelo Arenas Belon
2008-01-05 0:25 ` Rob Landley
2008-01-05 1:02 ` Stuart Brady
2008-01-05 1:57 ` Stuart Brady
2008-01-05 2:06 ` Carlo Marcelo Arenas Belon
2008-01-05 3:53 ` Rob Landley
2008-01-05 10:28 ` Stuart Brady
2008-01-06 2:22 ` Carlo Marcelo Arenas Belon [this message]
2008-01-06 13:57 ` Stuart Brady
2008-01-06 14:32 ` Andreas Färber
2008-01-07 0:38 ` Carlo Marcelo Arenas Belon
2008-01-07 0:23 ` Carlo Marcelo Arenas Belon
2008-01-05 3:36 ` Carlo Marcelo Arenas Belon
2008-01-06 9:22 ` Rob Landley
2008-01-07 4:47 ` Carlo Marcelo Arenas Belon
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20080106022233.GB27577@tapir \
--to=carenas@sajinet.com.pe \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).