Skip to contentSkip to conversation

to /sys from /proc/ide/hd$v/identify

DISCUSSION Pat LaVarre 3 participants 5 messages Jun 7, 2004 libata

lore
Share & tools
lore
#0 lore raw
Quoted 5 lines
List:       linux-kernel
Subject:    [RFC][DOC] writing IDE driver guidelines
From:       Bartlomiej Zolnierkiewicz <B.Z...()elk...>
Date:       2004-05-15 17:23:50
Quoted 9 lines

Feedback is welcomed.
...
general rules:
...
- use [email protected] mailing list
...
PCI drivers:
...
- /proc/ide/ interfaces are obsolete

Where do I now find the ATA op xEC/A1 "IDENTIFY" data that was /proc/ide/hd$v/identify ?

$ uname -r
2.6.7-rc2
$
$ sudo cat /proc/ide/hda/identify | wc -w
    256
$ sudo cat /proc/ide/hdc/identify | wc -w
    256
$
$ sudo mount -t sysfs sysfs /sys
$ sudo find /sys -name '*id*' | less
$ find /sys/bus/ide | less
$

Pat LaVarre

#1 lore raw
Quoted 19 lines · Pat LaVarre
Quoted 5 lines
List:       linux-kernel
Subject:    [RFC][DOC] writing IDE driver guidelines
From:       Bartlomiej Zolnierkiewicz <B.Z...()elk...>
Date:       2004-05-15 17:23:50
Quoted 9 lines

Feedback is welcomed.
...
general rules:
...
- use [email protected] mailing list
...
PCI drivers:
...
- /proc/ide/ interfaces are obsolete

Where do I now find the ATA op xEC/A1 "IDENTIFY" data that was /proc/ide/hd$v/identify ?

Quoted 11 lines
$ uname -r
2.6.7-rc2
$
$ sudo cat /proc/ide/hda/identify | wc -w
    256
$ sudo cat /proc/ide/hdc/identify | wc -w
    256
$
$ sudo mount -t sysfs sysfs /sys
$ sudo find /sys -name '*id*' | less
$ find /sys/bus/ide | less

Since IDE supports taskfile ioctl, you shouldn't need this in sysfs...

Jeff

#2 lore raw
Quoted 5 lines
Quoted 3 lines
Quoted 1 line

- /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...

Unless corrected, I will guess this answer means:

Forget about the ! CONFIG_IDE_TASK_IOCTL kernels, and then for the remaining kernels persuade Google to teach you ioctl HDIO_DRIVE_TASKFILE.

Pat LaVarre

P.S. Evidence as follows:

http://marc.theaimsgroup.com/?l=linux-ide&s=taskfile+ioctl
http://www.google.com/search?q=linux-ide+taskfile+ioctl
http://lxr.linux.no/ident?v=2.6.5&i=ide_taskfile_ioctl
http://lxr.linux.no/source/drivers/ide/ide.c?v=2.6.5#L1554

1548 #ifdef CONFIG_IDE_TASK_IOCTL
1549 case HDIO_DRIVE_TASKFILE:
1550 if (!capable(CAP_SYS_ADMIN) || !capable(CAP_SYS_RAWIO))
1551 return -EACCES;
1552 switch(drive->media) {
1553 case ide_disk:
1554 return ide_taskfile_ioctl(drive, cmd, arg);
1555 default:
1556 return -ENOMSG;
1557 }

http://groups.google.com/groups?q=ioctl%20HDIO_DRIVE_TASKFILE

From: Jeff Garzik ([email protected])
Subject: Re: "do ata" scsi command?
Newsgroups: mlist.linux.scsi
Date: 2003-05-16 09:00:27 PST
...
I don't like HDIO_DRIVE_TASKFILE in this case :) and here's why:
...
http://groups.google.com/groups?selm=linux.scsi.3EC509A1.10503%40pobox.com

#3 lore raw
Quoted 6 lines · Pat LaVarre
Quoted 6 lines
Quoted 4 lines
Quoted 1 line

- /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...

There is also HDIO_GET_IDENTITY.

#4 lore raw
Quoted 14 lines
Quoted 4 lines
Quoted 1 line

- /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...
...

Quoted 6 lines

Forget about the ! CONFIG_IDE_TASK_IOCTL
kernels, and then for the remaining kernels
persuade Google to teach you ioctl
HDIO_DRIVE_TASKFILE.
...

Quoted 1 line

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  |              ..|
---
Quoted 5 lines
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;
}