[patch] 2.1.60: quotas and sound (and nvram)

Janos Farkas (Janos.Farkas-#uHrnrnmso493mxu4Ekk50cva@shadow.banki.hu)
Wed, 29 Oct 1997 08:45:01 +0100


On Mon, Oct 27, 1997 at 01:02:00PM -0500, Simon Karpen wrote:
> but the sound doesn't work. 'cat /dev/sndstat' returns invalid
> argument[...]

On Mon, Oct 27, 1997 at 09:54:20PM -0700, teunis wrote:
> (cat /dev/sndstat fails with "cat: /dev/sndstat: Invalid argument")

On Wed, Oct 29, 1997 at 06:59:21AM +1000, Russell Coker - mailing lists account wrote:
> Quota seems badly broken in 2.1.60[...]

Ok, so it seems many others had the same problems. :) Assuming
vger is not so crowded now and not just me who doesn't get the patches
for this, I append the patches to fix these problems.

Summary:
nvram: fix for the new _read/_write conventions
soundcard/dmasound: likewise (soundcard is the main culprit, dmasound
is the m68k version, but I fixed it accidently.. :)
quota: likewise, and the small fix it needed in the earlier versions
too.

The problem was that the new VFS read/write functions take different
arguments but GCC sees the prototype mismatch as a warning, but it's
fatal in this case.

And I found the 'isofs can't compile without Joliet', but there was
already a patch to fix that.

Oh, and about the reluctancy on including the quota fixes into the
mainstream kernel, is this because Linus doesn't use quota or is quota
broken anyways? I remember some weeks ago someone posted that there
are a few problems with the quota code, I imagine that's a more
possible reason to force others into looking at that code.. :)

diff -urpN linux-2.1.60-ORIG/drivers/char/nvram.c linux/drivers/char/nvram.c
--- linux-2.1.60-ORIG/drivers/char/nvram.c Sat Sep 13 20:07:27 1997
+++ linux/drivers/char/nvram.c Sun Oct 26 17:38:37 1997
@@ -227,11 +227,11 @@ static long long nvram_llseek(struct fil
return( (offset >= 0) ? (file->f_pos = offset) : -EINVAL );
}

