Re: [PATCH] for offsets in writing to proc files

From: Tad Ahlvers (nematode@iname.com)
Date: Mon Jul 24 2000 - 04:15:25 EST


And for those who don't want to detach it. (oops)

Tad Ahlvers wrote:
>
> This is a simple patch to allow the use of offsets when writing to proc files. I don't know if it is
> really needed but it seems correct, and I needed it for a module I was writing.
>
> This patch was created with 2.4.0-test5-pre3 and also applied fine to 2.4.0-test5-pre4.
>
> I believe I caught all uses of this function but since this is my first kernel patch, it would be
> nice if someone more knowledgeable would double check.
>
> CC me, as I am not on the KML
>
>

diff -u --recursive --new-file linux-2.4.0-test5-pre3-clean/arch/alpha/kernel/irq.c
linux/arch/alpha/kernel/irq.c
--- linux-2.4.0-test5-pre3-clean/arch/alpha/kernel/irq.c Thu Jun 22 00:30:59 2000
+++ linux/arch/alpha/kernel/irq.c Sat Jul 22 02:46:43 2000
@@ -298,7 +298,7 @@
 
 static int
 irq_affinity_write_proc(struct file *file, const char *buffer,
- unsigned long count, void *data)
+ unsigned long count, off_t off, void *data)
 {
        int irq = (long) data, full_count = count, err;
        unsigned long new_value;
diff -u --recursive --new-file linux-2.4.0-test5-pre3-clean/arch/i386/kernel/irq.c
linux/arch/i386/kernel/irq.c
--- linux-2.4.0-test5-pre3-clean/arch/i386/kernel/irq.c Sat Jul 22 03:46:55 2000
+++ linux/arch/i386/kernel/irq.c Sat Jul 22 02:45:57 2000
@@ -1061,7 +1061,7 @@
 }
 
 static int irq_affinity_write_proc (struct file *file, const char *buffer,
- unsigned long count, void *data)
+ unsigned long count, off_t off, void *data)
 {
        int irq = (long) data, full_count = count, err;
        unsigned long new_value;
@@ -1097,7 +1097,7 @@
 }
 
 static int prof_cpu_mask_write_proc (struct file *file, const char *buffer,
- unsigned long count, void *data)
+ unsigned long count, off_t off, void *data)
 {
        unsigned long *mask = (unsigned long *) data, full_count = count, err;
        unsigned long new_value;
diff -u --recursive --new-file linux-2.4.0-test5-pre3-clean/arch/ia64/kernel/irq.c
linux/arch/ia64/kernel/irq.c
--- linux-2.4.0-test5-pre3-clean/arch/ia64/kernel/irq.c Sat Jul 22 03:46:56 2000
+++ linux/arch/ia64/kernel/irq.c Sat Jul 22 02:53:12 2000
@@ -973,7 +973,7 @@
 }
 
 static int irq_affinity_write_proc (struct file *file, const char *buffer,
- unsigned long count, void *data)
+ unsigned long count, off_t off, void *data)
 {
        int irq = (long) data, full_count = count, err;
        unsigned long new_value;
@@ -1009,7 +1009,7 @@
 }
 
 static int prof_cpu_mask_write_proc (struct file *file, const char *buffer,
- unsigned long count, void *data)
+ unsigned long count, off_t off, void *data)
 {
        unsigned long *mask = (unsigned long *) data, full_count = count, err;
        unsigned long new_value;
diff -u --recursive --new-file linux-2.4.0-test5-pre3-clean/arch/ppc/kernel/irq.c
linux/arch/ppc/kernel/irq.c
--- linux-2.4.0-test5-pre3-clean/arch/ppc/kernel/irq.c Thu Jul 13 11:42:50 2000
+++ linux/arch/ppc/kernel/irq.c Sat Jul 22 02:50:16 2000
@@ -676,7 +676,7 @@
 }
 
 static int irq_affinity_write_proc (struct file *file, const char *buffer,
- unsigned long count, void *data)
+ unsigned long count, off_t off, void *data)
 {
        int irq = (int) data, full_count = count, err;
        unsigned long new_value;
@@ -712,7 +712,7 @@
 }
 
 static int prof_cpu_mask_write_proc (struct file *file, const char *buffer,
- unsigned long count, void *data)
+ unsigned long count, off_t off, void *data)
 {
        unsigned long *mask = (unsigned long *) data, full_count = count, err;
        unsigned long new_value;
diff -u --recursive --new-file linux-2.4.0-test5-pre3-clean/drivers/block/DAC960.c
linux/drivers/block/DAC960.c
--- linux-2.4.0-test5-pre3-clean/drivers/block/DAC960.c Thu Jun 22 09:15:10 2000
+++ linux/drivers/block/DAC960.c Sat Jul 22 02:25:35 2000
@@ -3646,7 +3646,7 @@
 */
 
 static int DAC960_ProcWriteUserCommand(File_T *File, const char *Buffer,
- unsigned long Count, void *Data)
+ unsigned long Count, off_t off, void *Data)
 {
   DAC960_Controller_T *Controller = (DAC960_Controller_T *) Data;
   char CommandBuffer[80];
diff -u --recursive --new-file linux-2.4.0-test5-pre3-clean/drivers/char/cpia.c
linux/drivers/char/cpia.c
--- linux-2.4.0-test5-pre3-clean/drivers/char/cpia.c Wed May 24 19:52:43 2000
+++ linux/drivers/char/cpia.c Sat Jul 22 02:26:49 2000
@@ -537,7 +537,7 @@
 }
 
 static int cpia_write_proc(struct file *file, const char *buffer,
- unsigned long count, void *data)
+ unsigned long count, off_t off, void *data)
 {
        struct cam_data *cam = data;
        struct cam_params new_params;
diff -u --recursive --new-file linux-2.4.0-test5-pre3-clean/drivers/ide/ide-proc.c
linux/drivers/ide/ide-proc.c
--- linux-2.4.0-test5-pre3-clean/drivers/ide/ide-proc.c Fri Apr 14 00:54:26 2000
+++ linux/drivers/ide/ide-proc.c Sat Jul 22 01:38:09 2000
@@ -152,7 +152,7 @@
 static struct proc_dir_entry * proc_ide_root = NULL;
 
 static int proc_ide_write_config
- (struct file *file, const char *buffer, unsigned long count, void *data)
+ (struct file *file, const char *buffer, unsigned long count, off_t off, void *data)
 {
        ide_hwif_t *hwif = (ide_hwif_t *)data;
        int for_real = 0;
@@ -496,7 +496,7 @@
 #define MAX_LEN 30
 
 static int proc_ide_write_settings
- (struct file *file, const char *buffer, unsigned long count, void *data)
+ (struct file *file, const char *buffer, unsigned long count, off_t off, void *data)
 {
        ide_drive_t *drive = (ide_drive_t *) data;
        char name[MAX_LEN + 1];
@@ -623,7 +623,7 @@
 }
 
 static int proc_ide_write_driver
- (struct file *file, const char *buffer, unsigned long count, void *data)
+ (struct file *file, const char *buffer, unsigned long count, off_t off, void *data)
 {
        ide_drive_t *drive = (ide_drive_t *) data;
 
diff -u --recursive --new-file linux-2.4.0-test5-pre3-clean/drivers/isdn/avmb1/capi.c
linux/drivers/isdn/avmb1/capi.c
--- linux-2.4.0-test5-pre3-clean/drivers/isdn/avmb1/capi.c Wed Jul 12 23:58:42 2000
+++ linux/drivers/isdn/avmb1/capi.c Sat Jul 22 03:04:48 2000
@@ -1745,7 +1745,7 @@
 }
 
 int capinc_write_proc(struct file *file, const char *buffer,
- unsigned long count, void *data)
+ unsigned long count, off_t off, void *data)
 {
        return 0;
 }
diff -u --recursive --new-file linux-2.4.0-test5-pre3-clean/drivers/net/pcmcia/ray_cs.c
linux/drivers/net/pcmcia/ray_cs.c
--- linux-2.4.0-test5-pre3-clean/drivers/net/pcmcia/ray_cs.c Sat Jul 22 03:46:59 2000
+++ linux/drivers/net/pcmcia/ray_cs.c Sat Jul 22 02:20:01 2000
@@ -2673,7 +2673,8 @@
        }
 }
 
