Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 9998
b: refs/heads/master
c: cb1f7be
h: refs/heads/master
v: v3
  • Loading branch information
Trond Myklebust authored and Trond Myklebust committed Oct 18, 2005
1 parent 8c466d0 commit 85b9ed7
Show file tree
Hide file tree
Showing 40 changed files with 3,068 additions and 1,948 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: bb7e257ef8d8ba43cab356aa1cc1b20d0106d45f
refs/heads/master: cb1f7be73b6f708d4f4ce225a3bbc02908b729e4
12 changes: 6 additions & 6 deletions trunk/fs/exec.c
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,7 @@ asmlinkage long sys_uselib(const char __user * library)
struct nameidata nd;
int error;

nd.intent.open.flags = FMODE_READ;
error = __user_walk(library, LOOKUP_FOLLOW|LOOKUP_OPEN, &nd);
error = __user_path_lookup_open(library, LOOKUP_FOLLOW, &nd, FMODE_READ);
if (error)
goto out;

Expand All @@ -139,7 +138,7 @@ asmlinkage long sys_uselib(const char __user * library)
if (error)
goto exit;

file = dentry_open(nd.dentry, nd.mnt, O_RDONLY);
file = nameidata_to_filp(&nd, O_RDONLY);
error = PTR_ERR(file);
if (IS_ERR(file))
goto out;
Expand Down Expand Up @@ -167,6 +166,7 @@ asmlinkage long sys_uselib(const char __user * library)
out:
return error;
exit:
release_open_intent(&nd);
path_release(&nd);
goto out;
}
Expand Down Expand Up @@ -490,8 +490,7 @@ struct file *open_exec(const char *name)
int err;
struct file *file;

nd.intent.open.flags = FMODE_READ;
err = path_lookup(name, LOOKUP_FOLLOW|LOOKUP_OPEN, &nd);
err = path_lookup_open(name, LOOKUP_FOLLOW, &nd, FMODE_READ);
file = ERR_PTR(err);

