public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] MTRR driver: s/suser()/capable(CAP_SYS_ADMIN)/
@ 2001-04-03 11:23 Andrey Panin
  0 siblings, 0 replies; only message in thread
From: Andrey Panin @ 2001-04-03 11:23 UTC (permalink / raw)
  To: linux-kernel; +Cc: kernel-janitor-discuss


[-- Attachment #1.1: Type: text/plain, Size: 300 bytes --]

Hi all,

this patch (2.4.3) replaces suser() with capable(CAP_SYS_ADMIN) and adds missing
KERN_* constants in some printk() calls.

Best regards.

-- 
Andrey Panin            | Embedded systems software engineer
pazke@orbita1.ru        | PGP key: http://www.orbita1.ru/~pazke/AndreyPanin.asc

[-- Attachment #1.2: patch-mtrr-suser --]
[-- Type: text/plain, Size: 11500 bytes --]

diff -ur /linux.vanilla/arch/i386/kernel/mtrr.c /linux/arch/i386/kernel/mtrr.c
--- /linux.vanilla/arch/i386/kernel/mtrr.c	Mon Apr  2 15:46:39 2001
+++ /linux/arch/i386/kernel/mtrr.c	Tue Apr  3 21:43:03 2001
@@ -1010,12 +1010,12 @@
 {
     if (!mask) return;
     if (mask & MTRR_CHANGE_MASK_FIXED)
-	printk ("mtrr: your CPUs had inconsistent fixed MTRR settings\n");
+	printk (KERN_WARNING "mtrr: your CPUs had inconsistent fixed MTRR settings\n");
     if (mask & MTRR_CHANGE_MASK_VARIABLE)
-	printk ("mtrr: your CPUs had inconsistent variable MTRR settings\n");
+	printk (KERN_WARNING "mtrr: your CPUs had inconsistent variable MTRR settings\n");
     if (mask & MTRR_CHANGE_MASK_DEFTYPE)
-	printk ("mtrr: your CPUs had inconsistent MTRRdefType settings\n");
-    printk ("mtrr: probably your BIOS does not setup all CPUs\n");
+	printk (KERN_WARNING "mtrr: your CPUs had inconsistent MTRRdefType settings\n");
+    printk (KERN_WARNING "mtrr: probably your BIOS does not setup all CPUs\n");
 }   /*  End Function mtrr_state_warn  */
 
 #endif  /*  CONFIG_SMP  */
@@ -1224,7 +1224,7 @@
 
     if (type >= MTRR_NUM_TYPES)
     {
-	printk ("mtrr: type: %u illegal\n", type);
+	printk (KERN_WARNING "mtrr: type: %u illegal\n", type);
 	return -EINVAL;
     }
 
@@ -1237,7 +1237,7 @@
 
     if ( base & size_or_mask || size  & size_or_mask )
     {
-	printk ("mtrr: base or size exceeds the MTRR width\n");
+	printk (KERN_WARNING "mtrr: base or size exceeds the MTRR width\n");
 	return -EINVAL;
     }
 
@@ -1264,7 +1264,7 @@
 	{
 	    if (type == MTRR_TYPE_UNCACHABLE) continue;
 	    up(&main_lock);
-	    printk ( "mtrr: type mismatch for %lx000,%lx000 old: %s new: %s\n",
+	    printk (KERN_WARNING "mtrr: type mismatch for %lx000,%lx000 old: %s new: %s\n",
 		     base, size, attrib_to_str (ltype), attrib_to_str (type) );
 	    return -EINVAL;
 	}
@@ -1278,7 +1278,7 @@
     if (i < 0)
     {
 	up(&main_lock);
-	printk ("mtrr: no more MTRRs available\n");
+	printk (KERN_WARNING "mtrr: no more MTRRs available\n");
 	return i;
     }
     set_mtrr (i, base, size, type);
@@ -1338,8 +1338,8 @@
 
     if ( (base & (PAGE_SIZE - 1)) || (size & (PAGE_SIZE - 1)) )
     {
-	printk ("mtrr: size and base must be multiples of 4 kiB\n");
-	printk ("mtrr: size: 0x%lx  base: 0x%lx\n", size, base);
+	printk (KERN_ERR "mtrr: size and base must be multiples of 4 kiB\n");
+	printk (KERN_ERR "mtrr: size: 0x%lx  base: 0x%lx\n", size, base);
 	return -EINVAL;
     }
     return mtrr_add_page(base >> PAGE_SHIFT, size >> PAGE_SHIFT, type, increment);
@@ -1394,14 +1394,14 @@
 	if (reg < 0)
 	{
 	    up(&main_lock);
-	    printk ("mtrr: no MTRR for %lx000,%lx000 found\n", base, size);
+	    printk (KERN_ERR "mtrr: no MTRR for %lx000,%lx000 found\n", base, size);
 	    return -EINVAL;
 	}
     }
     if (reg >= max)
     {
 	up (&main_lock);
-	printk ("mtrr: register: %d too big\n", reg);
+	printk (KERN_ERR "mtrr: register: %d too big\n", reg);
 	return -EINVAL;
     }
     if ( mtrr_if == MTRR_IF_CYRIX_ARR )
@@ -1409,7 +1409,7 @@
 	if ( (reg == 3) && arr3_protected )
 	{
 	    up (&main_lock);
-	    printk ("mtrr: ARR3 cannot be changed\n");
+	    printk (KERN_ERR "mtrr: ARR3 cannot be changed\n");
 	    return -EINVAL;
 	}
     }
@@ -1417,13 +1417,13 @@
     if (lsize < 1)
     {
 	up (&main_lock);
-	printk ("mtrr: MTRR %d not used\n", reg);
+	printk (KERN_ERR "mtrr: MTRR %d not used\n", reg);
 	return -EINVAL;
     }
     if (usage_table[reg] < 1)
     {
 	up (&main_lock);
-	printk ("mtrr: reg: %d has count=0\n", reg);
+	printk (KERN_ERR "mtrr: reg: %d has count=0\n", reg);
 	return -EINVAL;
     }
     if (--usage_table[reg] < 1) set_mtrr (reg, 0, 0, 0);
@@ -1459,8 +1459,8 @@
 {
     if ( (base & (PAGE_SIZE - 1)) || (size & (PAGE_SIZE - 1)) )
     {
-	printk ("mtrr: size and base must be multiples of 4 kiB\n");
-	printk ("mtrr: size: 0x%lx  base: 0x%lx\n", size, base);
+	printk (KERN_ERR "mtrr: size and base must be multiples of 4 kiB\n");
+	printk (KERN_ERR "mtrr: size: 0x%lx  base: 0x%lx\n", size, base);
 	return -EINVAL;
     }
     return mtrr_del_page(reg, base >> PAGE_SHIFT, size >> PAGE_SHIFT);
@@ -1479,7 +1479,7 @@
     {
 	if ( ( fcount = kmalloc (max * sizeof *fcount, GFP_KERNEL) ) == NULL )
 	{
-	    printk ("mtrr: could not allocate\n");
+	    printk (KERN_ERR "mtrr: could not allocate\n");
 	    return -ENOMEM;
 	}
 	memset (fcount, 0, max * sizeof *fcount);
@@ -1488,8 +1488,8 @@
     if (!page) {
 	if ( (base & (PAGE_SIZE - 1)) || (size & (PAGE_SIZE - 1)) )
 	{
-	    printk ("mtrr: size and base must be multiples of 4 kiB\n");
-	    printk ("mtrr: size: 0x%lx  base: 0x%lx\n", size, base);
+	    printk (KERN_ERR "mtrr: size and base must be multiples of 4 kiB\n");
+	    printk (KERN_ERR "mtrr: size: 0x%lx  base: 0x%lx\n", size, base);
 	    return -EINVAL;
 	}
 	base >>= PAGE_SHIFT;
@@ -1509,8 +1509,8 @@
     if (!page) {
 	if ( (base & (PAGE_SIZE - 1)) || (size & (PAGE_SIZE - 1)) )
 	{
-	    printk ("mtrr: size and base must be multiples of 4 kiB\n");
-	    printk ("mtrr: size: 0x%lx  base: 0x%lx\n", size, base);
+	    printk (KERN_ERR "mtrr: size and base must be multiples of 4 kiB\n");
+	    printk (KERN_ERR "mtrr: size: 0x%lx  base: 0x%lx\n", size, base);
 	    return -EINVAL;
 	}
 	base >>= PAGE_SHIFT;
@@ -1547,7 +1547,7 @@
     char *ptr;
     char line[LINE_SIZE];
 
-    if ( !suser () ) return -EPERM;
+    if ( !capable(CAP_SYS_ADMIN) ) return -EPERM;
     /*  Can't seek (pwrite) on this device  */
     if (ppos != &file->f_pos) return -ESPIPE;
     memset (line, 0, LINE_SIZE);
@@ -1564,27 +1564,27 @@
     }
     if ( strncmp (line, "base=", 5) )
     {
-	printk ("mtrr: no \"base=\" in line: \"%s\"\n", line);
+	printk (KERN_ERR "mtrr: no \"base=\" in line: \"%s\"\n", line);
 	return -EINVAL;
     }
     base = simple_strtoull (line + 5, &ptr, 0);
     for (; isspace (*ptr); ++ptr);
     if ( strncmp (ptr, "size=", 5) )
     {
-	printk ("mtrr: no \"size=\" in line: \"%s\"\n", line);
+	printk (KERN_ERR "mtrr: no \"size=\" in line: \"%s\"\n", line);
 	return -EINVAL;
     }
     size = simple_strtoull (ptr + 5, &ptr, 0);
     if ( (base & 0xfff) || (size & 0xfff) )
     {
-	printk ("mtrr: size and base must be multiples of 4 kiB\n");
-	printk ("mtrr: size: 0x%Lx  base: 0x%Lx\n", size, base);
+	printk (KERN_ERR "mtrr: size and base must be multiples of 4 kiB\n");
+	printk (KERN_ERR "mtrr: size: 0x%Lx  base: 0x%Lx\n", size, base);
 	return -EINVAL;
     }
     for (; isspace (*ptr); ++ptr);
     if ( strncmp (ptr, "type=", 5) )
     {
-	printk ("mtrr: no \"type=\" in line: \"%s\"\n", line);
+	printk (KERN_ERR "mtrr: no \"type=\" in line: \"%s\"\n", line);
 	return -EINVAL;
     }
     ptr += 5;
@@ -1598,7 +1598,7 @@
 	if (err < 0) return err;
 	return len;
     }
-    printk ("mtrr: illegal type: \"%s\"\n", ptr);
+    printk (KERN_ERR "mtrr: illegal type: \"%s\"\n", ptr);
     return -EINVAL;
 }   /*  End Function mtrr_write  */
 
@@ -1615,28 +1615,28 @@
       default:
 	return -ENOIOCTLCMD;
       case MTRRIOC_ADD_ENTRY:
-	if ( !suser () ) return -EPERM;
+	if ( !capable(CAP_SYS_ADMIN) ) return -EPERM;
 	if ( copy_from_user (&sentry, (void *) arg, sizeof sentry) )
 	    return -EFAULT;
 	err = mtrr_file_add (sentry.base, sentry.size, sentry.type, 1, file, 0);
 	if (err < 0) return err;
 	break;
       case MTRRIOC_SET_ENTRY:
-	if ( !suser () ) return -EPERM;
+	if ( !capable(CAP_SYS_ADMIN) ) return -EPERM;
 	if ( copy_from_user (&sentry, (void *) arg, sizeof sentry) )
 	    return -EFAULT;
 	err = mtrr_add (sentry.base, sentry.size, sentry.type, 0);
 	if (err < 0) return err;
 	break;
       case MTRRIOC_DEL_ENTRY:
-	if ( !suser () ) return -EPERM;
+	if ( !capable(CAP_SYS_ADMIN) ) return -EPERM;
 	if ( copy_from_user (&sentry, (void *) arg, sizeof sentry) )
 	    return -EFAULT;
 	err = mtrr_file_del (sentry.base, sentry.size, file, 0);
 	if (err < 0) return err;
 	break;
       case MTRRIOC_KILL_ENTRY:
-	if ( !suser () ) return -EPERM;
+	if ( !capable(CAP_SYS_ADMIN) ) return -EPERM;
 	if ( copy_from_user (&sentry, (void *) arg, sizeof sentry) )
 	    return -EFAULT;
 	err = mtrr_del (-1, sentry.base, sentry.size);
@@ -1661,28 +1661,28 @@
 	     return -EFAULT;
 	break;
       case MTRRIOC_ADD_PAGE_ENTRY:
-	if ( !suser () ) return -EPERM;
+	if ( !capable(CAP_SYS_ADMIN) ) return -EPERM;
 	if ( copy_from_user (&sentry, (void *) arg, sizeof sentry) )
 	    return -EFAULT;
 	err = mtrr_file_add (sentry.base, sentry.size, sentry.type, 1, file, 1);
 	if (err < 0) return err;
 	break;
       case MTRRIOC_SET_PAGE_ENTRY:
-	if ( !suser () ) return -EPERM;
+	if ( !capable(CAP_SYS_ADMIN) ) return -EPERM;
 	if ( copy_from_user (&sentry, (void *) arg, sizeof sentry) )
 	    return -EFAULT;
 	err = mtrr_add_page (sentry.base, sentry.size, sentry.type, 0);
 	if (err < 0) return err;
 	break;
       case MTRRIOC_DEL_PAGE_ENTRY:
-	if ( !suser () ) return -EPERM;
+	if ( !capable(CAP_SYS_ADMIN) ) return -EPERM;
 	if ( copy_from_user (&sentry, (void *) arg, sizeof sentry) )
 	    return -EFAULT;
 	err = mtrr_file_del (sentry.base, sentry.size, file, 1);
 	if (err < 0) return err;
 	break;
       case MTRRIOC_KILL_PAGE_ENTRY:
-	if ( !suser () ) return -EPERM;
+	if ( !capable(CAP_SYS_ADMIN) ) return -EPERM;
 	if ( copy_from_user (&sentry, (void *) arg, sizeof sentry) )
 	    return -EFAULT;
 	err = mtrr_del_page (-1, sentry.base, sentry.size);
@@ -1714,7 +1714,7 @@
     {
 	while (fcount[i] > 0)
 	{
-	    if (mtrr_del (i, 0, 0) < 0) printk ("mtrr: reg %d not used\n", i);
+	    if (mtrr_del (i, 0, 0) < 0) printk (KERN_WARNING "mtrr: reg %d not used\n", i);
 	    --fcount[i];
 	}
     }
@@ -1896,14 +1896,14 @@
 
     set_mtrr_done (&ctxt); /* flush cache and disable MAPEN */
 
-    if ( ccrc[5] ) printk ("mtrr: ARR usage was not enabled, enabled manually\n");
-    if ( ccrc[3] ) printk ("mtrr: ARR3 cannot be changed\n");
+    if ( ccrc[5] ) printk (KERN_INFO "mtrr: ARR usage was not enabled, enabled manually\n");
+    if ( ccrc[3] ) printk (KERN_INFO "mtrr: ARR3 cannot be changed\n");
 /*
     if ( ccrc[1] & 0x80) printk ("mtrr: SMM memory access through ARR3 disabled\n");
     if ( ccrc[1] & 0x04) printk ("mtrr: SMM memory access disabled\n");
     if ( ccrc[1] & 0x02) printk ("mtrr: SMM mode disabled\n");
 */
-    if ( ccrc[6] ) printk ("mtrr: ARR3 was write protected, unprotected\n");
+    if ( ccrc[6] ) printk (KERN_INFO "mtrr: ARR3 was write protected, unprotected\n");
 }   /*  End Function cyrix_arr_init  */
 
 static void __init centaur_mcr_init(void)
@@ -1991,8 +1991,8 @@
 	mtrr_if = MTRR_IF_NONE;
     }
 
-    printk ("mtrr: v%s Richard Gooch (rgooch@atnf.csiro.au)\n"
-	    "mtrr: detected mtrr type: %s\n",
+    printk (KERN_INFO "mtrr: v%s Richard Gooch (rgooch@atnf.csiro.au)\n"
+	    KERN_INFO "mtrr: detected mtrr type: %s\n",
 	    MTRR_VERSION, mtrr_if_name[mtrr_if]);
 
     return (mtrr_if != MTRR_IF_NONE);
@@ -2051,7 +2051,7 @@
 	break;
     default:
 	/* I see no MTRRs I can support in SMP mode... */
-	printk ("mtrr: SMP support incomplete for this vendor\n");
+	printk (KERN_INFO "mtrr: SMP support incomplete for this vendor\n");
     }
 }   /*  End Function mtrr_init_secondary_cpu  */
 #endif  /*  CONFIG_SMP  */

[-- Attachment #2: Type: application/pgp-signature, Size: 232 bytes --]

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2001-04-03 11:25 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2001-04-03 11:23 [PATCH] MTRR driver: s/suser()/capable(CAP_SYS_ADMIN)/ Andrey Panin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox