public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Antonio Gallo <agx@linux.it>
To: linux-kernel@vger.kernel.org
Cc: andre@linux-ide.org, rubini@gnu.org
Subject: [PATCH] serial_no displaed under /proc/ide/ideX/hdX/
Date: Tue, 23 Sep 2003 12:07:01 +0200	[thread overview]
Message-ID: <20030923120701.4c31f455.agx@linux.it> (raw)


This you to "cat" the file /proc/ide/ide*/hd*/serial_no in order to
display the "Serial Number" of the selected HD, if available.

The patch just add this entries to the proc filesystem since the serial_no
is already there thanks to already implemented kernel functions.

I also added some few notes to the kernel.

The patch is for kernel 2.4.21, i also tested it with 2.4.22

The touched file are drivers/ide/ide-disk.c and drivers/ide/ide-proc.c

I'm no currently subscribed to the kernel ML so if possibile answer me back
to my source email address.

Thank you in advance, this is my FIRST kernel patch :-) i hope it is
usefull as it is usefull for me, bye!!!

Antonio Gallo - http://www.linux.it/~agx/



diff -urN linux-vanilla/drivers/ide/ide-disk.c linux-2.4.21/drivers/ide/ide-disk.c
--- linux-vanilla/drivers/ide/ide-disk.c	2003-06-13 16:51:33.000000000 +0200
+++ linux-2.4.21/drivers/ide/ide-disk.c	2003-09-22 12:43:53.000000000 +0200
@@ -1397,6 +1397,10 @@
 	PROC_IDE_READ_RETURN(page,start,off,count,eof,len);
 }
 
+/*
+ * this static array defines addittional entries that the proc virtual filesystem
+ * will display under the /proc/ide/ideX/hdX directory (Antonio Gallo)
+ */
 static ide_proc_entry_t idedisk_proc[] = {
 	{ "cache",		S_IFREG|S_IRUGO,	proc_idedisk_read_cache,		NULL },
 	{ "geometry",		S_IFREG|S_IRUGO,	proc_ide_read_geometry,			NULL },
diff -urN linux-vanilla/drivers/ide/ide-proc.c linux-2.4.21/drivers/ide/ide-proc.c
--- linux-vanilla/drivers/ide/ide-proc.c	2003-06-13 16:51:33.000000000 +0200
+++ linux-2.4.21/drivers/ide/ide-proc.c	2003-09-22 12:43:33.000000000 +0200
@@ -691,6 +691,25 @@
 
 EXPORT_SYMBOL(proc_ide_read_dmodel);
 
+/*
+ * This function return to the proc virtual filesystem the "serial_no" field
+ * of the drive->id structure if available. This function is exactly as the
+ * above proc_ide_read_dmodel (Antonio Gallo)
+ */
+int proc_ide_read_serial_no
+	(char *page, char **start, off_t off, int count, int *eof, void *data)
+{
+	ide_drive_t	*drive = (ide_drive_t *) data;
+	struct hd_driveid *id = drive->id;
+	int		len;
+
+	len = sprintf(page, "%.40s\n",
+		(id && id->serial_no[0]) ? (char *)id->serial_no : "(none)");
+	PROC_IDE_READ_RETURN(page,start,off,count,eof,len);
+}
+
+EXPORT_SYMBOL(proc_ide_read_serial_no);
+
 int proc_ide_read_driver
 	(char *page, char **start, off_t off, int count, int *eof, void *data)
 {
@@ -745,12 +764,17 @@
 
 EXPORT_SYMBOL(proc_ide_read_media);
 
+/*
+ * This static array defines the entries that the proc virtual filesystem will display
+ * under the /proc/ide/ideX/hdX directory (Antonio Gallo)
+ */
 static ide_proc_entry_t generic_drive_entries[] = {
 	{ "driver",	S_IFREG|S_IRUGO,	proc_ide_read_driver,	proc_ide_write_driver },
 	{ "identify",	S_IFREG|S_IRUSR,	proc_ide_read_identify,	NULL },
 	{ "media",	S_IFREG|S_IRUGO,	proc_ide_read_media,	NULL },
 	{ "model",	S_IFREG|S_IRUGO,	proc_ide_read_dmodel,	NULL },
 	{ "settings",	S_IFREG|S_IRUSR|S_IWUSR,proc_ide_read_settings,	proc_ide_write_settings },
+	{ "serial_no",	S_IFREG|S_IRUGO,	proc_ide_read_serial_no,NULL },
 	{ NULL,	0, NULL, NULL }
 };
 
@@ -874,6 +898,10 @@
 
 EXPORT_SYMBOL(destroy_proc_ide_drives);
 
+/*
+ * This static array defines the entries that the proc virtual filesystem will display
+ * under the /proc/ide/ideX/ directory (Antonio Gallo)
+ */
 static ide_proc_entry_t hwif_entries[] = {
 	{ "channel",	S_IFREG|S_IRUGO,	proc_ide_read_channel,	NULL },
 	{ "config",	S_IFREG|S_IRUGO|S_IWUSR,proc_ide_read_config,	proc_ide_write_config },

                 reply	other threads:[~2003-09-23 10:08 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20030923120701.4c31f455.agx@linux.it \
    --to=agx@linux.it \
    --cc=andre@linux-ide.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rubini@gnu.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