Skip to content

Commit

Permalink
Merge pull request #1 from CryToCry96/cm-14.0-test
Browse files Browse the repository at this point in the history
pull request  sdcardfs
  • Loading branch information
linhphi9x94 committed Nov 30, 2016
2 parents f10fd27 + 34b560f commit 1a12bad
Show file tree
Hide file tree
Showing 30 changed files with 4,018 additions and 87 deletions.
2 changes: 2 additions & 0 deletions arch/arm/configs/cm_ef52_defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -557,6 +557,8 @@ CONFIG_NFS_V3=y
CONFIG_NFS_V3_ACL=y
CONFIG_NFS_V4=y
CONFIG_CIFS=y
CONFIG_CONFIGFS_FS=y
CONFIG_SDCARD_FS=y
CONFIG_NLS_CODEPAGE_437=y
CONFIG_NLS_ASCII=y
CONFIG_NLS_ISO8859_1=y
Expand Down
98 changes: 41 additions & 57 deletions drivers/base/devtmpfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -227,33 +227,24 @@ static int handle_create(const char *nodename, umode_t mode, struct device *dev)

static int dev_rmdir(const char *name)
{
struct nameidata nd;
struct path parent;
struct dentry *dentry;
int err;

err = kern_path_parent(name, &nd);
if (err)
return err;

mutex_lock_nested(&nd.path.dentry->d_inode->i_mutex, I_MUTEX_PARENT);
dentry = lookup_one_len(nd.last.name, nd.path.dentry, nd.last.len);
if (!IS_ERR(dentry)) {
if (dentry->d_inode) {
if (dentry->d_inode->i_private == &thread)
err = vfs_rmdir(nd.path.dentry->d_inode,
dentry);
else
err = -EPERM;
} else {
err = -ENOENT;
}
dput(dentry);
dentry = kern_path_locked(name, &parent);
if (IS_ERR(dentry))
return PTR_ERR(dentry);
if (dentry->d_inode) {
if (dentry->d_inode->i_private == &thread)
err = vfs_rmdir(parent.dentry->d_inode, dentry);
else
err = -EPERM;
} else {
err = PTR_ERR(dentry);
err = -ENOENT;
}

mutex_unlock(&nd.path.dentry->d_inode->i_mutex);
path_put(&nd.path);
dput(dentry);
mutex_unlock(&parent.dentry->d_inode->i_mutex);
path_put(&parent);
return err;
}

Expand Down Expand Up @@ -305,50 +296,43 @@ static int dev_mynode(struct device *dev, struct inode *inode, struct kstat *sta

static int handle_remove(const char *nodename, struct device *dev)
{
struct nameidata nd;
struct path parent;
struct dentry *dentry;
struct kstat stat;
int deleted = 1;
int err;

err = kern_path_parent(nodename, &nd);
if (err)
return err;
dentry = kern_path_locked(nodename, &parent);
if (IS_ERR(dentry))
return PTR_ERR(dentry);

mutex_lock_nested(&nd.path.dentry->d_inode->i_mutex, I_MUTEX_PARENT);
dentry = lookup_one_len(nd.last.name, nd.path.dentry, nd.last.len);
if (!IS_ERR(dentry)) {
if (dentry->d_inode) {
err = vfs_getattr(nd.path.mnt, dentry, &stat);
if (!err && dev_mynode(dev, dentry->d_inode, &stat)) {
struct iattr newattrs;
/*
* before unlinking this node, reset permissions
* of possible references like hardlinks
*/
newattrs.ia_uid = 0;
newattrs.ia_gid = 0;
newattrs.ia_mode = stat.mode & ~0777;
newattrs.ia_valid =
ATTR_UID|ATTR_GID|ATTR_MODE;
mutex_lock(&dentry->d_inode->i_mutex);
notify_change(dentry, &newattrs);
mutex_unlock(&dentry->d_inode->i_mutex);
err = vfs_unlink(nd.path.dentry->d_inode,
dentry);
if (!err || err == -ENOENT)
deleted = 1;
}
} else {
err = -ENOENT;
if (dentry->d_inode) {
struct kstat stat;
err = vfs_getattr(parent.mnt, dentry, &stat);
if (!err && dev_mynode(dev, dentry->d_inode, &stat)) {
struct iattr newattrs;
/*
* before unlinking this node, reset permissions
* of possible references like hardlinks
*/
newattrs.ia_uid = 0;
newattrs.ia_gid = 0;
newattrs.ia_mode = stat.mode & ~0777;
newattrs.ia_valid =
ATTR_UID|ATTR_GID|ATTR_MODE;
mutex_lock(&dentry->d_inode->i_mutex);
notify_change(dentry, &newattrs);
mutex_unlock(&dentry->d_inode->i_mutex);
err = vfs_unlink(parent.dentry->d_inode, dentry);
if (!err || err == -ENOENT)
deleted = 1;
}
dput(dentry);
} else {
err = PTR_ERR(dentry);
err = -ENOENT;
}
mutex_unlock(&nd.path.dentry->d_inode->i_mutex);
dput(dentry);
mutex_unlock(&parent.dentry->d_inode->i_mutex);

path_put(&nd.path);
path_put(&parent);
if (deleted && strchr(nodename, '/'))
delete_path(nodename);
return err;
Expand Down
2 changes: 1 addition & 1 deletion drivers/net/wireless/wcnss/wcnss_wlan.c
Original file line number Diff line number Diff line change
Expand Up @@ -1672,7 +1672,7 @@ static ssize_t wcnss_wlan_write(struct file *fp, const char __user
return -EFAULT;

if ((UINT32_MAX - count < penv->user_cal_rcvd) ||
MAX_CALIBRATED_DATA_SIZE < count + penv->user_cal_rcvd) {
(penv->user_cal_exp_size < count + penv->user_cal_rcvd)) {
pr_err(DEVICE " invalid size to write %d\n", count +
penv->user_cal_rcvd);
rc = -ENOMEM;
Expand Down
1 change: 1 addition & 0 deletions fs/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ if MISC_FILESYSTEMS
source "fs/adfs/Kconfig"
source "fs/affs/Kconfig"
source "fs/ecryptfs/Kconfig"
source "fs/sdcardfs/Kconfig"
source "fs/hfs/Kconfig"
source "fs/hfsplus/Kconfig"
source "fs/befs/Kconfig"
Expand Down
5 changes: 3 additions & 2 deletions fs/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#
# 14 Sep 2000, Christoph Hellwig <hch@infradead.org>
# Rewritten to use lists instead of if-statements.
#
#

obj-y := open.o read_write.o file_table.o super.o \
char_dev.o stat.o exec.o pipe.o namei.o fcntl.o \
Expand Down Expand Up @@ -60,7 +60,7 @@ obj-y += devpts/

obj-$(CONFIG_PROFILING) += dcookies.o
obj-$(CONFIG_DLM) += dlm/

# Do not add any filesystems before this line
obj-$(CONFIG_FSCACHE) += fscache/
obj-$(CONFIG_REISERFS_FS) += reiserfs/
Expand All @@ -83,6 +83,7 @@ obj-$(CONFIG_ISO9660_FS) += isofs/
obj-$(CONFIG_HFSPLUS_FS) += hfsplus/ # Before hfs to find wrapped HFS+
obj-$(CONFIG_HFS_FS) += hfs/
obj-$(CONFIG_ECRYPT_FS) += ecryptfs/
obj-$(CONFIG_SDCARD_FS) += sdcardfs/
obj-$(CONFIG_VXFS_FS) += freevxfs/
obj-$(CONFIG_NFS_FS) += nfs/
obj-$(CONFIG_EXPORTFS) += exportfs/
Expand Down
3 changes: 3 additions & 0 deletions fs/compat_ioctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -868,6 +868,9 @@ COMPATIBLE_IOCTL(TIOCGPTN)
COMPATIBLE_IOCTL(TIOCSPTLCK)
COMPATIBLE_IOCTL(TIOCSERGETLSR)
COMPATIBLE_IOCTL(TIOCSIG)
COMPATIBLE_IOCTL(TIOCPMGET)
COMPATIBLE_IOCTL(TIOCPMPUT)
COMPATIBLE_IOCTL(TIOCPMACT)
#ifdef TCGETS2
COMPATIBLE_IOCTL(TCGETS2)
COMPATIBLE_IOCTL(TCSETS2)
Expand Down
1 change: 1 addition & 0 deletions fs/fs_struct.c
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ struct fs_struct *copy_fs_struct(struct fs_struct *old)
return fs;
}

EXPORT_SYMBOL_GPL(copy_fs_struct);
int unshare_fs_struct(void)
{
struct fs_struct *fs = current->fs;
Expand Down
5 changes: 5 additions & 0 deletions fs/fuse/dev.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include <linux/poll.h>
#include <linux/uio.h>
#include <linux/miscdevice.h>
#include <linux/namei.h>
#include <linux/pagemap.h>
#include <linux/file.h>
#include <linux/slab.h>
Expand Down Expand Up @@ -1783,6 +1784,10 @@ static ssize_t fuse_dev_do_write(struct fuse_conn *fc,
spin_unlock(&fc->lock);

err = copy_out_args(cs, &req->out, nbytes);
if (req->in.h.opcode == FUSE_CANONICAL_PATH) {
req->out.h.error = kern_path((char *)req->out.args[0].value, 0,
req->canonical_path);
}
fuse_copy_finish(cs);

spin_lock(&fc->lock);
Expand Down
45 changes: 45 additions & 0 deletions fs/fuse/dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -222,13 +222,58 @@ static int fuse_dentry_revalidate(struct dentry *entry, struct nameidata *nd)
return 1;
}

/*
* Get the canonical path. Since we must translate to a path, this must be done
* in the context of the userspace daemon, however, the userspace daemon cannot
* look up paths on its own. Instead, we handle the lookup as a special case
* inside of the write request.
*/
static void fuse_dentry_canonical_path(const struct path *path, struct path *canonical_path) {
struct inode *inode = path->dentry->d_inode;
struct fuse_conn *fc = get_fuse_conn(inode);
struct fuse_req *req;
int err;
char *path_name;

req = fuse_get_req(fc);
err = PTR_ERR(req);
if (IS_ERR(req))
goto default_path;

path_name = (char*)__get_free_page(GFP_KERNEL);
if (!path_name) {
fuse_put_request(fc, req);
goto default_path;
}

req->in.h.opcode = FUSE_CANONICAL_PATH;
req->in.h.nodeid = get_node_id(inode);
req->in.numargs = 0;
req->out.numargs = 1;
req->out.args[0].size = PATH_MAX;
req->out.args[0].value = path_name;
req->canonical_path = canonical_path;
req->out.argvar = 1;
fuse_request_send(fc, req);
err = req->out.h.error;
fuse_put_request(fc, req);
free_page((unsigned long)path_name);
if (!err)
return;
default_path:
canonical_path->dentry = path->dentry;
canonical_path->mnt = path->mnt;
path_get(canonical_path);
}

static int invalid_nodeid(u64 nodeid)
{
return !nodeid || nodeid == FUSE_ROOT_ID;
}

const struct dentry_operations fuse_dentry_operations = {
.d_revalidate = fuse_dentry_revalidate,
.d_canonical_path = fuse_dentry_canonical_path,
};

int fuse_valid_type(int m)
Expand Down
3 changes: 3 additions & 0 deletions fs/fuse/fuse_i.h
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,9 @@ struct fuse_req {
/** Inode used in the request or NULL */
struct inode *inode;

/** Path used for completing d_canonical_path */
struct path *canonical_path;

/** Link on fi->writepages */
struct list_head writepages_entry;

Expand Down
22 changes: 20 additions & 2 deletions fs/namei.c
Original file line number Diff line number Diff line change
Expand Up @@ -1799,9 +1799,27 @@ static int do_path_lookup(int dfd, const char *name,
return retval;
}

int kern_path_parent(const char *name, struct nameidata *nd)
/* does lookup, returns the object with parent locked */
struct dentry *kern_path_locked(const char *name, struct path *path)
{
return do_path_lookup(AT_FDCWD, name, LOOKUP_PARENT, nd);
struct nameidata nd;
struct dentry *d;
int err = do_path_lookup(AT_FDCWD, name, LOOKUP_PARENT, &nd);
if (err)
return ERR_PTR(err);
if (nd.last_type != LAST_NORM) {
path_put(&nd.path);
return ERR_PTR(-EINVAL);
}
mutex_lock_nested(&nd.path.dentry->d_inode->i_mutex, I_MUTEX_PARENT);
d = lookup_one_len(nd.last.name, nd.path.dentry, nd.last.len);
if (IS_ERR(d)) {
mutex_unlock(&nd.path.dentry->d_inode->i_mutex);
path_put(&nd.path);
return d;
}
*path = nd.path;
return d;
}

int kern_path(const char *name, unsigned int flags, struct path *path)
Expand Down
15 changes: 13 additions & 2 deletions fs/notify/inotify/inotify_user.c
Original file line number Diff line number Diff line change
Expand Up @@ -752,6 +752,8 @@ SYSCALL_DEFINE3(inotify_add_watch, int, fd, const char __user *, pathname,
struct inode *inode;
struct path path;
struct file *filp;
struct path alteredpath;
struct path *canonical_path = &path;
int ret, fput_needed;
unsigned flags = 0;

Expand All @@ -778,13 +780,22 @@ SYSCALL_DEFINE3(inotify_add_watch, int, fd, const char __user *, pathname,
if (ret)
goto fput_and_out;

/* support stacked filesystems */
if(path.dentry && path.dentry->d_op) {
if (path.dentry->d_op->d_canonical_path) {
path.dentry->d_op->d_canonical_path(&path, &alteredpath);
canonical_path = &alteredpath;
path_put(&path);
}
}

/* inode held in place by reference to path; group by fget on fd */
inode = path.dentry->d_inode;
inode = canonical_path->dentry->d_inode;
group = filp->private_data;

/* create/update an inode mark */
ret = inotify_update_watch(group, inode, mask);
path_put(&path);
path_put(canonical_path);
fput_and_out:
fput_light(filp, fput_needed);
return ret;
Expand Down
13 changes: 13 additions & 0 deletions fs/sdcardfs/Kconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
config SDCARD_FS
tristate "sdcard file system"
depends on CONFIGFS_FS
default n
help
Sdcardfs is based on Wrapfs file system.

config SDCARD_FS_FADV_NOACTIVE
bool "sdcardfs fadvise noactive support"
depends on FADV_NOACTIVE
default y
help
Sdcardfs supports fadvise noactive mode.
7 changes: 7 additions & 0 deletions fs/sdcardfs/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
SDCARDFS_VERSION="0.1"

EXTRA_CFLAGS += -DSDCARDFS_VERSION=\"$(SDCARDFS_VERSION)\"

obj-$(CONFIG_SDCARD_FS) += sdcardfs.o

sdcardfs-y := dentry.o file.o inode.o main.o super.o lookup.o mmap.o packagelist.o derived_perm.o
Loading

0 comments on commit 1a12bad

Please sign in to comment.