Skip to content
Snippets Groups Projects
Select Git revision
  • b24c30c678630e48cf8e3caefe463e1c6144d029
  • vme-testing default
  • ci-test
  • master
  • remoteproc
  • am625-sk-ov5640
  • pcal6534-upstreaming
  • lps22df-upstreaming
  • msc-upstreaming
  • imx8mp
  • iio/noa1305
  • vme-next
  • vme-next-4.14-rc4
  • v4.14-rc4
  • v4.14-rc3
  • v4.14-rc2
  • v4.14-rc1
  • v4.13
  • vme-next-4.13-rc7
  • v4.13-rc7
  • v4.13-rc6
  • v4.13-rc5
  • v4.13-rc4
  • v4.13-rc3
  • v4.13-rc2
  • v4.13-rc1
  • v4.12
  • v4.12-rc7
  • v4.12-rc6
  • v4.12-rc5
  • v4.12-rc4
  • v4.12-rc3
32 results

generic.c

Blame
  • generic.c 18.38 KiB
    // SPDX-License-Identifier: GPL-2.0-only
    /*
     * proc/fs/generic.c --- generic routines for the proc-fs
     *
     * This file contains generic proc-fs routines for handling
     * directories and files.
     * 
     * Copyright (C) 1991, 1992 Linus Torvalds.
     * Copyright (C) 1997 Theodore Ts'o
     */
    
    #include <linux/cache.h>
    #include <linux/errno.h>
    #include <linux/time.h>
    #include <linux/proc_fs.h>
    #include <linux/stat.h>
    #include <linux/mm.h>
    #include <linux/module.h>
    #include <linux/namei.h>
    #include <linux/slab.h>
    #include <linux/printk.h>
    #include <linux/mount.h>
    #include <linux/init.h>
    #include <linux/idr.h>
    #include <linux/bitops.h>
    #include <linux/spinlock.h>
    #include <linux/completion.h>
    #include <linux/uaccess.h>
    #include <linux/seq_file.h>
    
    #include "internal.h"
    
    static DEFINE_RWLOCK(proc_subdir_lock);
    
    struct kmem_cache *proc_dir_entry_cache __ro_after_init;
    
    void pde_free(struct proc_dir_entry *pde)
    {
    	if (S_ISLNK(pde->mode))
    		kfree(pde->data);
    	if (pde->name != pde->inline_name)
    		kfree(pde->name);
    	kmem_cache_free(proc_dir_entry_cache, pde);
    }
    
    static int proc_match(const char *name, struct proc_dir_entry *de, unsigned int len)
    {
    	if (len < de->namelen)
    		return -1;
    	if (len > de->namelen)
    		return 1;
    
    	return memcmp(name, de->name, len);
    }
    
    static struct proc_dir_entry *pde_subdir_first(struct proc_dir_entry *dir)
    {
    	return rb_entry_safe(rb_first(&dir->subdir), struct proc_dir_entry,
    			     subdir_node);
    }
    
    static struct proc_dir_entry *pde_subdir_next(struct proc_dir_entry *dir)
    {
    	return rb_entry_safe(rb_next(&dir->subdir_node), struct proc_dir_entry,
    			     subdir_node);
    }
    
    static struct proc_dir_entry *pde_subdir_find(struct proc_dir_entry *dir,
    					      const char *name,
    					      unsigned int len)