-static int write_essid(struct file *file, const char *buffer, unsigned long count, void *data)
+static int write_essid(struct file *file, const char *buffer, unsigned long count,
+ off_t off, void *data)
 {
        static char proc_essid[33];
        int len = count;
@@ -2687,7 +2688,8 @@
        return count;
 }
 
-static int write_int(struct file *file, const char *buffer, unsigned long count, void *data)
+static int write_int(struct file *file, const char *buffer, unsigned long count,
+ off_t off, void *data)
 {
        static char proc_number[10];
        char *p;
diff -u --recursive --new-file linux-2.4.0-test5-pre3-clean/drivers/net/wan/comx-hw-comx.c
linux/drivers/net/wan/comx-hw-comx.c
--- linux-2.4.0-test5-pre3-clean/drivers/net/wan/comx-hw-comx.c Sun May 21 22:34:37 2000
+++ linux/drivers/net/wan/comx-hw-comx.c Sat Jul 22 02:08:07 2000
@@ -1022,7 +1022,7 @@
 }
 
 static int comxhw_write_proc(struct file *file, const char *buffer,
- u_long count, void *data)
+ u_long count, off_t off, void *data)
 {
        struct proc_dir_entry *entry = (struct proc_dir_entry *)data;
        struct net_device *dev = entry->parent->data;
diff -u --recursive --new-file linux-2.4.0-test5-pre3-clean/drivers/net/wan/comx-hw-locomx.c
linux/drivers/net/wan/comx-hw-locomx.c
--- linux-2.4.0-test5-pre3-clean/drivers/net/wan/comx-hw-locomx.c Sun May 21 22:34:37 2000
+++ linux/drivers/net/wan/comx-hw-locomx.c Sat Jul 22 02:09:36 2000
@@ -323,7 +323,7 @@
 }
 
 static int locomx_write_proc(struct file *file, const char *buffer,
- u_long count, void *data)
+ u_long count, off_t off, void *data)
 {
        struct proc_dir_entry *entry = (struct proc_dir_entry *)data;
        struct net_device *dev = (struct net_device *)entry->parent->data;
diff -u --recursive --new-file linux-2.4.0-test5-pre3-clean/drivers/net/wan/comx-hw-mixcom.c
linux/drivers/net/wan/comx-hw-mixcom.c
--- linux-2.4.0-test5-pre3-clean/drivers/net/wan/comx-hw-mixcom.c Sun May 21 22:34:37 2000
+++ linux/drivers/net/wan/comx-hw-mixcom.c Sat Jul 22 02:11:59 2000
@@ -733,7 +733,7 @@
 }
 
 static int mixcom_write_proc(struct file *file, const char *buffer,
- u_long count, void *data)
+ u_long count, off_t off, void *data)
 {
        struct proc_dir_entry *entry = (struct proc_dir_entry *)data;
        struct net_device *dev = (struct net_device *)entry->parent->data;
diff -u --recursive --new-file linux-2.4.0-test5-pre3-clean/drivers/net/wan/comx-proto-fr.c
linux/drivers/net/wan/comx-proto-fr.c
--- linux-2.4.0-test5-pre3-clean/drivers/net/wan/comx-proto-fr.c Sun May 21 22:34:37 2000
+++ linux/drivers/net/wan/comx-proto-fr.c Sat Jul 22 02:13:30 2000
@@ -629,7 +629,7 @@
 }
 
 static int fr_write_proc(struct file *file, const char *buffer,
- u_long count, void *data)
+ u_long count, off_t off, void *data)
 {
        struct proc_dir_entry *entry = (struct proc_dir_entry *)data;
        struct net_device *dev = entry->parent->data;
diff -u --recursive --new-file linux-2.4.0-test5-pre3-clean/drivers/net/wan/comx-proto-lapb.c
linux/drivers/net/wan/comx-proto-lapb.c
--- linux-2.4.0-test5-pre3-clean/drivers/net/wan/comx-proto-lapb.c Wed Jul 5 12:56:13 2000
+++ linux/drivers/net/wan/comx-proto-lapb.c Sat Jul 22 02:15:03 2000
@@ -213,7 +213,7 @@
 }
 
 static int comxlapb_write_proc(struct file *file, const char *buffer,
- u_long count, void *data)
+ u_long count, off_t off, void *data)
 {
        struct proc_dir_entry *entry = (struct proc_dir_entry *)data;
        struct net_device *dev = entry->parent->data;
diff -u --recursive --new-file linux-2.4.0-test5-pre3-clean/drivers/net/wan/comx.c
linux/drivers/net/wan/comx.c
--- linux-2.4.0-test5-pre3-clean/drivers/net/wan/comx.c Wed Jun 21 12:10:02 2000
+++ linux/drivers/net/wan/comx.c Sat Jul 22 02:15:36 2000
@@ -591,7 +591,7 @@
 
 
 static int comx_write_proc(struct file *file, const char *buffer, u_long count,
- void *data)
+ off_t off, void *data)
 {
        struct proc_dir_entry *entry = (struct proc_dir_entry *)data;
        struct net_device *dev = (struct net_device *)entry->parent->data;
diff -u --recursive --new-file linux-2.4.0-test5-pre3-clean/drivers/s390/misc/chandev.c
linux/drivers/s390/misc/chandev.c
--- linux-2.4.0-test5-pre3-clean/drivers/s390/misc/chandev.c Fri May 12 13:41:44 2000
+++ linux/drivers/s390/misc/chandev.c Sat Jul 22 02:42:24 2000
@@ -705,7 +705,7 @@
 
 
 static int chandev_write_proc(struct file *file, const char *buffer,
- unsigned long count, void *data)
+ unsigned long count, off_t off, void *data)
 {
        int rc;
        char *buff;
diff -u --recursive --new-file linux-2.4.0-test5-pre3-clean/drivers/scsi/scsi.c
linux/drivers/scsi/scsi.c
--- linux-2.4.0-test5-pre3-clean/drivers/scsi/scsi.c Mon Jul 10 00:14:37 2000
+++ linux/drivers/scsi/scsi.c Sat Jul 22 02:34:13 2000
@@ -1469,7 +1469,7 @@
 }
 
 static int proc_scsi_gen_write(struct file * file, const char * buf,
- unsigned long length, void *data);
+ unsigned long length, off_t off, void *data);
 
 void __init scsi_host_no_insert(char *str, int n)
 {
@@ -1663,7 +1663,7 @@
 }
 
 static int proc_scsi_gen_write(struct file * file, const char * buf,
- unsigned long length, void *data)
+ unsigned long length, off_t off, void *data)
 {
        struct Scsi_Device_Template *SDTpnt;
        Scsi_Device *scd;
diff -u --recursive --new-file linux-2.4.0-test5-pre3-clean/drivers/scsi/scsi_proc.c
linux/drivers/scsi/scsi_proc.c
--- linux-2.4.0-test5-pre3-clean/drivers/scsi/scsi_proc.c Tue Dec 21 00:05:10 1999
+++ linux/drivers/scsi/scsi_proc.c Sat Jul 22 02:31:19 2000
@@ -92,7 +92,7 @@
                                      */
 
 static int proc_scsi_write(struct file * file, const char * buf,
- unsigned long count, void *data)
+ unsigned long count, off_t off, void *data)
 {
        struct Scsi_Host *hpnt = data;
        ssize_t ret = 0;
diff -u --recursive --new-file linux-2.4.0-test5-pre3-clean/drivers/scsi/sg.c
linux/drivers/scsi/sg.c
--- linux-2.4.0-test5-pre3-clean/drivers/scsi/sg.c Wed Jul 12 23:58:43 2000
+++ linux/drivers/scsi/sg.c Sat Jul 22 03:30:12 2000
@@ -2453,7 +2453,7 @@
 static int sg_proc_dressz_info(char * buffer, int * len, off_t * begin,
                               off_t offset, int size);
 static int sg_proc_dressz_write(struct file * filp, const char * buffer,
- unsigned long count, void * data);
+ unsigned long count, off_t off, void * data);
 static int sg_proc_debug_read(char * buffer, char ** start, off_t offset,
                              int size, int * eof, void * data);
 static int sg_proc_debug_info(char * buffer, int * len, off_t * begin,
@@ -2568,7 +2568,7 @@
 }
 
 static int sg_proc_dressz_write(struct file * filp, const char * buffer,
- unsigned long count, void * data)
+ unsigned long count, off_t off, void * data)
 {
     int num;
     unsigned long k = ULONG_MAX;
diff -u --recursive --new-file linux-2.4.0-test5-pre3-clean/drivers/usb/ov511.c
linux/drivers/usb/ov511.c
--- linux-2.4.0-test5-pre3-clean/drivers/usb/ov511.c Sat Jul 22 03:47:00 2000
+++ linux/drivers/usb/ov511.c Sat Jul 22 02:37:07 2000
@@ -354,7 +354,7 @@
 }
 
 static int ov511_write_proc(struct file *file, const char *buffer,
- unsigned long count, void *data)
+ unsigned long count, off_t off, void *data)
 {
        return -EINVAL;
 }
