Re: [2.3.51pre2] wrong shm_statfs in ipc/shm.c

From: Alexander Viro (viro@math.psu.edu)
Date: Fri Mar 10 2000 - 08:32:39 EST


On Fri, 10 Mar 2000, Rui Sousa wrote:

> Hi,
>
> In ipc/shm.c we have:
>
> static int shm_statfs (struct super_block *, struct statfs *, int);
> ....
>
> static struct super_operations shm_sops = {
> ...
> statfs: shm_statfs,
> ...
> };
>
> But in include/linux/fs.h
>
> struct super_operations {
> ...
> int (*statfs) (struct super_block *, struct statfs *);
> ...
> };
>
>
> It gives a compiler warning about wrong pointer assignment and
> when running a number of applications fail with the following message
> in /var/log/messages:
>
> Mar 10 08:16:48 localhost kernel: shmget: shm filesystem not mounted

Clashed patches. Fix:
--- ipc/shm.c Fri Mar 10 07:29:27 2000
+++ ipc/shm.c.new Fri Mar 10 08:30:43 2000
@@ -48,7 +48,7 @@
 static int shm_remount_fs (struct super_block *, int *, char
*);
 static void shm_read_inode (struct inode *);
 static void shm_write_inode(struct inode *);
-static int shm_statfs (struct super_block *, struct statfs *, int);
+static int shm_statfs (struct super_block *, struct statfs *);
 static int shm_create (struct inode *,struct dentry *,int);
 static struct dentry *shm_lookup (struct inode *,struct dentry *);
 static int shm_unlink (struct inode *,struct dentry *);
@@ -338,18 +338,15 @@
        up(&shm_ids.sem);
 }

-static int shm_statfs(struct super_block *sb, struct statfs *buf, int bufsiz)
+static int shm_statfs(struct super_block *sb, struct statfs *buf)
 {
- struct statfs tmp;
-
- tmp.f_type = 0;
- tmp.f_bsize = PAGE_SIZE;
- tmp.f_blocks = shm_ctlall;
- tmp.f_bavail = tmp.f_bfree = shm_ctlall - shm_tot;
- tmp.f_files = shm_ctlmni;
- tmp.f_ffree = shm_ctlmni - used_segs;
- tmp.f_namelen = SHM_NAME_LEN;
- return copy_to_user(buf, &tmp, bufsiz) ? -EFAULT : 0;
+ buf->f_bsize = PAGE_SIZE;
+ buf->f_blocks = shm_ctlall;
+ buf->f_bavail = tmp.f_bfree = shm_ctlall - shm_tot;
+ buf->f_files = shm_ctlmni;
+ buf->f_ffree = shm_ctlmni - used_segs;
+ buf->f_namelen = SHM_NAME_LEN;
+ return 0;
 }

 static void shm_write_inode(struct inode * inode)

-
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 : Wed Mar 15 2000 - 21:00:17 EST