if (!err) {
Expand All @@ -504,7 +503,7 @@ struct file *open_exec(const char *name)
err = -EACCES;
file = ERR_PTR(err);
if (!err) {
file = dentry_open(nd.dentry, nd.mnt, O_RDONLY);
file = nameidata_to_filp(&nd, O_RDONLY);
if (!IS_ERR(file)) {
err = deny_write_access(file);
if (err) {
Expand All @@ -516,6 +515,7 @@ struct file *open_exec(const char *name)
return file;
}
}
release_open_intent(&nd);
path_release(&nd);
}
goto out;
Expand Down
4 changes: 1 addition & 3 deletions trunk/fs/lockd/host.c
Original file line number Diff line number Diff line change
Expand Up @@ -173,11 +173,10 @@ nlm_bind_host(struct nlm_host *host)

/* If we've already created an RPC client, check whether
* RPC rebind is required
* Note: why keep rebinding if we're on a tcp connection?
*/
if ((clnt = host->h_rpcclnt) != NULL) {
xprt = clnt->cl_xprt;
if (!xprt->stream && time_after_eq(jiffies, host->h_nextrebind)) {
if (time_after_eq(jiffies, host->h_nextrebind)) {
clnt->cl_port = 0;
host->h_nextrebind = jiffies + NLM_HOST_REBIND;
dprintk("lockd: next rebind in %ld jiffies\n",
Expand All @@ -189,7 +188,6 @@ nlm_bind_host(struct nlm_host *host)
goto forgetit;

xprt_set_timeout(&xprt->timeout, 5, nlmsvc_timeout);
xprt->nocong = 1; /* No congestion control for NLM */
xprt->resvport = 1; /* NLM requires a reserved port */

/* Existing NLM servers accept AUTH_UNIX only */
Expand Down
48 changes: 30 additions & 18 deletions trunk/fs/locks.c
Original file line number Diff line number Diff line change
Expand Up @@ -316,21 +316,22 @@ static int flock_to_posix_lock(struct file *filp, struct file_lock *fl,
/* POSIX-1996 leaves the case l->l_len < 0 undefined;
POSIX-2001 defines it. */
start += l->l_start;
end = start + l->l_len - 1;
if (l->l_len < 0) {
if (start < 0)
return -EINVAL;
fl->fl_end = OFFSET_MAX;
if (l->l_len > 0) {
end = start + l->l_len - 1;
fl->fl_end = end;
} else if (l->l_len < 0) {
end = start - 1;
fl->fl_end = end;
start += l->l_len;
if (start < 0)
return -EINVAL;
}

if (start < 0)
return -EINVAL;
if (l->l_len > 0 && end < 0)
return -EOVERFLOW;

fl->fl_start = start; /* we record the absolute position */
fl->fl_end = end;
if (l->l_len == 0)
fl->fl_end = OFFSET_MAX;
if (fl->fl_end < fl->fl_start)
return -EOVERFLOW;

fl->fl_owner = current->files;
fl->fl_pid = current->tgid;
Expand Down Expand Up @@ -362,14 +363,21 @@ static int flock64_to_posix_lock(struct file *filp, struct file_lock *fl,
return -EINVAL;
}

if (((start += l->l_start) < 0) || (l->l_len < 0))
start += l->l_start;
if (start < 0)
return -EINVAL;
fl->fl_end = start + l->l_len - 1;
if (l->l_len > 0 && fl->fl_end < 0)
return -EOVERFLOW;
fl->fl_end = OFFSET_MAX;
if (l->l_len > 0) {
fl->fl_end = start + l->l_len - 1;
} else if (l->l_len < 0) {
fl->fl_end = start - 1;
start += l->l_len;
if (start < 0)
return -EINVAL;
}
fl->fl_start = start; /* we record the absolute position */
if (l->l_len == 0)
fl->fl_end = OFFSET_MAX;
if (fl->fl_end < fl->fl_start)
return -EOVERFLOW;

fl->fl_owner = current->files;
fl->fl_pid = current->tgid;
Expand Down Expand Up @@ -829,12 +837,16 @@ static int __posix_lock_file(struct inode *inode, struct file_lock *request)
/* Detect adjacent or overlapping regions (if same lock type)
*/
if (request->fl_type == fl->fl_type) {
/* In all comparisons of start vs end, use
* "start - 1" rather than "end + 1". If end
* is OFFSET_MAX, end + 1 will become negative.
*/
if (fl->fl_end < request->fl_start - 1)
goto next_lock;
/* If the next lock in the list has entirely bigger
* addresses than the new one, insert the lock here.
*/
if (fl->fl_start > request->fl_end + 1)
if (fl->fl_start - 1 > request->fl_end)
break;

/* If we come here, the new and old lock are of the
Expand Down
95 changes: 87 additions & 8 deletions trunk/fs/namei.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include <linux/syscalls.h>
#include <linux/mount.h>
#include <linux/audit.h>
#include <linux/file.h>
#include <asm/namei.h>
#include <asm/uaccess.h>

Expand Down Expand Up @@ -317,6 +318,18 @@ void path_release_on_umount(struct nameidata *nd)
mntput_no_expire(nd->mnt);
}

/**
* release_open_intent - free up open intent resources
* @nd: pointer to nameidata
*/
void release_open_intent(struct nameidata *nd)
{
if (nd->intent.open.file->f_dentry == NULL)
put_filp(nd->intent.open.file);
else
fput(nd->intent.open.file);
}

/*
* Internal lookup() using the new generic dcache.
* SMP-safe
Expand Down Expand Up @@ -750,6 +763,7 @@ static fastcall int __link_path_walk(const char * name, struct nameidata *nd)
struct qstr this;
unsigned int c;

nd->flags |= LOOKUP_CONTINUE;
err = exec_permission_lite(inode, nd);
if (err == -EAGAIN) {
err = permission(inode, MAY_EXEC, nd);
Expand Down Expand Up @@ -802,7 +816,6 @@ static fastcall int __link_path_walk(const char * name, struct nameidata *nd)
if (err < 0)
break;
}
nd->flags |= LOOKUP_CONTINUE;
/* This does the actual lookups.. */
err = do_lookup(nd, &this, &next);
if (err)
Expand Down Expand Up @@ -1052,6 +1065,70 @@ int fastcall path_lookup(const char *name, unsigned int flags, struct nameidata
return retval;
}

static int __path_lookup_intent_open(const char *name, unsigned int lookup_flags,
struct nameidata *nd, int open_flags, int create_mode)
{
struct file *filp = get_empty_filp();
int err;

if (filp == NULL)
return -ENFILE;
nd->intent.open.file = filp;
nd->intent.open.flags = open_flags;
nd->intent.open.create_mode = create_mode;
err = path_lookup(name, lookup_flags|LOOKUP_OPEN, nd);
if (IS_ERR(nd->intent.open.file)) {
if (err == 0) {
err = PTR_ERR(nd->intent.open.file);
path_release(nd);
}
} else if (err != 0)
release_open_intent(nd);
return err;
}

/**
* path_lookup_open - lookup a file path with open intent
* @name: pointer to file name
* @lookup_flags: lookup intent flags
* @nd: pointer to nameidata
* @open_flags: open intent flags
*/
int path_lookup_open(const char *name, unsigned int lookup_flags,
struct nameidata *nd, int open_flags)
{
return __path_lookup_intent_open(name, lookup_flags, nd,
open_flags, 0);
}

/**
* path_lookup_create - lookup a file path with open + create intent
* @name: pointer to file name
* @lookup_flags: lookup intent flags
* @nd: pointer to nameidata
* @open_flags: open intent flags
* @create_mode: create intent flags
*/
int path_lookup_create(const char *name, unsigned int lookup_flags,
struct nameidata *nd, int open_flags, int create_mode)
{
return __path_lookup_intent_open(name, lookup_flags|LOOKUP_CREATE, nd,
open_flags, create_mode);
}

int __user_path_lookup_open(const char __user *name, unsigned int lookup_flags,
struct nameidata *nd, int open_flags)
{
char *tmp = getname(name);
int err = PTR_ERR(tmp);

if (!IS_ERR(tmp)) {
err = __path_lookup_intent_open(tmp, lookup_flags, nd, open_flags, 0);
putname(tmp);
}
return err;
}

/*
* Restricted form of lookup. Doesn't follow links, single-component only,
* needs parent already locked. Doesn't follow mounts.
Expand Down Expand Up @@ -1416,27 +1493,27 @@ int may_open(struct nameidata *nd, int acc_mode, int flag)
*/
int open_namei(const char * pathname, int flag, int mode, struct nameidata *nd)
{
int acc_mode, error = 0;
int acc_mode, error;
struct path path;
struct dentry *dir;
int count = 0;

acc_mode = ACC_MODE(flag);

/* O_TRUNC implies we need access checks for write permissions */
if (flag & O_TRUNC)
acc_mode |= MAY_WRITE;

/* Allow the LSM permission hook to distinguish append
access from general write access. */
if (flag & O_APPEND)
acc_mode |= MAY_APPEND;

/* Fill in the open() intent data */
nd->intent.open.flags = flag;
nd->intent.open.create_mode = mode;

/*
* The simplest case - just a plain lookup.
*/
if (!(flag & O_CREAT)) {
error = path_lookup(pathname, lookup_flags(flag)|LOOKUP_OPEN, nd);
error = path_lookup_open(pathname, lookup_flags(flag), nd, flag);
if (error)
return error;
goto ok;
Expand All @@ -1445,7 +1522,7 @@ int open_namei(const char * pathname, int flag, int mode, struct nameidata *nd)
/*
* Create - we need to know the parent.
*/
error = path_lookup(pathname, LOOKUP_PARENT|LOOKUP_OPEN|LOOKUP_CREATE, nd);
error = path_lookup_create(pathname, LOOKUP_PARENT, nd, flag, mode);
if (error)
return error;

Expand Down Expand Up @@ -1520,6 +1597,8 @@ int open_namei(const char * pathname, int flag, int mode, struct nameidata *nd)
exit_dput:
dput_path(&path, nd);
exit:
if (!IS_ERR(nd->intent.open.file))
release_open_intent(nd);
path_release(nd);
return error;

Expand Down
2 changes: 1 addition & 1 deletion trunk/fs/nfs/delegation.c
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ static void nfs_msync_inode(struct inode *inode)
/*
* Basic procedure for returning a delegation to the server
*/
int nfs_inode_return_delegation(struct inode *inode)
int __nfs_inode_return_delegation(struct inode *inode)
{
struct nfs4_client *clp = NFS_SERVER(inode)->nfs4_state;
struct nfs_inode *nfsi = NFS_I(inode);
Expand Down
16 changes: 15 additions & 1 deletion trunk/fs/nfs/delegation.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ struct nfs_delegation {

int nfs_inode_set_delegation(struct inode *inode, struct rpc_cred *cred, struct nfs_openres *res);
void nfs_inode_reclaim_delegation(struct inode *inode, struct rpc_cred *cred, struct nfs_openres *res);
int nfs_inode_return_delegation(struct inode *inode);
int __nfs_inode_return_delegation(struct inode *inode);
int nfs_async_inode_return_delegation(struct inode *inode, const nfs4_stateid *stateid);

struct inode *nfs_delegation_find_inode(struct nfs4_client *clp, const struct nfs_fh *fhandle);
Expand All @@ -47,11 +47,25 @@ static inline int nfs_have_delegation(struct inode *inode, int flags)
return 1;
return 0;
}

static inline int nfs_inode_return_delegation(struct inode *inode)
{
int err = 0;

if (NFS_I(inode)->delegation != NULL)
err = __nfs_inode_return_delegation(inode);
return err;
}
#else
static inline int nfs_have_delegation(struct inode *inode, int flags)
{
return 0;
}

static inline int nfs_inode_return_delegation(struct inode *inode)
{
return 0;
}
#endif

#endif
Loading

0 comments on commit 85b9ed7

Please sign in to comment.