diff -u --recursive --new-file linux-2.4.0-test5-pre3-clean/fs/binfmt_misc.c linux/fs/binfmt_misc.c
--- linux-2.4.0-test5-pre3-clean/fs/binfmt_misc.c Mon Jun 26 13:36:44 2000
+++ linux/fs/binfmt_misc.c Sat Jul 22 02:05:48 2000
@@ -276,7 +276,7 @@
  * where the ':' is the IFS, that can be chosen with the first char
  */
 static int proc_write_register(struct file *file, const char *buffer,
- unsigned long count, void *data)
+ unsigned long count, off_t off, void *data)
 {
        const char *sp;
        char del, *dp;
@@ -419,7 +419,7 @@
  * '1' enables, '0' disables and '-1' clears entry/binfmt_misc
  */
 static int proc_write_status(struct file *file, const char *buffer,
- unsigned long count, void *data)
+ unsigned long count, off_t off, void *data)
 {
        struct binfmt_entry *e;
        int res = count;
diff -u --recursive --new-file linux-2.4.0-test5-pre3-clean/fs/proc/generic.c
linux/fs/proc/generic.c
--- linux-2.4.0-test5-pre3-clean/fs/proc/generic.c Thu Jun 22 09:09:45 2000
+++ linux/fs/proc/generic.c Sat Jul 22 04:22:44 2000
@@ -132,8 +132,7 @@
        if (!dp->write_proc)
                return -EIO;
 
- /* FIXME: does this routine need ppos? probably... */
- return dp->write_proc(file, buffer, count, dp->data);
+ return dp->write_proc(file, buffer, count, *ppos, dp->data);
 }
 
 
