/* * * Copyright (C) 2011 Novell Inc. * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 as published by * the Free Software Foundation. */#include<linux/fs.h>#include<linux/namei.h>#include<linux/pagemap.h>#include<linux/xattr.h>#include<linux/security.h>#include<linux/mount.h>#include<linux/slab.h>#include<linux/parser.h>#include<linux/module.h>#include<linux/sched.h>#include<linux/statfs.h>#include<linux/seq_file.h>#include<linux/posix_acl_xattr.h>#include"overlayfs.h"MODULE_AUTHOR("Miklos Szeredi <miklos@szeredi.hu>");MODULE_DESCRIPTION("Overlay filesystem");MODULE_LICENSE("GPL");structovl_config{char*lowerdir;char*upperdir;char*workdir;booldefault_permissions;};/* private information held for overlayfs's superblock */structovl_fs{structvfsmount*upper_mnt;unsignednumlower;structvfsmount**lower_mnt;structdentry*workdir;longlower_namelen;/* pathnames of lower and upper dirs, for show_options */structovl_configconfig;/* creds of process who forced instantiation of super block */conststructcred*creator_cred;};structovl_dir_cache;/* private information held for every overlayfs dentry */structovl_entry{structdentry*__upperdentry;structovl_dir_cache*cache;union{struct{u64version;boolopaque;};structrcu_headrcu;};unsignednumlower;structpathlowerstack[];};#define OVL_MAX_STACK 500staticstructdentry*__ovl_dentry_lower(structovl_entry*oe){returnoe->numlower?oe->lowerstack[0].dentry:NULL;}enumovl_path_typeovl_path_type(structdentry*dentry){structovl_entry*oe=dentry->d_fsdata;enumovl_path_typetype=0;if(oe->__upperdentry){type=__OVL_PATH_UPPER;/* * Non-dir dentry can hold lower dentry from previous * location. Its purity depends only on opaque flag. */if(oe->numlower&&S_ISDIR(dentry->d_inode->i_mode))type|=__OVL_PATH_MERGE;elseif(!oe->opaque)type