[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 ...@@ -124,6 +124,18 @@ static int proc_ide_read_identify
PROC_IDE_READ_RETURN(page,start,off,count,eof,len); 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 static int proc_ide_read_settings
(char *page, char **start, off_t off, int count, int *eof, void *data) (char *page, char **start, off_t off, int count, int *eof, void *data)
{ {
...@@ -132,8 +144,7 @@ static int proc_ide_read_settings ...@@ -132,8 +144,7 @@ static int proc_ide_read_settings
char *out = page; char *out = page;
int len, rc, mul_factor, div_factor; int len, rc, mul_factor, div_factor;
printk(KERN_WARNING "Warning: /proc/ide/hd?/settings interface is " proc_ide_settings_warn();
"obsolete, and will be removed soon!\n");
down(&ide_setting_sem); down(&ide_setting_sem);
out += sprintf(out, "name\t\t\tvalue\t\tmin\t\tmax\t\tmode\n"); 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, ...@@ -171,12 +182,11 @@ static int proc_ide_write_settings(struct file *file, const char __user *buffer,
ide_settings_t *setting; ide_settings_t *setting;
char *buf, *s; 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)) if (!capable(CAP_SYS_ADMIN))
return -EACCES; return -EACCES;
proc_ide_settings_warn();
if (count >= PAGE_SIZE) if (count >= PAGE_SIZE)
return -EINVAL; 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