patch-1.3.6 linux/fs/proc/scsi.c

Next file: linux/include/asm-i386/checksum.h
Previous file: linux/fs/proc/net.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v1.3.5/linux/fs/proc/scsi.c linux/fs/proc/scsi.c
@@ -12,12 +12,12 @@
  *
  *  Initial version: March '95
  *  95/15/05 Added subdirectories for each driver and show every
- *           registered HBA as a single file. 
+ *	     registered HBA as a single file. 
  *  95/30/05 Added rudimentary write support for parameter passing
  *
  *  TODO: Improve support to write to the driver files
- *        Optimize directory handling 
- *        Add some more comments
+ *	  Optimize directory handling 
+ *	  Add some more comments
  */
 #include <linux/autoconf.h>
 #include <asm/segment.h>
@@ -30,11 +30,11 @@
 
 /* forward references */
 static int proc_readscsi(struct inode * inode, struct file * file,
-                         char * buf, int count);
+			 char * buf, int count);
 static int proc_writescsi(struct inode * inode, struct file * file,
-                         char * buf, int count);
+			 char * buf, int count);
 static int proc_readscsidir(struct inode *, struct file *, 
-                            void *, filldir_t filldir);
+			    void *, filldir_t filldir);
 static int proc_lookupscsi(struct inode *,const char *,int,struct inode **);
 static int proc_scsilseek(struct inode *, struct file *, off_t, int);
 
@@ -46,16 +46,16 @@
     
     
 static struct file_operations proc_scsi_operations = {
-    proc_scsilseek,     /* lseek   */
-    proc_readscsi,      /* read    */
-    proc_writescsi,     /* write   */
-    proc_readscsidir,   /* readdir */
-    NULL,               /* select  */
-    NULL,               /* ioctl   */
-    NULL,               /* mmap    */
-    NULL,               /* no special open code    */
-    NULL,               /* no special release code */
-    NULL                /* can't fsync */
+    proc_scsilseek,	/* lseek   */
+    proc_readscsi,	/* read	   */
+    proc_writescsi,	/* write   */
+    proc_readscsidir,	/* readdir */
+    NULL,		/* select  */
+    NULL,		/* ioctl   */
+    NULL,		/* mmap	   */
+    NULL,		/* no special open code	   */
+    NULL,		/* no special release code */
+    NULL		/* can't fsync */
 };
 
 /*
@@ -63,29 +63,29 @@
  */
 struct inode_operations proc_scsi_inode_operations = {
     &proc_scsi_operations,  /* default scsi directory file-ops */
-    NULL,           /* create      */
-    proc_lookupscsi,/* lookup      */
-    NULL,           /* link        */
-    NULL,           /* unlink      */
-    NULL,           /* symlink     */
-    NULL,           /* mkdir       */
-    NULL,           /* rmdir       */
-    NULL,           /* mknod       */
-    NULL,           /* rename      */
-    NULL,           /* readlink    */
-    NULL,           /* follow_link */
-    NULL,           /* bmap        */
-    NULL,           /* truncate    */
-    NULL            /* permission  */
+    NULL,	    /* create	   */
+    proc_lookupscsi,/* lookup	   */
+    NULL,	    /* link	   */
+    NULL,	    /* unlink	   */
+    NULL,	    /* symlink	   */
+    NULL,	    /* mkdir	   */
+    NULL,	    /* rmdir	   */
+    NULL,	    /* mknod	   */
+    NULL,	    /* rename	   */
+    NULL,	    /* readlink	   */
+    NULL,	    /* follow_link */
+    NULL,	    /* bmap	   */
+    NULL,	    /* truncate	   */
+    NULL	    /* permission  */
 };
 
 struct proc_dir_entry scsi_dir[PROC_SCSI_FILE - PROC_SCSI_SCSI + 3]; 
 struct proc_dir_entry scsi_hba_dir[(PROC_SCSI_LAST - PROC_SCSI_FILE) * 4]; 
 
 static struct proc_dir_entry scsi_dir2[] = {
-    { PROC_SCSI,                 1, "." },
-    { PROC_ROOT_INO,             2, ".." },
-    { PROC_SCSI_NOT_PRESENT,    11, "not.present" },
+    { PROC_SCSI,		 1, "." },
+    { PROC_ROOT_INO,		 2, ".." },
+    { PROC_SCSI_NOT_PRESENT,	11, "not.present" },
     { 0, 0, NULL }
 };
 
@@ -96,72 +96,72 @@
     
     
     if(dispatch_scsi_info_ptr)
-        if (inode <= PROC_SCSI_SCSI_DEBUG)
-            dir = scsi_dir;
-        else
-            dir = scsi_hba_dir;
+	if (inode <= PROC_SCSI_SCSI_DEBUG)
+	    dir = scsi_dir;
+	else
+	    dir = scsi_hba_dir;
     else dir = scsi_dir2;
     
     while(dir[i].low_ino)
