mm: use octal not symbolic permissions
authorJoe Perches <joe@perches.com>
Thu, 14 Jun 2018 22:27:58 +0000 (15:27 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Thu, 14 Jun 2018 22:55:25 +0000 (07:55 +0900)
mm/*.c files use symbolic and octal styles for permissions.

Using octal and not symbolic permissions is preferred by many as more
readable.

https://lkml.org/lkml/2016/8/2/1945

Prefer the direct use of octal for permissions.

Done using
$ scripts/checkpatch.pl -f --types=SYMBOLIC_PERMS --fix-inplace mm/*.c
and some typing.

Before:  $ git grep -P -w "0[0-7]{3,3}" mm | wc -l
44
After:  $ git grep -P -w "0[0-7]{3,3}" mm | wc -l
86

Miscellanea:

o Whitespace neatening around these conversions.

Link: http://lkml.kernel.org/r/2e032ef111eebcd4c5952bae86763b541d373469.1522102887.git.joe@perches.com
Signed-off-by: Joe Perches <joe@perches.com>
Acked-by: David Rientjes <rientjes@google.com>
Acked-by: Michal Hocko <mhocko@suse.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
15 files changed:
mm/cleancache.c
mm/cma_debug.c
mm/compaction.c
mm/dmapool.c
mm/failslab.c
mm/frontswap.c
mm/memblock.c
mm/page_alloc.c
mm/page_idle.c
mm/page_owner.c
mm/shmem.c
mm/slab_common.c
mm/vmalloc.c
mm/zsmalloc.c
mm/zswap.c

index 126548b5a292bce68708be3b725dfa04465e5078..2bf12da9baa0666e6c772ede6ff63f4900106fe4 100644 (file)
@@ -307,12 +307,10 @@ static int __init init_cleancache(void)
        struct dentry *root = debugfs_create_dir("cleancache", NULL);
        if (root == NULL)
                return -ENXIO;
-       debugfs_create_u64("succ_gets", S_IRUGO, root, &cleancache_succ_gets);
-       debugfs_create_u64("failed_gets", S_IRUGO,
-                               root, &cleancache_failed_gets);
-       debugfs_create_u64("puts", S_IRUGO, root, &cleancache_puts);
-       debugfs_create_u64("invalidates", S_IRUGO,
-                               root, &cleancache_invalidates);
+       debugfs_create_u64("succ_gets", 0444, root, &cleancache_succ_gets);
+       debugfs_create_u64("failed_gets", 0444, root, &cleancache_failed_gets);
+       debugfs_create_u64("puts", 0444, root, &cleancache_puts);
+       debugfs_create_u64("invalidates", 0444, root, &cleancache_invalidates);
 #endif
        return 0;
 }
index 275df8b5b22e7bdb722e95774a1948d6c69fa4f8..f23467291cfb0bcb06ad736ee7dd34b5705ac989 100644 (file)
@@ -172,23 +172,18 @@ static void cma_debugfs_add_one(struct cma *cma, int idx)
 
        tmp = debugfs_create_dir(name, cma_debugfs_root);
 
-       debugfs_create_file("alloc", S_IWUSR, tmp, cma,
-                               &cma_alloc_fops);
-
-       debugfs_create_file("free", S_IWUSR, tmp, cma,
-                               &cma_free_fops);
-
-       debugfs_create_file("base_pfn", S_IRUGO, tmp,
-                               &cma->base_pfn, &cma_debugfs_fops);
-       debugfs_create_file("count", S_IRUGO, tmp,
-                               &cma->count, &cma_debugfs_fops);
-       debugfs_create_file("order_per_bit", S_IRUGO, tmp,
-                               &cma->order_per_bit, &cma_debugfs_fops);
-       debugfs_create_file("used", S_IRUGO, tmp, cma, &cma_used_fops);
-       debugfs_create_file("maxchunk", S_IRUGO, tmp, cma, &cma_maxchunk_fops);
+       debugfs_create_file("alloc", 0200, tmp, cma, &cma_alloc_fops);
+       debugfs_create_file("free", 0200, tmp, cma, &cma_free_fops);
+       debugfs_create_file("base_pfn", 0444, tmp,
+                           &cma->base_pfn, &cma_debugfs_fops);
+       debugfs_create_file("count", 0444, tmp, &cma->count, &cma_debugfs_fops);
+       debugfs_create_file("order_per_bit", 0444, tmp,
+                           &cma->order_per_bit, &cma_debugfs_fops);
+       debugfs_create_file("used", 0444, tmp, cma, &cma_used_fops);
+       debugfs_create_file("maxchunk", 0444, tmp, cma, &cma_maxchunk_fops);
 
        u32s = DIV_ROUND_UP(cma_bitmap_maxno(cma), BITS_PER_BYTE * sizeof(u32));
-       debugfs_create_u32_array("bitmap", S_IRUGO, tmp, (u32*)cma->bitmap, u32s);
+       debugfs_create_u32_array("bitmap", 0444, tmp, (u32 *)cma->bitmap, u32s);
 }
 
 static int __init cma_debugfs_init(void)
index 29bd1df18b98aff1d4a2a59c9253d5734c32bb20..faca45ebe62dfbb58099661158334ab9ce0155f8 100644 (file)
@@ -1899,7 +1899,7 @@ static ssize_t sysfs_compact_node(struct device *dev,
 
        return count;
 }
-static DEVICE_ATTR(compact, S_IWUSR, NULL, sysfs_compact_node);
+static DEVICE_ATTR(compact, 0200, NULL, sysfs_compact_node);
 
 int compaction_register_node(struct node *node)
 {
index 4d90a64b2fdc8d50af4ef60278901a5b089b5735..6d4b97e7e9e97752413caef09df772ece3d6f45c 100644 (file)
@@ -105,7 +105,7 @@ show_pools(struct device *dev, struct device_attribute *attr, char *buf)
        return PAGE_SIZE - size;
 }
 
-static DEVICE_ATTR(pools, S_IRUGO, show_pools, NULL);
+static DEVICE_ATTR(pools, 0444, show_pools, NULL);
 
 /**
  * dma_pool_create - Creates a pool of consistent memory blocks, for dma.
index 1f2f248e36019121bad626a9a81403b5b5316b1d..b135ebb88b6f729e145430999591beb3db2371d2 100644 (file)
@@ -42,7 +42,7 @@ __setup("failslab=", setup_failslab);
 static int __init failslab_debugfs_init(void)
 {
        struct dentry *dir;
-       umode_t mode = S_IFREG | S_IRUSR | S_IWUSR;
+       umode_t mode = S_IFREG | 0600;
 
        dir = fault_create_debugfs_attr("failslab", NULL, &failslab.attr);
        if (IS_ERR(dir))
index 4f5476a0f95535a1c687b898b96373b7fc1c040e..157e5bf63504258e3d1be341854627d47d4b96d0 100644 (file)
@@ -486,12 +486,11 @@ static int __init init_frontswap(void)
        struct dentry *root = debugfs_create_dir("frontswap", NULL);
        if (root == NULL)
                return -ENXIO;
-       debugfs_create_u64("loads", S_IRUGO, root, &frontswap_loads);
-       debugfs_create_u64("succ_stores", S_IRUGO, root, &frontswap_succ_stores);
-       debugfs_create_u64("failed_stores", S_IRUGO, root,
-                               &frontswap_failed_stores);
-       debugfs_create_u64("invalidates", S_IRUGO,
-                               root, &frontswap_invalidates);
+       debugfs_create_u64("loads", 0444, root, &frontswap_loads);
+       debugfs_create_u64("succ_stores", 0444, root, &frontswap_succ_stores);
+       debugfs_create_u64("failed_stores", 0444, root,
+                          &frontswap_failed_stores);
+       debugfs_create_u64("invalidates", 0444, root, &frontswap_invalidates);
 #endif
        return 0;
 }
index f1dba2826d0fc7c09128c4d3e405d793d3d3122b..cc16d70b8333890730d16c08b858631947e38d70 100644 (file)
@@ -1809,10 +1809,13 @@ static int __init memblock_init_debugfs(void)
        struct dentry *root = debugfs_create_dir("memblock", NULL);
        if (!root)
                return -ENXIO;
-       debugfs_create_file("memory", S_IRUGO, root, &memblock.memory, &memblock_debug_fops);
-       debugfs_create_file("reserved", S_IRUGO, root, &memblock.reserved, &memblock_debug_fops);
+       debugfs_create_file("memory", 0444, root,
+                           &memblock.memory, &memblock_debug_fops);
+       debugfs_create_file("reserved", 0444, root,
+                           &memblock.reserved, &memblock_debug_fops);
 #ifdef CONFIG_HAVE_MEMBLOCK_PHYS_MAP
-       debugfs_create_file("physmem", S_IRUGO, root, &memblock.physmem, &memblock_debug_fops);
+       debugfs_create_file("physmem", 0444, root,
+                           &memblock.physmem, &memblock_debug_fops);
 #endif
 
        return 0;
index 07b3c23762adbbc441ba7fb9e1f39c2c694d85c1..1521100f1e63b729bba37e21723a312950d688d8 100644 (file)
@@ -3061,7 +3061,7 @@ static bool should_fail_alloc_page(gfp_t gfp_mask, unsigned int order)
 
 static int __init fail_page_alloc_debugfs(void)
 {
-       umode_t mode = S_IFREG | S_IRUSR | S_IWUSR;
+       umode_t mode = S_IFREG | 0600;
        struct dentry *dir;
 
        dir = fault_create_debugfs_attr("fail_page_alloc", NULL,
index e412a63b2b74f7820298751e1cf382fe90c48005..6302bc62c27d6b69939ab2791c57a5da8945e8aa 100644 (file)
@@ -201,7 +201,7 @@ static ssize_t page_idle_bitmap_write(struct file *file, struct kobject *kobj,
 }
 
 static struct bin_attribute page_idle_bitmap_attr =
-               __BIN_ATTR(bitmap, S_IRUSR | S_IWUSR,
+               __BIN_ATTR(bitmap, 0600,
                           page_idle_bitmap_read, page_idle_bitmap_write, 0);
 
 static struct bin_attribute *page_idle_bin_attrs[] = {
index 75d21a2259b3b1ff9d2ac624fc9fbab10100580d..d80adfe702d3b85f754589135f3695b4e3394c72 100644 (file)
@@ -631,8 +631,8 @@ static int __init pageowner_init(void)
                return 0;
        }
 
-       dentry = debugfs_create_file("page_owner", S_IRUSR, NULL,
-                       NULL, &proc_page_owner_operations);
+       dentry = debugfs_create_file("page_owner", 0400, NULL,
+                                    NULL, &proc_page_owner_operations);
 
        return PTR_ERR_OR_ZERO(dentry);
 }
index e9a7ac74823de13b912c2896f3254e762d17a172..2cab8440305531f8ab97f3a56c95b91516bcd2ea 100644 (file)
@@ -3013,7 +3013,8 @@ static int shmem_symlink(struct inode *dir, struct dentry *dentry, const char *s
        if (len > PAGE_SIZE)
                return -ENAMETOOLONG;
 
-       inode = shmem_get_inode(dir->i_sb, dir, S_IFLNK|S_IRWXUGO, 0, VM_NORESERVE);
+       inode = shmem_get_inode(dir->i_sb, dir, S_IFLNK | 0777, 0,
+                               VM_NORESERVE);
        if (!inode)
                return -ENOSPC;
 
@@ -3445,7 +3446,7 @@ static int shmem_show_options(struct seq_file *seq, struct dentry *root)
                        sbinfo->max_blocks << (PAGE_SHIFT - 10));
        if (sbinfo->max_inodes != shmem_default_max_inodes())
                seq_printf(seq, ",nr_inodes=%lu", sbinfo->max_inodes);
-       if (sbinfo->mode != (S_IRWXUGO | S_ISVTX))
+       if (sbinfo->mode != (0777 | S_ISVTX))
                seq_printf(seq, ",mode=%03ho", sbinfo->mode);
        if (!uid_eq(sbinfo->uid, GLOBAL_ROOT_UID))
                seq_printf(seq, ",uid=%u",
@@ -3486,7 +3487,7 @@ int shmem_fill_super(struct super_block *sb, void *data, int silent)
        if (!sbinfo)
                return -ENOMEM;
 
-       sbinfo->mode = S_IRWXUGO | S_ISVTX;
+       sbinfo->mode = 0777 | S_ISVTX;
        sbinfo->uid = current_fsuid();
        sbinfo->gid = current_fsgid();
        sb->s_fs_info = sbinfo;
@@ -3929,7 +3930,7 @@ static struct file *__shmem_file_setup(struct vfsmount *mnt, const char *name, l
        d_set_d_op(path.dentry, &anon_ops);
 
        res = ERR_PTR(-ENOSPC);
-       inode = shmem_get_inode(sb, NULL, S_IFREG | S_IRWXUGO, 0, flags);
+       inode = shmem_get_inode(sb, NULL, S_IFREG | 0777, 0, flags);
        if (!inode)
                goto put_memory;
 
index 42aca26d61d01c67d0ba381fd08f2c11fce6af4a..890b1f04a03a3d46f80fe1b2cfccae1f14b79836 100644 (file)
@@ -1243,9 +1243,9 @@ void cache_random_seq_destroy(struct kmem_cache *cachep)
 
 #if defined(CONFIG_SLAB) || defined(CONFIG_SLUB_DEBUG)
 #ifdef CONFIG_SLAB
-#define SLABINFO_RIGHTS (S_IWUSR | S_IRUSR)
+#define SLABINFO_RIGHTS (0600)
 #else
-#define SLABINFO_RIGHTS S_IRUSR
+#define SLABINFO_RIGHTS (0400)
 #endif
 
 static void print_slabinfo_header(struct seq_file *m)
index 89efac3a020e5bb47cc0fcbfb83c0fb114c0498f..cfea25be77548cfad6ffc5d4c4d3f60445804f52 100644 (file)
@@ -2741,11 +2741,11 @@ static const struct seq_operations vmalloc_op = {
 static int __init proc_vmalloc_init(void)
 {
        if (IS_ENABLED(CONFIG_NUMA))
-               proc_create_seq_private("vmallocinfo", S_IRUSR, NULL,
+               proc_create_seq_private("vmallocinfo", 0400, NULL,
                                &vmalloc_op,
                                nr_node_ids * sizeof(unsigned int), NULL);
        else
-               proc_create_seq("vmallocinfo", S_IRUSR, NULL, &vmalloc_op);
+               proc_create_seq("vmallocinfo", 0400, NULL, &vmalloc_op);
        return 0;
 }
 module_init(proc_vmalloc_init);
index 61cb05dc950caf394dbf375b5b7084a193cbaddb..8d87e973a4f509955e3c0974ed3a2e808cbd0688 100644 (file)
@@ -661,8 +661,9 @@ static void zs_pool_stat_create(struct zs_pool *pool, const char *name)
        }
        pool->stat_dentry = entry;
 
-       entry = debugfs_create_file("classes", S_IFREG | S_IRUGO,
-                       pool->stat_dentry, pool, &zs_stats_size_fops);
+       entry = debugfs_create_file("classes", S_IFREG | 0444,
+                                   pool->stat_dentry, pool,
+                                   &zs_stats_size_fops);
        if (!entry) {
                pr_warn("%s: debugfs file entry <%s> creation failed\n",
                                name, "classes");
index 61a5c41972dba22bc35179a13d40e900dea679b6..7d34e69507e305adec0a64b5e272626385f9d651 100644 (file)
@@ -1256,26 +1256,26 @@ static int __init zswap_debugfs_init(void)
        if (!zswap_debugfs_root)
                return -ENOMEM;
 
-       debugfs_create_u64("pool_limit_hit", S_IRUGO,
-                       zswap_debugfs_root, &zswap_pool_limit_hit);
-       debugfs_create_u64("reject_reclaim_fail", S_IRUGO,
-                       zswap_debugfs_root, &zswap_reject_reclaim_fail);
-       debugfs_create_u64("reject_alloc_fail", S_IRUGO,
-                       zswap_debugfs_root, &zswap_reject_alloc_fail);
-       debugfs_create_u64("reject_kmemcache_fail", S_IRUGO,
-                       zswap_debugfs_root, &zswap_reject_kmemcache_fail);
-       debugfs_create_u64("reject_compress_poor", S_IRUGO,
-                       zswap_debugfs_root, &zswap_reject_compress_poor);
-       debugfs_create_u64("written_back_pages", S_IRUGO,
-                       zswap_debugfs_root, &zswap_written_back_pages);
-       debugfs_create_u64("duplicate_entry", S_IRUGO,
-                       zswap_debugfs_root, &zswap_duplicate_entry);
-       debugfs_create_u64("pool_total_size", S_IRUGO,
-                       zswap_debugfs_root, &zswap_pool_total_size);
-       debugfs_create_atomic_t("stored_pages", S_IRUGO,
-                       zswap_debugfs_root, &zswap_stored_pages);
+       debugfs_create_u64("pool_limit_hit", 0444,
+                          zswap_debugfs_root, &zswap_pool_limit_hit);
+       debugfs_create_u64("reject_reclaim_fail", 0444,
+                          zswap_debugfs_root, &zswap_reject_reclaim_fail);
+       debugfs_create_u64("reject_alloc_fail", 0444,
+                          zswap_debugfs_root, &zswap_reject_alloc_fail);
+       debugfs_create_u64("reject_kmemcache_fail", 0444,
+                          zswap_debugfs_root, &zswap_reject_kmemcache_fail);
+       debugfs_create_u64("reject_compress_poor", 0444,
+                          zswap_debugfs_root, &zswap_reject_compress_poor);
+       debugfs_create_u64("written_back_pages", 0444,
+                          zswap_debugfs_root, &zswap_written_back_pages);
+       debugfs_create_u64("duplicate_entry", 0444,
+                          zswap_debugfs_root, &zswap_duplicate_entry);
+       debugfs_create_u64("pool_total_size", 0444,
+                          zswap_debugfs_root, &zswap_pool_total_size);
+       debugfs_create_atomic_t("stored_pages", 0444,
+                               zswap_debugfs_root, &zswap_stored_pages);
        debugfs_create_atomic_t("same_filled_pages", 0444,
-                       zswap_debugfs_root, &zswap_same_filled_pages);
+                               zswap_debugfs_root, &zswap_same_filled_pages);
 
        return 0;
 }