dir.c (f7c85868fcacc331dd3454a4f08f006d7942521f) dir.c (8a5e929dd2e05ab4d3d89f58c5e8fca596af8f3a)
1/*
2 * linux/fs/nfs/dir.c
3 *
4 * Copyright (C) 1992 Rick Sladkey
5 *
6 * nfs directory handling functions
7 *
8 * 10 Apr 1996 Added silly rename for unlink --okir

--- 1324 unchanged lines hidden (view full) ---

1333{
1334 if (nd == NULL || nfs_lookup_check_intent(nd, LOOKUP_OPEN) == 0)
1335 return 0;
1336 /* NFS does not (yet) have a stateful open for directories */
1337 if (nd->flags & LOOKUP_DIRECTORY)
1338 return 0;
1339 /* Are we trying to write to a read only partition? */
1340 if (__mnt_is_readonly(nd->path.mnt) &&
1/*
2 * linux/fs/nfs/dir.c
3 *
4 * Copyright (C) 1992 Rick Sladkey
5 *
6 * nfs directory handling functions
7 *
8 * 10 Apr 1996 Added silly rename for unlink --okir

--- 1324 unchanged lines hidden (view full) ---

1333{
1334 if (nd == NULL || nfs_lookup_check_intent(nd, LOOKUP_OPEN) == 0)
1335 return 0;
1336 /* NFS does not (yet) have a stateful open for directories */
1337 if (nd->flags & LOOKUP_DIRECTORY)
1338 return 0;
1339 /* Are we trying to write to a read only partition? */
1340 if (__mnt_is_readonly(nd->path.mnt) &&
1341 (nd->intent.open.flags & (O_CREAT|O_TRUNC|FMODE_WRITE)))
1341 (nd->intent.open.flags & (O_CREAT|O_TRUNC|O_ACCMODE)))
1342 return 0;
1343 return 1;
1344}
1345
1342 return 0;
1343 return 1;
1344}
1345
1346static fmode_t flags_to_mode(int flags)
1347{
1348 fmode_t res = (__force fmode_t)flags & FMODE_EXEC;
1349 if ((flags & O_ACCMODE) != O_WRONLY)
1350 res |= FMODE_READ;
1351 if ((flags & O_ACCMODE) != O_RDONLY)
1352 res |= FMODE_WRITE;
1353 return res;
1354}
1355
1346static struct nfs_open_context *create_nfs_open_context(struct dentry *dentry, int open_flags)
1347{
1348 struct nfs_open_context *ctx;
1349 struct rpc_cred *cred;
1356static struct nfs_open_context *create_nfs_open_context(struct dentry *dentry, int open_flags)
1357{
1358 struct nfs_open_context *ctx;
1359 struct rpc_cred *cred;
1350 fmode_t fmode = open_flags & (FMODE_READ | FMODE_WRITE | FMODE_EXEC);
1360 fmode_t fmode = flags_to_mode(open_flags);
1351
1352 cred = rpc_lookup_cred();
1353 if (IS_ERR(cred))
1354 return ERR_CAST(cred);
1355 ctx = alloc_nfs_open_context(dentry, cred, fmode);
1356 put_rpccred(cred);
1357 if (ctx == NULL)
1358 return ERR_PTR(-ENOMEM);

--- 203 unchanged lines hidden (view full) ---

1562}
1563
1564static int nfs_open_create(struct inode *dir, struct dentry *dentry, int mode,
1565 struct nameidata *nd)
1566{
1567 struct nfs_open_context *ctx = NULL;
1568 struct iattr attr;
1569 int error;
1361
1362 cred = rpc_lookup_cred();
1363 if (IS_ERR(cred))
1364 return ERR_CAST(cred);
1365 ctx = alloc_nfs_open_context(dentry, cred, fmode);
1366 put_rpccred(cred);
1367 if (ctx == NULL)
1368 return ERR_PTR(-ENOMEM);

--- 203 unchanged lines hidden (view full) ---

1572}
1573
1574static int nfs_open_create(struct inode *dir, struct dentry *dentry, int mode,
1575 struct nameidata *nd)
1576{
1577 struct nfs_open_context *ctx = NULL;
1578 struct iattr attr;
1579 int error;
1570 int open_flags = O_CREAT|O_EXCL|FMODE_READ;
1580 int open_flags = O_CREAT|O_EXCL;
1571
1572 dfprintk(VFS, "NFS: create(%s/%ld), %s\n",
1573 dir->i_sb->s_id, dir->i_ino, dentry->d_name.name);
1574
1575 attr.ia_mode = mode;
1576 attr.ia_valid = ATTR_MODE;
1577
1578 if (nd && (nd->flags & LOOKUP_OPEN) != 0)

--- 73 unchanged lines hidden (view full) ---

1652 * that the operation succeeded on the server, but an error in the
1653 * reply path made it appear to have failed.
1654 */
1655static int nfs_create(struct inode *dir, struct dentry *dentry, int mode,
1656 struct nameidata *nd)
1657{
1658 struct iattr attr;
1659 int error;
1581
1582 dfprintk(VFS, "NFS: create(%s/%ld), %s\n",
1583 dir->i_sb->s_id, dir->i_ino, dentry->d_name.name);
1584
1585 attr.ia_mode = mode;
1586 attr.ia_valid = ATTR_MODE;
1587
1588 if (nd && (nd->flags & LOOKUP_OPEN) != 0)

--- 73 unchanged lines hidden (view full) ---

1662 * that the operation succeeded on the server, but an error in the
1663 * reply path made it appear to have failed.
1664 */
1665static int nfs_create(struct inode *dir, struct dentry *dentry, int mode,
1666 struct nameidata *nd)
1667{
1668 struct iattr attr;
1669 int error;
1660 int open_flags = O_CREAT|O_EXCL|FMODE_READ;
1670 int open_flags = O_CREAT|O_EXCL;
1661
1662 dfprintk(VFS, "NFS: create(%s/%ld), %s\n",
1663 dir->i_sb->s_id, dir->i_ino, dentry->d_name.name);
1664
1665 attr.ia_mode = mode;
1666 attr.ia_valid = ATTR_MODE;
1667
1668 if (nd && (nd->flags & LOOKUP_OPEN) != 0)

--- 582 unchanged lines hidden (view full) ---

2251 return 0;
2252 return -EACCES;
2253}
2254
2255static int nfs_open_permission_mask(int openflags)
2256{
2257 int mask = 0;
2258
1671
1672 dfprintk(VFS, "NFS: create(%s/%ld), %s\n",
1673 dir->i_sb->s_id, dir->i_ino, dentry->d_name.name);
1674
1675 attr.ia_mode = mode;
1676 attr.ia_valid = ATTR_MODE;
1677
1678 if (nd && (nd->flags & LOOKUP_OPEN) != 0)

--- 582 unchanged lines hidden (view full) ---

2261 return 0;
2262 return -EACCES;
2263}
2264
2265static int nfs_open_permission_mask(int openflags)
2266{
2267 int mask = 0;
2268
2259 if (openflags & FMODE_READ)
2269 if ((openflags & O_ACCMODE) != O_WRONLY)
2260 mask |= MAY_READ;
2270 mask |= MAY_READ;
2261 if (openflags & FMODE_WRITE)
2271 if ((openflags & O_ACCMODE) != O_RDONLY)
2262 mask |= MAY_WRITE;
2272 mask |= MAY_WRITE;
2263 if (openflags & FMODE_EXEC)
2273 if (openflags & __FMODE_EXEC)
2264 mask |= MAY_EXEC;
2265 return mask;
2266}
2267
2268int nfs_may_open(struct inode *inode, struct rpc_cred *cred, int openflags)
2269{
2270 return nfs_do_access(inode, cred, nfs_open_permission_mask(openflags));
2271}

--- 66 unchanged lines hidden ---
2274 mask |= MAY_EXEC;
2275 return mask;
2276}
2277
2278int nfs_may_open(struct inode *inode, struct rpc_cred *cred, int openflags)
2279{
2280 return nfs_do_access(inode, cred, nfs_open_permission_mask(openflags));
2281}

--- 66 unchanged lines hidden ---