diff -u --recursive --new-file linux-2.4.0-test5-pre3-clean/include/linux/proc_fs.h
linux/include/linux/proc_fs.h
--- linux-2.4.0-test5-pre3-clean/include/linux/proc_fs.h Thu Jul 13 00:01:44 2000
+++ linux/include/linux/proc_fs.h Sat Jul 22 01:22:08 2000
@@ -47,7 +47,7 @@
 typedef int (read_proc_t)(char *page, char **start, off_t off,
                          int count, int *eof, void *data);
 typedef int (write_proc_t)(struct file *file, const char *buffer,
- unsigned long count, void *data);
+ unsigned long count, off_t off, void *data);
 typedef int (get_info_t)(char *, char **, off_t, int);
 
 struct proc_dir_entry {
diff -u --recursive --new-file linux-2.4.0-test5-pre3-clean/include/linux/slab.h
linux/include/linux/slab.h
--- linux-2.4.0-test5-pre3-clean/include/linux/slab.h Sat Jul 22 03:47:04 2000
+++ linux/include/linux/slab.h Sat Jul 22 01:23:25 2000
@@ -63,7 +63,7 @@
 extern int slabinfo_read_proc(char *page, char **start, off_t off,
                                 int count, int *eof, void *data);
 extern int slabinfo_write_proc(struct file *file, const char *buffer,
- unsigned long count, void *data);
+ unsigned long count, off_t off, void *data);
 
 /* System wide caches */
 extern kmem_cache_t *vm_area_cachep;