-static long nvram_read( struct inode * inode, struct file * file,
- char * buf, unsigned long count )
+static ssize_t nvram_read( struct file * file,
+ char * buf, size_t count, loff_t *ppos )
{
unsigned long flags;
- unsigned i = file->f_pos;
+ unsigned i = *ppos;
char *tmp = buf;

save_flags(flags);
@@ -244,17 +244,16 @@ static long nvram_read( struct inode * i

for( ; count-- > 0 && i < NVRAM_BYTES; ++i, ++tmp )
put_user( nvram_read_int(i), tmp );
- file->f_pos = i;
+ *ppos = i;

restore_flags(flags);
return( tmp - buf );
}

-static long nvram_write( struct inode * inode, struct file * file,
- const char * buf, unsigned long count )
+static ssize_t nvram_write( struct file * file, const char * buf, size_t count, loff_t *ppos )
{
unsigned long flags;
- unsigned i = file->f_pos;
+ unsigned i = *ppos;
const char *tmp = buf;
char c;

@@ -271,7 +270,7 @@ static long nvram_write( struct inode *
nvram_write_int( c, i );
}
nvram_set_checksum_int();
- file->f_pos = i;
+ *ppos = i;

restore_flags(flags);
return( tmp - buf );
diff -urpN linux-2.1.60-ORIG/drivers/sound/dmasound.c linux/drivers/sound/dmasound.c
--- linux-2.1.60-ORIG/drivers/sound/dmasound.c Sat Oct 18 13:42:23 1997
+++ linux/drivers/sound/dmasound.c Sun Oct 26 17:41:31 1997
@@ -670,11 +670,9 @@ static long state_read(char *dest, unsig
static int sound_open(struct inode *inode, struct file *file);
static int sound_fsync(struct file *filp, struct dentry *dentry);
static void sound_release(struct inode *inode, struct file *file);
-static long long sound_lseek(struct file *file, long long offset, int orig);
-static long sound_read(struct inode *inode, struct file *file, char *buf,
- unsigned long count);
-static long sound_write(struct inode *inode, struct file *file,
- const char *buf, unsigned long count);
+static loff_t sound_lseek(struct file *file, loff_t offset, int orig);
+static ssize_t sound_read(struct file *file, char *buf, size_t count, loff_t *ppos);
+static ssize_t sound_write(struct file *file, const char *buf, size_t count, loff_t *ppos);
static inline int ioctl_return(int *addr, int value)
{
if (value < 0)
@@ -3115,16 +3113,18 @@ static void sound_release(struct inode *
}


-static long long sound_lseek(struct file *file, long long offset, int orig)
+static loff_t sound_lseek(struct file *file, loff_t offset, int orig)
{
return -ESPIPE;
}


-static long sound_read(struct inode *inode, struct file *file, char *buf,
- unsigned long count)
+static ssize_t sound_read(struct file *file, char *buf,size_t count, loff_t *ppos)
{
- int dev = MINOR(inode->i_rdev);
+ int dev = MINOR(file->f_dentry->d_inode->i_rdev);
+
+ if (ppos != &file->f_pos)
+ return -ESPIPE;

switch (dev & 0x0f) {
case SND_DEV_STATUS:
@@ -3139,10 +3139,12 @@ static long sound_read(struct inode *ino
}


-static long sound_write(struct inode *inode, struct file *file,
- const char *buf, unsigned long count)
+static ssize_t sound_write(struct file *file, const char *buf, size_t count, loff_t *ppos)
{
- int dev = MINOR(inode->i_rdev);
+ int dev = MINOR(file->f_dentry->d_inode->i_rdev);
+
+ if (ppos != &file->f_pos)
+ return -ESPIPE;

switch (dev & 0x0f) {
case SND_DEV_STATUS:
diff -urpN linux-2.1.60-ORIG/drivers/sound/soundcard.c linux/drivers/sound/soundcard.c
--- linux-2.1.60-ORIG/drivers/sound/soundcard.c Mon Sep 15 21:46:21 1997
+++ linux/drivers/sound/soundcard.c Sun Oct 26 17:45:29 1997
@@ -56,33 +56,37 @@ static char dma_alloc_map[8] =



-static long
-sound_read (struct inode *inode, struct file *file, char *buf, unsigned long count)
+static ssize_t sound_read (struct file *file, char *buf, size_t count, loff_t *ppos)
{
int dev;

- dev = MINOR (inode->i_rdev);
+ if (ppos != &file->f_pos)
+ return -ESPIPE;
+
+ dev = MINOR (file->f_dentry->d_inode->i_rdev);

files[dev].flags = file->f_flags;

return sound_read_sw (dev, &files[dev], buf, count);
}

-static long
-sound_write (struct inode *inode, struct file *file, const char *buf, unsigned long count)
+static ssize_t sound_write (struct file *file, const char *buf, size_t count, loff_t *ppos)
{
int dev;

- dev = MINOR (inode->i_rdev);
+ if (ppos != &file->f_pos)
+ return -ESPIPE;
+
+ dev = MINOR (file->f_dentry->d_inode->i_rdev);

files[dev].flags = file->f_flags;

return sound_write_sw (dev, &files[dev], buf, count);
}

-static long long sound_lseek (struct file *file, long long offset, int orig)
+static loff_t sound_lseek (struct file *file, loff_t offset, int orig)
{
- return -EPERM;
+ return -ESPIPE;
}

static int
diff -urpN linux-2.1.60-ORIG/fs/dquot.c linux/fs/dquot.c
--- linux-2.1.60-ORIG/fs/dquot.c Sun Sep 7 20:11:30 1997
+++ linux/fs/dquot.c Sun Oct 26 17:06:20 1997
@@ -229,7 +229,7 @@ static void write_dquot(struct dquot *dq
lock_dquot(dquot);
down(&dquot->dq_mnt->mnt_sem);
if (filp->f_op->llseek) {
- if (filp->f_op->llseek(filp->f_dentry->d_inode, filp,
+ if (filp->f_op->llseek(filp,
dqoff(dquot->dq_id), 0) != dqoff(dquot->dq_id)) {
up(&dquot->dq_mnt->mnt_sem);
unlock_dquot(dquot);
@@ -240,8 +240,9 @@ static void write_dquot(struct dquot *dq
fs = get_fs();
set_fs(KERNEL_DS);

- if (filp->f_op->write(filp->f_dentry->d_inode, filp,
- (char *)&dquot->dq_dqb, sizeof(struct dqblk)) == sizeof(struct dqblk))
+ if (filp->f_op->write(filp, (char *)&dquot->dq_dqb,
+ sizeof(struct dqblk),
+ &filp->f_pos) == sizeof(struct dqblk))
dquot->dq_flags &= ~DQ_MOD;

up(&dquot->dq_mnt->mnt_sem);
@@ -261,7 +262,7 @@ static void read_dquot(struct dquot *dqu
lock_dquot(dquot);
down(&dquot->dq_mnt->mnt_sem);
if (filp->f_op->llseek) {
- if (filp->f_op->llseek(filp->f_dentry->d_inode, filp,
+ if (filp->f_op->llseek(filp,
dqoff(dquot->dq_id), 0) != dqoff(dquot->dq_id)) {
up(&dquot->dq_mnt->mnt_sem);
unlock_dquot(dquot);
@@ -271,7 +272,8 @@ static void read_dquot(struct dquot *dqu
filp->f_pos = dqoff(dquot->dq_id);
fs = get_fs();
set_fs(KERNEL_DS);
- filp->f_op->read(filp->f_dentry->d_inode, filp, (char *)&dquot->dq_dqb, sizeof(struct dqblk));
+ filp->f_op->read(filp, (char *)&dquot->dq_dqb, sizeof(struct dqblk),
+ &filp->f_pos);
up(&dquot->dq_mnt->mnt_sem);
set_fs(fs);
if (dquot->dq_bhardlimit == 0 && dquot->dq_bsoftlimit == 0 &&