All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jens Axboe <axboe@kernel.org>
To: Jeff Meininger <jeffm@boxybutgood.com>
Cc: linux-kernel@vger.kernel.org
Subject: Re: determining size of cdrom
Date: Wed, 30 May 2001 23:15:09 +0200	[thread overview]
Message-ID: <20010530231509.D25129@suse.de> (raw)
In-Reply-To: <Pine.LNX.4.21.0105301548120.296-100000@mangonel>
In-Reply-To: <Pine.LNX.4.21.0105301548120.296-100000@mangonel>; from jeffm@boxybutgood.com on Wed, May 30, 2001 at 04:11:00PM +0000

On Wed, May 30 2001, Jeff Meininger wrote:
> 
> I'm not subscribed to the mailing list, so please Cc a copy of your
> replies straight to my email address: jeffm@boxybutgood.com.
> 
> 
> I'm trying to determine the raw size of a cdrom disc, as in the size of
> the file you'd get by doing 'dd if=/dev/cdrom of=size_of_this.img'.
> 
> I've tried the following things (with a disc in the drive) without
> success, and I'm hoping that someone will be able to point me in the right
> direction.
> 
> 
> struct stat s;
> stat("/dev/cdrom", &s);
> /* s.st_size is 0, s.st_blocks is 0.  */
> 
> int fd = open("/dev/cdrom", O_RDONLY);
> 
> off_t bytes = lseek(fd, 0, SEEK_END);
> /* bytes is 0 */
> 
> long sectors = 0;
> ioctl(fd, BLKGETSIZE, &sectors);
> /* sectors varies (never seems accurate) and is usually LONG_MAX */

At least this is the capacity as reported by the drive when we read the
table of contents.

> long ssz = 0;
> ioctl(fd, BLKSSZGET, &ssz);
> /* ssz varies, and is usually 1024. (shouldn't it be 2048?)  */

Someone added a block size setting of 1024 to ide revalidate, and this
has screwed us for a awhile (ie atapi dvd-ram breaks). Recent ac has the
correct stuff to reset it.

> /* ioctl HDIO_GETGEO fails. */
> 
> /* ioctl HDIO_GET_IDENTITY returns 0's for the c/h/s values I'm looking
> for.  */
> 
> I didn't find anything that looked obvious to me in linux/cdrom.h, except
> in the #ifdef __KERNEL__ section which I don't believe I can use from
> user space.

You can do it from user space with CDROMREADTOCHDR/CDROMREATOCENTRY if
you want, did you see those?

-- 
Jens Axboe


  reply	other threads:[~2001-05-30 21:15 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-05-30 16:11 determining size of cdrom Jeff Meininger
2001-05-30 21:15 ` Jens Axboe [this message]
2001-05-31  6:51   ` Jeff Meininger

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=20010530231509.D25129@suse.de \
    --to=axboe@kernel.org \
    --cc=jeffm@boxybutgood.com \
    --cc=linux-kernel@vger.kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.