Skip to content

Commit

Permalink
Revert NFS changes
Browse files Browse the repository at this point in the history
  • Loading branch information
anodos325 committed Oct 31, 2024
1 parent ff82817 commit 72a8968
Show file tree
Hide file tree
Showing 12 changed files with 34 additions and 1,181 deletions.
521 changes: 0 additions & 521 deletions fs/nfs/nfs4proc.c

Large diffs are not rendered by default.

67 changes: 0 additions & 67 deletions fs/nfs_common/nfs41acl_xdr.h

This file was deleted.

140 changes: 0 additions & 140 deletions fs/nfs_common/nfsacl.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,6 @@
#include <linux/nfsacl.h>
#include <linux/nfs3.h>
#include <linux/sort.h>
#if CONFIG_TRUENAS
#include "nfs41acl_xdr.h"

/* Value from zfs/include/os/linux/spl/sys/acl.h */
#define ACL_IS_DIR 0x20000
#endif /* CONFIG_TRUENAS */


MODULE_LICENSE("GPL");

Expand Down Expand Up @@ -425,136 +418,3 @@ bool nfs_stream_decode_acl(struct xdr_stream *xdr, unsigned int *aclcnt,
return true;
}
EXPORT_SYMBOL_GPL(nfs_stream_decode_acl);

#if CONFIG_TRUENAS
static int
convert_to_nfs40_ace(u32 *xdrbuf, size_t *remaining, struct nfs4_ace *ace)
{
int error = 0;
u32 iflag, id;

if (*remaining < ACE4SIZE)
return -EOVERFLOW;

ace->type = ntohl(*(xdrbuf++));
if (ace->type > NFS4_ACE_ACCESS_DENIED_ACE_TYPE)
return -EINVAL;

ace->flag = ntohl(*(xdrbuf++));
iflag = ntohl(*(xdrbuf++));
ace->access_mask = ntohl(*(xdrbuf++)) & NFS4_ACE_MASK_ALL;
id = ntohl(*(xdrbuf++));

*remaining -= ACE4SIZE;

if (iflag & ACEI4_SPECIAL_WHO) {
switch (id) {
case ACE4_SPECIAL_OWNER:
ace->whotype = NFS4_ACL_WHO_OWNER;
break;
case ACE4_SPECIAL_GROUP:
ace->whotype = NFS4_ACL_WHO_GROUP;
break;
case ACE4_SPECIAL_EVERYONE:
ace->whotype = NFS4_ACL_WHO_EVERYONE;
break;
}
} else {
ace->whotype = NFS4_ACL_WHO_NAMED;
if (ace->flag & NFS4_ACE_IDENTIFIER_GROUP) {
ace->who_gid = make_kgid(&init_user_ns, id);
if (!gid_valid(ace->who_gid)) {
error = -EINVAL;
}
} else {
ace->who_uid = make_kuid(&init_user_ns, id);
if (!uid_valid(ace->who_uid)) {
error = -EINVAL;
}
}
}

return error;
}

int
convert_nfs41xdr_to_nfs40_acl(u32 *xdrbuf, size_t remaining, struct nfs4_acl *acl)
{
int error = 0;
int i;

for (i = 0; i < acl->naces; i++, xdrbuf += NACE41_LEN) {
error = convert_to_nfs40_ace(xdrbuf, &remaining, &acl->aces[i]);
if (error)
break;
}

return error;
}
EXPORT_SYMBOL_GPL(convert_nfs41xdr_to_nfs40_acl);

static int
convert_ace_to_nfs41(u32 *p, const struct nfs4_ace *ace)
{
int error = 0;
u32 iflag = 0, who = -1;

/* Audit and Alarm are not currently supported */
if (ace->type > NFS4_ACE_ACCESS_DENIED_ACE_TYPE)
return -EINVAL;

switch (ace->whotype) {
case NFS4_ACL_WHO_OWNER:
iflag = ACEI4_SPECIAL_WHO;
who = ACE4_SPECIAL_OWNER;
break;
case NFS4_ACL_WHO_GROUP:
iflag = ACEI4_SPECIAL_WHO;
who = ACE4_SPECIAL_GROUP;
break;
case NFS4_ACL_WHO_EVERYONE:
iflag = ACEI4_SPECIAL_WHO;
who = ACE4_SPECIAL_EVERYONE;
break;
case NFS4_ACL_WHO_NAMED:
if (ace->flag & NFS4_ACE_IDENTIFIER_GROUP)
who = (u32)__kgid_val(ace->who_gid);
else
who = (u32)__kuid_val(ace->who_uid);
break;
default:
error = -EINVAL;
}

*p++ = htonl(ace->type);
*p++ = htonl(ace->flag & NFS41_FLAGS);
*p++ = htonl(iflag);
*p++ = htonl(ace->access_mask & NFS4_ACE_MASK_ALL);
*p++ = htonl(who);

return error;
}

int
generate_nfs41acl_buf(u32 *xdrbuf, const struct nfs4_acl *acl, bool isdir)
{
int error = 0;
int i;

/*
* first byte is NFS41 Flags. Maybe be zero if these are RFC3530 acls
*/
*xdrbuf++ = htonl(acl->flag | (isdir ? ACL_IS_DIR : 0));
*xdrbuf++ = htonl(acl->naces);

for (i = 0; i < acl->naces; i++, xdrbuf += NACE41_LEN) {
error = convert_ace_to_nfs41(xdrbuf, &acl->aces[i]);
if (error)
break;
}

return error;
}
EXPORT_SYMBOL_GPL(generate_nfs41acl_buf);
#endif /* CONFIG_TRUENAS */

12 changes: 2 additions & 10 deletions fs/nfsd/acl.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,22 +40,14 @@ struct svc_fh;
struct svc_rqst;
struct nfsd_attrs;
enum nfs_ftype4;
#if CONFIG_TRUENAS
enum nfs4_acl_type;
#endif /* CONFIG_TRUENAS */

int nfs4_acl_bytes(int entries);
int nfs4_acl_get_whotype(char *, u32);
__be32 nfs4_acl_write_who(struct xdr_stream *xdr, int who);

void nfsd4_setup_attr(struct dentry *dentry, struct nfsd_attrs *attr);
int nfsd4_get_nfs4_acl(struct svc_rqst *rqstp, struct dentry *dentry,
#if CONFIG_TRUENAS
struct nfs4_acl **acl, enum nfs4_acl_type acl_type);
#else
struct nfs4_acl **acl);
#endif /* CONFIG_TRUENAS */
int nfsv4_set_zfacl_from_attr(struct dentry *dentry,
struct nfsd_attrs *attr);
__be32 nfsd4_acl_to_attr(enum nfs_ftype4 type, struct nfs4_acl *acl,
struct nfsd_attrs *attr);

#endif /* LINUX_NFS4_ACL_H */
2 changes: 1 addition & 1 deletion fs/nfsd/nfs3proc.c
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ nfsd3_create_file(struct svc_rqst *rqstp, struct svc_fh *fhp,
goto out;
}

if (!IS_POSIXACL(inode) && !IS_NFSV4ACL(inode))
if (!IS_POSIXACL(inode))
iap->ia_mode &= ~current_umask();

status = fh_fill_pre_attrs(fhp);
Expand Down
Loading

0 comments on commit 72a8968

Please sign in to comment.