diff -u --recursive --new-file linux-2.4.0-test5-pre3-clean/include/linux/tty_driver.h
linux/include/linux/tty_driver.h
--- linux-2.4.0-test5-pre3-clean/include/linux/tty_driver.h Thu Jul 13 00:01:34 2000
+++ linux/include/linux/tty_driver.h Sat Jul 22 01:21:30 2000
@@ -169,7 +169,7 @@
        int (*read_proc)(char *page, char **start, off_t off,
                          int count, int *eof, void *data);
        int (*write_proc)(struct file *file, const char *buffer,
- unsigned long count, void *data);
+ unsigned long count, off_t off, void *data);
 
        /*
         * linked list pointers
diff -u --recursive --new-file linux-2.4.0-test5-pre3-clean/mm/slab.c linux/mm/slab.c
--- linux-2.4.0-test5-pre3-clean/mm/slab.c Wed Jul 12 18:24:38 2000
+++ linux/mm/slab.c Sat Jul 22 03:00:47 2000
@@ -1972,7 +1972,7 @@
  * @data: unused
  */
 int slabinfo_write_proc (struct file *file, const char *buffer,
- unsigned long count, void *data)
+ unsigned long count, off_t off, void *data)
 {
 #ifdef CONFIG_SMP
        char kbuf[MAX_SLABINFO_WRITE], *tmp;

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Mon Jul 31 2000 - 21:00:15 EST