-        i++;
+	i++;
     
     return(i);
 }
 
 static int proc_lookupscsi(struct inode * dir, const char * name, int len,
-                           struct inode ** result)
+			   struct inode ** result)
 {
     struct proc_dir_entry *de = NULL;
     
     *result = NULL;
     if (!dir)
-        return(-ENOENT);
+	return(-ENOENT);
     if (!S_ISDIR(dir->i_mode)) {
-        iput(dir);
-        return(-ENOENT);
+	iput(dir);
+	return(-ENOENT);
     }
     if (dispatch_scsi_info_ptr != NULL)
-        if (dir->i_ino <= PROC_SCSI_SCSI)
-            de = scsi_dir;
-        else {
-            de = &scsi_hba_dir[dispatch_scsi_info_ptr(dir->i_ino, 0, 0, 0, 0, 2)];
-        }
+	if (dir->i_ino <= PROC_SCSI_SCSI)
+	    de = scsi_dir;
+	else {
+	    de = &scsi_hba_dir[dispatch_scsi_info_ptr(dir->i_ino, 0, 0, 0, 0, 2)];
+	}
     else
-        de = scsi_dir2;
+	de = scsi_dir2;
     
     for (; de->name ; de++) {
-        if (!proc_match(len, name, de))
-            continue;
-        *result = iget(dir->i_sb, de->low_ino);
-        iput(dir);
-        if (!*result)
-            return(-ENOENT);
-        return(0);
+	if (!proc_match(len, name, de))
+	    continue;
+	*result = iget(dir->i_sb, de->low_ino);
+	iput(dir);
+	if (!*result)
+	    return(-ENOENT);
+	return(0);
     }
     iput(dir);
     return(-ENOENT);
 }
 
 static int proc_readscsidir(struct inode * inode, struct file * filp,
-                            void * dirent, filldir_t filldir)
+			    void * dirent, filldir_t filldir)
 {
     struct proc_dir_entry * de;
     unsigned int ino;
     
     if (!inode || !S_ISDIR(inode->i_mode))
-        return(-EBADF);
+	return(-EBADF);
     ino = inode->i_ino;
-	while (((unsigned) filp->f_pos) < count_dir_entries(ino)) {
-        if (dispatch_scsi_info_ptr)
-            if (ino <= PROC_SCSI_SCSI)
-                de = scsi_dir + filp->f_pos;
-            else
-                de = scsi_hba_dir + filp->f_pos;
-        else
-            de = scsi_dir2 + filp->f_pos;
-        if (filldir(dirent, de->name, de->namelen, filp->f_pos, de->low_ino)<0)
-            break;
-        filp->f_pos++;
+    while (((unsigned) filp->f_pos) < count_dir_entries(ino)) {
+	if (dispatch_scsi_info_ptr)
+	    if (ino <= PROC_SCSI_SCSI)
+		de = scsi_dir + filp->f_pos;
+	    else
+		de = scsi_hba_dir + filp->f_pos;
+	else
+	    de = scsi_dir2 + filp->f_pos;
+	if (filldir(dirent, de->name, de->namelen, filp->f_pos, de->low_ino)<0)
+	    break;
+	filp->f_pos++;
     }
     return(0);
 }
@@ -172,26 +172,26 @@
     
     begin = 0;
     pos = len = sprintf(buffer, 
-                        "The scsi core module is currently not present\n");
+			"The scsi core module is currently not present\n");
     if(pos < offset) {
-        len = 0;
-        begin = pos;
+	len = 0;
+	begin = pos;
     }
     
-    *start = buffer + (offset - begin);   /* Start of wanted data */
+    *start = buffer + (offset - begin);	  /* Start of wanted data */
     len -= (offset - begin);
     if(len > length)
-        len = length;
+	len = length;
     
     return(len);
 }
 
 #define PROC_BLOCK_SIZE (3*1024)     /* 4K page size, but our output routines 
