Linux ATA/IDE development
 help / color / mirror / Atom feed
From: Pat LaVarre <p.lavarre@ieee.org>
To: Bartlomiej Zolnierkiewicz <B.Zolnierkiewicz@elka.pw.edu.pl>
Cc: Jeff Garzik <jgarzik@pobox.com>, linux-ide@vger.kernel.org
Subject: Re: to /sys from /proc/ide/hd$v/identify
Date: 07 Jun 2004 15:58:57 -0600	[thread overview]
Message-ID: <1086645537.3137.103.camel@patibmrh9> (raw)
In-Reply-To: <200406072154.33609.bzolnier@elka.pw.edu.pl>

> > > - /proc/ide/ interfaces are obsolete
> > ...
> > Where do I now find the ATA op xEC/A1 "IDENTIFY" data that was
> > /proc/ide/hd$v/identify ?
> ...
> Since IDE supports taskfile ioctl,
> you shouldn't need this in sysfs...
> ...
> > Forget about the ! CONFIG_IDE_TASK_IOCTL
> > kernels, and then for the remaining kernels
> > persuade Google to teach you ioctl  
> > HDIO_DRIVE_TASKFILE.
> > ...
> > > There is also HDIO_GET_IDENTITY

Thanks for that ATA pass thru hint, I pursued it as follows.

ioctl HDIO_GET_IDENTITY maybe works here for my PATA /dev/hda and PATAPI
/dev/hdc, though not yet for my SATAPI /dev/scd0.

The bits of HDIO_GET_IDENTITY differ from those of
/proc/ide/hd$v/identify.  /proc was byte-swapping text and substituting
x20 SPACE for x00 NUL, or vice versa.

$ sudo cat /proc/ide/hdc/identify | x2c | hexdump -C >1
$ sudo ~/bin/ataid /dev/hdc | hexdump -C >2
$ diff 1 2
2,6c2,6
< 00000010  00 00 00 00 20 20 20 20  20 20 20 20 20 20 20 20  |....            |
< 00000020  20 20 20 20 20 20 20 20  00 00 00 00 00 00 4b 48  |        ......KH|
< 00000030  30 4b 20 20 20 20 4c 49  54 45 2d 4f 4e 20 43 4f  |0K    LITE-ON CO|
< 00000040  4d 42 4f 20 4c 54 43 2d  34 38 31 36 31 48 20 20  |MBO LTC-48161H  |
< 00000050  20 20 20 20 20 20 20 20  20 20 20 20 20 20 00 00  |              ..|
---
> 00000010  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
> 00000020  00 00 00 00 00 00 00 00  00 00 00 00 00 00 48 4b  |..............HK|
> 00000030  4b 30 00 00 00 00 49 4c  45 54 4f 2d 20 4e 4f 43  |K0....ILETO- NOC|
> 00000040  42 4d 20 4f 54 4c 2d 43  38 34 36 31 48 31 00 00  |BM OTL-C8461H1..|
> 00000050  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
$

Pat LaVarre

-----

There is no
http://marc.theaimsgroup.com/?l=linux-ide&s=HDIO_GET_IDENTITY

man -K HDIO_GET_IDENTITY
here yields only: man 2 ioctl_list

http://www.google.com/search?q=man+HDIO_GET_IDENTITY
suggests:
ioctl(int d, HDIO_GET_IDENTITY, struct hd_driveid *hd) 

http://groups.google.com/groups?q=ioctl+HDIO_GET_IDENTITY
suggests essentially the following code, root privilege required.

------ ataid.c

#include <fcntl.h>
#include <linux/hdreg.h>
#include <stdio.h>
#include <sys/ioctl.h>

static struct hd_driveid hddi;

int main(int argc, char* argv[])
{
	--argc; ++argv;
	if (0 < argc) {
		int fd = open(argv[0], O_NONBLOCK);
		if (0 <= fd) {
			int ii = ioctl(fd,HDIO_GET_IDENTITY, &hddi);
			if (ii == 0) {
				FILE * fi = stdout;
#if 0
				if (fwrite(&hddi, sizeof hddi, 1, fi) == 1) {
					return 0;
				}
#else
				unsigned char * uchars = (char *) &hddi;
				int ix = 0;
				for (ix = 0; ix < (int) sizeof hddi; ix += 2) {
					fputc(uchars[ix + 1], fi);
					fputc(uchars[ix + 0], fi);
				}
				return 0;
#endif
			}
		}
	}
	fprintf(stderr, "not\n");
	return -1;
}



      reply	other threads:[~2004-06-07 21:59 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-06-07 13:48 to /sys from /proc/ide/hd$v/identify Pat LaVarre
2004-06-07 13:54 ` Jeff Garzik
2004-06-07 19:46   ` Pat LaVarre
2004-06-07 19:54     ` Bartlomiej Zolnierkiewicz
2004-06-07 21:58       ` Pat LaVarre [this message]

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=1086645537.3137.103.camel@patibmrh9 \
    --to=p.lavarre@ieee.org \
    --cc=B.Zolnierkiewicz@elka.pw.edu.pl \
    --cc=jgarzik@pobox.com \
    --cc=linux-ide@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox