Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Macros | Functions | Variables
namei.c File Reference
#include <linux/init.h>
#include <linux/export.h>
#include <linux/kernel.h>
#include <linux/slab.h>
#include <linux/fs.h>
#include <linux/namei.h>
#include <linux/pagemap.h>
#include <linux/fsnotify.h>
#include <linux/personality.h>
#include <linux/security.h>
#include <linux/ima.h>
#include <linux/syscalls.h>
#include <linux/mount.h>
#include <linux/audit.h>
#include <linux/capability.h>
#include <linux/file.h>
#include <linux/fcntl.h>
#include <linux/device_cgroup.h>
#include <linux/fs_struct.h>
#include <linux/posix_acl.h>
#include <asm/uaccess.h>
#include "internal.h"
#include "mount.h"

Go to the source code of this file.

Macros

#define EMBEDDED_NAME_MAX   (PATH_MAX - sizeof(struct filename))
 

Functions

void final_putname (struct filename *name)
 
struct filenamegetname (const char __user *filename)
 
 EXPORT_SYMBOL (getname)
 
int generic_permission (struct inode *inode, int mask)
 
int __inode_permission (struct inode *inode, int mask)
 
int inode_permission (struct inode *inode, int mask)
 
void path_get (struct path *path)
 
 EXPORT_SYMBOL (path_get)
 
void path_put (struct path *path)
 
 EXPORT_SYMBOL (path_put)
 
void nd_jump_link (struct nameidata *nd, struct path *path)
 
int follow_up (struct path *path)
 
int follow_down_one (struct path *path)
 
int follow_down (struct path *path)
 
unsigned int full_name_hash (const unsigned char *name, unsigned int len)
 
 EXPORT_SYMBOL (full_name_hash)
 
struct dentrykern_path_locked (const char *name, struct path *path)
 
int kern_path (const char *name, unsigned int flags, struct path *path)
 
: pointer to file name

vfs_path_lookup - lookup a file path relative to a dentry-vfsmount pair : pointer to dentry of the base directory : pointer to vfs mount of the base directory

: lookup flags : pointer to struct path to fill

int vfs_path_lookup (struct dentry *dentry, struct vfsmount *mnt, const char *name, unsigned int flags, struct path *path)
 

Variables

int sysctl_protected_symlinks __read_mostly = 0
 

: pathname component to lookup

lookup_one_len - filesystem helper to lookup single pathname component

: base directory to lookup from : maximum length should be interpreted to

Note that this routine is purely a helper for filesystem usage and should not be called by generic code. Also note that by using this function the nameidata argument is passed to the filesystem methods and a filesystem using this helper needs to be prepared for that.

struct inode_operations page_symlink_inode_operations
 
struct dentrylookup_one_len (const char *name, struct dentry *base, int len)
 
int user_path_at_empty (int dfd, const char __user *name, unsigned flags, struct path *path, int *empty)
 
int user_path_at (int dfd, const char __user *name, unsigned flags, struct path *path)
 
struct dentrylock_rename (struct dentry *p1, struct dentry *p2)
 
void unlock_rename (struct dentry *p1, struct dentry *p2)
 
int vfs_create (struct inode *dir, struct dentry *dentry, umode_t mode, bool want_excl)
 
struct filedo_filp_open (int dfd, struct filename *pathname, const struct open_flags *op, int flags)
 
struct filedo_file_open_root (struct dentry *dentry, struct vfsmount *mnt, const char *name, const struct open_flags *op, int flags)
 
struct dentrykern_path_create (int dfd, const char *pathname, struct path *path, int is_dir)
 
 EXPORT_SYMBOL (kern_path_create)
 
void done_path_create (struct path *path, struct dentry *dentry)
 
 EXPORT_SYMBOL (done_path_create)
 
struct dentryuser_path_create (int dfd, const char __user *pathname, struct path *path, int is_dir)
 
 EXPORT_SYMBOL (user_path_create)
 
int vfs_mknod (struct inode *dir, struct dentry *dentry, umode_t mode, dev_t dev)
 
 SYSCALL_DEFINE4 (mknodat, int, dfd, const char __user *, filename, umode_t, mode, unsigned, dev)
 
 SYSCALL_DEFINE3 (mknod, const char __user *, filename, umode_t, mode, unsigned, dev)
 
int vfs_mkdir (struct inode *dir, struct dentry *dentry, umode_t mode)
 
 SYSCALL_DEFINE3 (mkdirat, int, dfd, const char __user *, pathname, umode_t, mode)
 
 SYSCALL_DEFINE2 (mkdir, const char __user *, pathname, umode_t, mode)
 
void dentry_unhash (struct dentry *dentry)
 
int vfs_rmdir (struct inode *dir, struct dentry *dentry)
 
 SYSCALL_DEFINE1 (rmdir, const char __user *, pathname)
 
int vfs_unlink (struct inode *dir, struct dentry *dentry)
 
 SYSCALL_DEFINE3 (unlinkat, int, dfd, const char __user *, pathname, int, flag)
 
 SYSCALL_DEFINE1 (unlink, const char __user *, pathname)
 
int vfs_symlink (struct inode *dir, struct dentry *dentry, const char *oldname)
 
 SYSCALL_DEFINE3 (symlinkat, const char __user *, oldname, int, newdfd, const char __user *, newname)
 
 SYSCALL_DEFINE2 (symlink, const char __user *, oldname, const char __user *, newname)
 
int vfs_link (struct dentry *old_dentry, struct inode *dir, struct dentry *new_dentry)
 
 SYSCALL_DEFINE5 (linkat, int, olddfd, const char __user *, oldname, int, newdfd, const char __user *, newname, int, flags)
 
 SYSCALL_DEFINE2 (link, const char __user *, oldname, const char __user *, newname)
 
int vfs_rename (struct inode *old_dir, struct dentry *old_dentry, struct inode *new_dir, struct dentry *new_dentry)
 
 SYSCALL_DEFINE4 (renameat, int, olddfd, const char __user *, oldname, int, newdfd, const char __user *, newname)
 
 SYSCALL_DEFINE2 (rename, const char __user *, oldname, const char __user *, newname)
 
int vfs_readlink (struct dentry *dentry, char __user *buffer, int buflen, const char *link)
 
int generic_readlink (struct dentry *dentry, char __user *buffer, int buflen)
 
int vfs_follow_link (struct nameidata *nd, const char *link)
 
int page_readlink (struct dentry *dentry, char __user *buffer, int buflen)
 
voidpage_follow_link_light (struct dentry *dentry, struct nameidata *nd)
 
void page_put_link (struct dentry *dentry, struct nameidata *nd, void *cookie)
 
int __page_symlink (struct inode *inode, const char *symname, int len, int nofs)
 
int page_symlink (struct inode *inode, const char *symname, int len)
 
 EXPORT_SYMBOL (user_path_at)
 
 EXPORT_SYMBOL (follow_down_one)
 
 EXPORT_SYMBOL (follow_down)
 
 EXPORT_SYMBOL (follow_up)
 
 EXPORT_SYMBOL (get_write_access)
 
 EXPORT_SYMBOL (lock_rename)
 
 EXPORT_SYMBOL (lookup_one_len)
 
 EXPORT_SYMBOL (page_follow_link_light)
 
 EXPORT_SYMBOL (page_put_link)
 
 EXPORT_SYMBOL (page_readlink)
 
 EXPORT_SYMBOL (__page_symlink)
 
 EXPORT_SYMBOL (page_symlink)
 
 EXPORT_SYMBOL (page_symlink_inode_operations)
 
 EXPORT_SYMBOL (kern_path)
 
 EXPORT_SYMBOL (vfs_path_lookup)
 
 EXPORT_SYMBOL (inode_permission)
 
 EXPORT_SYMBOL (unlock_rename)
 
 EXPORT_SYMBOL (vfs_create)
 
 EXPORT_SYMBOL (vfs_follow_link)
 
 EXPORT_SYMBOL (vfs_link)
 
 EXPORT_SYMBOL (vfs_mkdir)
 
 EXPORT_SYMBOL (vfs_mknod)
 
 EXPORT_SYMBOL (generic_permission)
 
 EXPORT_SYMBOL (vfs_readlink)
 
 EXPORT_SYMBOL (vfs_rename)
 
 EXPORT_SYMBOL (vfs_rmdir)
 
 EXPORT_SYMBOL (vfs_symlink)
 
 EXPORT_SYMBOL (vfs_unlink)
 
 EXPORT_SYMBOL (dentry_unhash)
 
 EXPORT_SYMBOL (generic_readlink)
 

Macro Definition Documentation

#define EMBEDDED_NAME_MAX   (PATH_MAX - sizeof(struct filename))

Definition at line 130 of file namei.c.

Function Documentation

int __inode_permission ( struct inode inode,
int  mask 
)

__inode_permission - Check for access rights to a given inode : Inode to check permission on : Right to check for (MAY_READ, MAY_WRITE, MAY_EXEC)

Check for read/write/execute permissions on an inode.

When checking for MAY_APPEND, MAY_WRITE must also be set in .

This does not check for a read-only file system. You probably want inode_permission().

Definition at line 383 of file namei.c.

int __page_symlink ( struct inode inode,
const char symname,
int  len,
int  nofs 
)

Definition at line 3995 of file namei.c.

void dentry_unhash ( struct dentry dentry)

Definition at line 3278 of file namei.c.

struct file* do_file_open_root ( struct dentry dentry,
struct vfsmount mnt,
const char name,
const struct open_flags op,
int  flags 
)
read

Definition at line 3024 of file namei.c.

struct file* do_filp_open ( int  dfd,
struct filename pathname,
const struct open_flags op,
int  flags 
)
read

Definition at line 3010 of file namei.c.

void done_path_create ( struct path path,
struct dentry dentry 
)

Definition at line 3107 of file namei.c.

EXPORT_SYMBOL ( getname  )
EXPORT_SYMBOL ( path_get  )
EXPORT_SYMBOL ( path_put  )
EXPORT_SYMBOL ( full_name_hash  )
EXPORT_SYMBOL ( kern_path_create  )
EXPORT_SYMBOL ( done_path_create  )
EXPORT_SYMBOL ( user_path_create  )
EXPORT_SYMBOL ( user_path_at  )
EXPORT_SYMBOL ( follow_down_one  )
EXPORT_SYMBOL ( follow_down  )
EXPORT_SYMBOL ( follow_up  )
EXPORT_SYMBOL ( get_write_access  )
EXPORT_SYMBOL ( lock_rename  )
EXPORT_SYMBOL ( lookup_one_len  )
EXPORT_SYMBOL ( page_follow_link_light  )
EXPORT_SYMBOL ( page_put_link  )
EXPORT_SYMBOL ( page_readlink  )
EXPORT_SYMBOL ( __page_symlink  )
EXPORT_SYMBOL ( page_symlink  )
EXPORT_SYMBOL ( page_symlink_inode_operations  )
EXPORT_SYMBOL ( kern_path  )
EXPORT_SYMBOL ( vfs_path_lookup  )
EXPORT_SYMBOL ( inode_permission  )
EXPORT_SYMBOL ( unlock_rename  )
EXPORT_SYMBOL ( vfs_create  )
EXPORT_SYMBOL ( vfs_follow_link  )
EXPORT_SYMBOL ( vfs_link  )
EXPORT_SYMBOL ( vfs_mkdir  )
EXPORT_SYMBOL ( vfs_mknod  )
EXPORT_SYMBOL ( generic_permission  )
EXPORT_SYMBOL ( vfs_readlink  )
EXPORT_SYMBOL ( vfs_rename  )
EXPORT_SYMBOL ( vfs_rmdir  )
EXPORT_SYMBOL ( vfs_symlink  )
EXPORT_SYMBOL ( vfs_unlink  )
EXPORT_SYMBOL ( dentry_unhash  )
EXPORT_SYMBOL ( generic_readlink  )
void final_putname ( struct filename name)

Definition at line 120 of file namei.c.

int follow_down ( struct path path)

Definition at line 1178 of file namei.c.

int follow_down_one ( struct path path)

Definition at line 1066 of file namei.c.

int follow_up ( struct path path)

Definition at line 898 of file namei.c.

unsigned int full_name_hash ( const unsigned char name,
unsigned int  len 
)

Definition at line 1730 of file namei.c.

int generic_permission ( struct inode inode,
int  mask 
)

generic_permission - check for access rights on a Posix-like filesystem : inode to check access rights for : right to check for (MAY_READ, MAY_WRITE, MAY_EXEC, ...)

Used to check for read/write/execute permissions on a file. We use "fsuid" for this, letting us set arbitrary permissions for filesystem access without changing the "normal" uids which are used for other things.

generic_permission is rcu-walk aware. It returns -ECHILD in case an rcu-walk request cannot be satisfied (eg. requires blocking or too much complexity). It would then be called again in ref-walk mode.

Definition at line 311 of file namei.c.

int generic_readlink ( struct dentry dentry,
char __user buffer,
int  buflen 
)

Definition at line 3926 of file namei.c.

struct filename* getname ( const char __user filename)
read

Definition at line 208 of file namei.c.

int inode_permission ( struct inode inode,
int  mask 
)

inode_permission - Check for access rights to a given inode : Inode to check permission on : Right to check for (MAY_READ, MAY_WRITE, MAY_EXEC)

Check for read/write/execute permissions on an inode. We use fs[ug]id for this, letting us set arbitrary permissions for filesystem access without changing the "normal" UIDs which are used for other things.

When checking for MAY_APPEND, MAY_WRITE must also be set in .

Definition at line 438 of file namei.c.

int kern_path ( const char name,
unsigned int  flags,
struct path path 
)

Definition at line 2066 of file namei.c.

struct dentry* kern_path_create ( int  dfd,
const char pathname,
struct path path,
int  is_dir 
)
read

Definition at line 3047 of file namei.c.

struct dentry* kern_path_locked ( const char name,
struct path path 
)
read

Definition at line 2044 of file namei.c.

struct dentry* lock_rename ( struct dentry p1,
struct dentry p2 
)
read

Definition at line 2297 of file namei.c.

struct dentry* lookup_one_len ( const char name,
struct dentry base,
int  len 
)
read

Definition at line 2120 of file namei.c.

void nd_jump_link ( struct nameidata nd,
struct path path 
)

Definition at line 689 of file namei.c.

void* page_follow_link_light ( struct dentry dentry,
struct nameidata nd 
)

Definition at line 3975 of file namei.c.

void page_put_link ( struct dentry dentry,
struct nameidata nd,
void cookie 
)

Definition at line 3982 of file namei.c.

int page_readlink ( struct dentry dentry,
char __user buffer,
int  buflen 
)

Definition at line 3963 of file namei.c.

int page_symlink ( struct inode inode,
const char symname,
int  len 
)

Definition at line 4029 of file namei.c.

void path_get ( struct path path)

path_get - get a reference to a path : path to get the reference to

Given a path increment the reference count to the dentry and the vfsmount.

Definition at line 454 of file namei.c.

void path_put ( struct path path)

path_put - put a reference to a path : path to put the reference to

Given a path decrement the reference count to the dentry and the vfsmount.

Definition at line 467 of file namei.c.

SYSCALL_DEFINE1 ( rmdir  ,
const char __user ,
pathname   
)

Definition at line 3376 of file namei.c.

SYSCALL_DEFINE1 ( unlink  ,
const char __user ,
pathname   
)

Definition at line 3484 of file namei.c.

SYSCALL_DEFINE2 ( mkdir  ,
const char __user ,
pathname  ,
umode_t  ,
mode   
)

Definition at line 3258 of file namei.c.

SYSCALL_DEFINE2 ( symlink  ,
const char __user ,
oldname  ,
const char __user ,
newname   
)

Definition at line 3535 of file namei.c.

SYSCALL_DEFINE2 ( link  ,
const char __user ,
oldname  ,
const char __user ,
newname   
)

Definition at line 3644 of file namei.c.

SYSCALL_DEFINE2 ( rename  ,
const char __user ,
oldname  ,
const char __user ,
newname   
)

Definition at line 3899 of file namei.c.

SYSCALL_DEFINE3 ( mknod  ,
const char __user ,
filename  ,
umode_t  ,
mode  ,
unsigned  ,
dev   
)

Definition at line 3209 of file namei.c.

SYSCALL_DEFINE3 ( mkdirat  ,
int  ,
dfd  ,
const char __user ,
pathname  ,
umode_t  ,
mode   
)

Definition at line 3239 of file namei.c.

SYSCALL_DEFINE3 ( unlinkat  ,
int  ,
dfd  ,
const char __user ,
pathname  ,
int  ,
flag   
)

Definition at line 3473 of file namei.c.

SYSCALL_DEFINE3 ( symlinkat  ,
const char __user ,
oldname  ,
int  ,
newdfd  ,
const char __user ,
newname   
)

Definition at line 3509 of file namei.c.

SYSCALL_DEFINE4 ( mknodat  ,
int  ,
dfd  ,
const char __user ,
filename  ,
umode_t  ,
mode  ,
unsigned  ,
dev   
)

Definition at line 3172 of file namei.c.

SYSCALL_DEFINE4 ( renameat  ,
int  ,
olddfd  ,
const char __user ,
oldname  ,
int  ,
newdfd  ,
const char __user ,
newname   
)

Definition at line 3801 of file namei.c.

SYSCALL_DEFINE5 ( linkat  ,
int  ,
olddfd  ,
const char __user ,
oldname  ,
int  ,
newdfd  ,
const char __user ,
newname  ,
int  ,
flags   
)

Definition at line 3593 of file namei.c.

void unlock_rename ( struct dentry p1,
struct dentry p2 
)

Definition at line 2327 of file namei.c.

int user_path_at ( int  dfd,
const char __user name,
unsigned  flags,
struct path path 
)

Definition at line 2179 of file namei.c.

int user_path_at_empty ( int  dfd,
const char __user name,
unsigned  flags,
struct path path,
int empty 
)

Definition at line 2161 of file namei.c.

struct dentry* user_path_create ( int  dfd,
const char __user pathname,
struct path path,
int  is_dir 
)
read

Definition at line 3116 of file namei.c.

int vfs_create ( struct inode dir,
struct dentry dentry,
umode_t  mode,
bool  want_excl 
)

Definition at line 2336 of file namei.c.

int vfs_follow_link ( struct nameidata nd,
const char link 
)

Definition at line 3943 of file namei.c.

int vfs_link ( struct dentry old_dentry,
struct inode dir,
struct dentry new_dentry 
)

Definition at line 3540 of file namei.c.

int vfs_mkdir ( struct inode dir,
struct dentry dentry,
umode_t  mode 
)

Definition at line 3214 of file namei.c.

int vfs_mknod ( struct inode dir,
struct dentry dentry,
umode_t  mode,
dev_t  dev 
)

Definition at line 3128 of file namei.c.

int vfs_path_lookup ( struct dentry dentry,
struct vfsmount mnt,
const char name,
unsigned int  flags,
struct path path 
)

Definition at line 2083 of file namei.c.

int vfs_readlink ( struct dentry dentry,
char __user buffer,
int  buflen,
const char link 
)

Definition at line 3904 of file namei.c.

int vfs_rename ( struct inode old_dir,
struct dentry old_dentry,
struct inode new_dir,
struct dentry new_dentry 
)

Definition at line 3763 of file namei.c.

int vfs_rmdir ( struct inode dir,
struct dentry dentry 
)

Definition at line 3287 of file namei.c.

int vfs_symlink ( struct inode dir,
struct dentry dentry,
const char oldname 
)

Definition at line 3489 of file namei.c.

int vfs_unlink ( struct inode dir,
struct dentry dentry 
)

Definition at line 3381 of file namei.c.

Variable Documentation

int sysctl_protected_hardlinks __read_mostly = 0

Definition at line 708 of file namei.c.

struct inode_operations page_symlink_inode_operations
Initial value:
= {
.readlink = generic_readlink,
.follow_link = page_follow_link_light,
.put_link = page_put_link,
}

Definition at line 4035 of file namei.c.