-                                      * use some slack for overruns 
-                                      */
+				      * use some slack for overruns 
+				      */
 
 static int proc_readscsi(struct inode * inode, struct file * file,
-                         char * buf, int count)
+			 char * buf, int count)
 {
     uint ino;
     int length;
@@ -201,52 +201,52 @@
     char * page;
     char * start;
     
-    if (count < -1)               /* Normally I wouldn't do this, */ 
-        return(-EINVAL);          /* but it saves some redundant code.
-                                   * Now it is possible to seek to the 
-                                   * end of the file */
+    if (count < -1)		  /* Normally I wouldn't do this, */ 
+	return(-EINVAL);	  /* but it saves some redundant code.
+				   * Now it is possible to seek to the 
+				   * end of the file */
     if (!(page = (char *) __get_free_page(GFP_KERNEL)))
-        return(-ENOMEM);
+	return(-ENOMEM);
     ino = inode->i_ino;
     
     
     while(bytes > 0 || count == -1)
     {
-        
-        thistime = bytes;
-        if(bytes > PROC_BLOCK_SIZE || count == -1)
-            thistime = PROC_BLOCK_SIZE;
-        
-        if(dispatch_scsi_info_ptr)
-            length = dispatch_scsi_info_ptr(ino, page, &start, 
-                                            file->f_pos, thistime, 0);
-        else
-            length = get_not_present_info(page, &start, file->f_pos, thistime);
-        if(length < 0) {
-            free_page((ulong) page);
-            return(length);
-        }
-        
-        /*
-         *  We have been given a non page aligned block of
-         *  the data we asked for + a bit. We have been given
-         *  the start pointer and we know the length.. 
-         */
-        if (length <= 0)
-            break;
-        /*
-         *  Copy the bytes, if we're not doing a seek to 
-         *      the end of the file 
-         */
-        if (count != -1)
-            memcpy_tofs(buf + copied, start, length);
-        file->f_pos += length;  /* Move down the file */
-        bytes -= length;
-        copied += length;
-        
-        if(length < thistime)
-            break;  /* End of file */
-        
+	
+	thistime = bytes;
+	if(bytes > PROC_BLOCK_SIZE || count == -1)
+	    thistime = PROC_BLOCK_SIZE;
+	
+	if(dispatch_scsi_info_ptr)
+	    length = dispatch_scsi_info_ptr(ino, page, &start, 
+					    file->f_pos, thistime, 0);
+	else
+	    length = get_not_present_info(page, &start, file->f_pos, thistime);
+	if(length < 0) {
+	    free_page((ulong) page);
+	    return(length);
+	}
+	
+	/*
+	 *  We have been given a non page aligned block of
+	 *  the data we asked for + a bit. We have been given
+	 *  the start pointer and we know the length.. 
+	 */
+	if (length <= 0)
+	    break;
+	/*
+	 *  Copy the bytes, if we're not doing a seek to 
+	 *	the end of the file 
+	 */
+	if (count != -1)
+	    memcpy_tofs(buf + copied, start, length);
+	file->f_pos += length;	/* Move down the file */
+	bytes -= length;
+	copied += length;
+	
+	if(length < thistime)
+	    break;  /* End of file */
+	
     }
     
     free_page((ulong) page);
@@ -255,27 +255,27 @@
 
 
 static int proc_writescsi(struct inode * inode, struct file * file,
-                         char * buf, int count)
+			 char * buf, int count)
 {
     uint ino;
     int ret = 0;
     char * page;
     
     if (!(page = (char *) __get_free_page(GFP_KERNEL)))
-        return(-ENOMEM);
+	return(-ENOMEM);
 
     if(count > PROC_BLOCK_SIZE) {
-        return(-EOVERFLOW);
+	return(-EOVERFLOW);
     }
 
     ino = inode->i_ino;
     
     if(dispatch_scsi_info_ptr != NULL) {
-        memcpy_fromfs(page, buf, count);
-        ret = dispatch_scsi_info_ptr(ino, page, 0, 0, count, 1);
+	memcpy_fromfs(page, buf, count);
+	ret = dispatch_scsi_info_ptr(ino, page, 0, 0, count, 1);
     } else {
-        free_page((ulong) page);   
-        return(-ENOPKG);          /* Nothing here */
+	free_page((ulong) page);   
+	return(-ENOPKG);	  /* Nothing here */
     }
     
     free_page((ulong) page);
@@ -284,22 +284,22 @@
 
 
 static int proc_scsilseek(struct inode * inode, struct file * file, 
-                          off_t offset, int orig)
+			  off_t offset, int orig)
 {
     switch (orig) {
     case 0:
-        file->f_pos = offset;
-        return(file->f_pos);
+	file->f_pos = offset;
+	return(file->f_pos);
     case 1:
-        file->f_pos += offset;
-        return(file->f_pos);
-    case 2:                  /* This ugly hack allows us to    */
-        if (offset)          /* to determine the length of the */
-            return(-EINVAL); /* file and then later savely to  */ 
-        proc_readscsi(inode, file, 0, -1); /* seek in it       */ 
-        return(file->f_pos);
+	file->f_pos += offset;
+	return(file->f_pos);
+    case 2:		     /* This ugly hack allows us to    */
+	if (offset)	     /* to determine the length of the */
+	    return(-EINVAL); /* file and then later savely to  */ 
+	proc_readscsi(inode, file, 0, -1); /* seek in it       */ 
+	return(file->f_pos);
     default:
-        return(-EINVAL);
+	return(-EINVAL);
     }
 }
 
@@ -318,6 +318,6 @@
  * c-continued-statement-offset: 4
  * c-continued-brace-offset: 0
  * indent-tabs-mode: nil
- * tab-width: 4
+ * tab-width: 8
  * End:
  */

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov with Sam's (original) version
of this