[ide] fix /proc/ide/hd?/settings to not spam logs

On Thu, 11 Nov 2004 17:10:21 +0100, Jens Axboe <axboe@suse.de> wrote:
> On Thu, Nov 11 2004, Alan Cox wrote:
> > > +   printk(KERN_WARNING "Warning: /proc/ide/hd?/settings interface is "
> > > +                       "obsolete, and will be removed soon!\n");
> > > +
> >
> > The above should be rate limited or on the write case moved to after
> > the capable() check. A program polling these settings now makes a nasty
> > noise and wipes the logs. A user can also do it intentionally.
> 
> Or just print it once...
Signed-off-by: default avatarBartlomiej Zolnierkiewicz <bzolnier@gmail.com>
parent 06f7df46
......@@ -124,6 +124,18 @@ static int proc_ide_read_identify
PROC_IDE_READ_RETURN(page,start,off,count,eof,len);
}
static void proc_ide_settings_warn(void)
{
static int warned = 0;
if (warned)
return;
printk(KERN_WARNING "Warning: /proc/ide/hd?/settings interface is "
"obsolete, and will be removed soon!\n");
warned = 1;
}
static int proc_ide_read_settings
(char *page, char **start, off_t off, int count, int *eof, void *data)
{
......@@ -132,8 +144,7 @@ static int proc_ide_read_settings
char *out = page;
int len, rc, mul_factor, div_factor;
printk(KERN_WARNING "Warning: /proc/ide/hd?/settings interface is "
"obsolete, and will be removed soon!\n");
proc_ide_settings_warn();
down(&ide_setting_sem);
out += sprintf(out, "name\t\t\tvalue\t\tmin\t\tmax\t\tmode\n");
......@@ -171,12 +182,11 @@ static int proc_ide_write_settings(struct file *file, const char __user *buffer,
ide_settings_t *setting;
char *buf, *s;
printk(KERN_WARNING "Warning: /proc/ide/hd?/settings interface is "
"obsolete, and will be removed soon!\n");
if (!capable(CAP_SYS_ADMIN))
return -EACCES;
proc_ide_settings_warn();
if (count >= PAGE_SIZE)
return -EINVAL;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment