コード例 #1
0
        /// <exception cref="System.IO.IOException"/>
        internal static HdfsFileStatus RemoveDefaultAcl(FSDirectory fsd, string srcArg)
        {
            string src = srcArg;

            CheckAclsConfigFlag(fsd);
            FSPermissionChecker pc = fsd.GetPermissionChecker();

            byte[][] pathComponents = FSDirectory.GetPathComponentsForReservedPath(src);
            src = fsd.ResolvePath(pc, src, pathComponents);
            INodesInPath iip;

            fsd.WriteLock();
            try
            {
                iip = fsd.GetINodesInPath4Write(FSDirectory.NormalizePath(src), true);
                fsd.CheckOwner(pc, iip);
                INode            inode       = FSDirectory.ResolveLastINode(iip);
                int              snapshotId  = iip.GetLatestSnapshotId();
                IList <AclEntry> existingAcl = AclStorage.ReadINodeLogicalAcl(inode);
                IList <AclEntry> newAcl      = AclTransformation.FilterDefaultAclEntries(existingAcl);
                AclStorage.UpdateINodeAcl(inode, newAcl, snapshotId);
                fsd.GetEditLog().LogSetAcl(src, newAcl);
            }
            finally
            {
                fsd.WriteUnlock();
            }
            return(fsd.GetAuditFileInfo(iip));
        }
コード例 #2
0
        /// <exception cref="System.IO.IOException"/>
        internal static IList <AclEntry> UnprotectedSetAcl(FSDirectory fsd, string src, IList
                                                           <AclEntry> aclSpec, bool fromEdits)
        {
            System.Diagnostics.Debug.Assert(fsd.HasWriteLock());
            INodesInPath iip = fsd.GetINodesInPath4Write(FSDirectory.NormalizePath(src), true
                                                         );

            // ACL removal is logged to edits as OP_SET_ACL with an empty list.
            if (aclSpec.IsEmpty())
            {
                UnprotectedRemoveAcl(fsd, iip);
                return(AclFeature.EmptyEntryList);
            }
            INode            inode      = FSDirectory.ResolveLastINode(iip);
            int              snapshotId = iip.GetLatestSnapshotId();
            IList <AclEntry> newAcl     = aclSpec;

            if (!fromEdits)
            {
                IList <AclEntry> existingAcl = AclStorage.ReadINodeLogicalAcl(inode);
                newAcl = AclTransformation.ReplaceAclEntries(existingAcl, aclSpec);
            }
            AclStorage.UpdateINodeAcl(inode, newAcl, snapshotId);
            return(newAcl);
        }
コード例 #3
0
ファイル: FSDirMkdirOp.cs プロジェクト: orf53975/hadoop.net
        /// <summary>create a directory at path specified by parent</summary>
        /// <exception cref="Org.Apache.Hadoop.Hdfs.Protocol.QuotaExceededException"/>
        /// <exception cref="Org.Apache.Hadoop.Hdfs.Protocol.AclException"/>
        /// <exception cref="Org.Apache.Hadoop.FS.FileAlreadyExistsException"/>
        private static INodesInPath UnprotectedMkdir(FSDirectory fsd, long inodeId, INodesInPath
                                                     parent, byte[] name, PermissionStatus permission, IList <AclEntry> aclEntries, long
                                                     timestamp)
        {
            System.Diagnostics.Debug.Assert(fsd.HasWriteLock());
            System.Diagnostics.Debug.Assert(parent.GetLastINode() != null);
            if (!parent.GetLastINode().IsDirectory())
            {
                throw new FileAlreadyExistsException("Parent path is not a directory: " + parent.
                                                     GetPath() + " " + DFSUtil.Bytes2String(name));
            }
            INodeDirectory dir = new INodeDirectory(inodeId, name, permission, timestamp);
            INodesInPath   iip = fsd.AddLastINode(parent, dir, true);

            if (iip != null && aclEntries != null)
            {
                AclStorage.UpdateINodeAcl(dir, aclEntries, Org.Apache.Hadoop.Hdfs.Server.Namenode.Snapshot.Snapshot
                                          .CurrentStateId);
            }
            return(iip);
        }
コード例 #4
0
 /// <exception cref="System.IO.IOException"/>
 private void AddAcl(INodeWithAdditionalFields inode, params AclEntry[] acl)
 {
     AclStorage.UpdateINodeAcl(inode, Arrays.AsList(acl), Org.Apache.Hadoop.Hdfs.Server.Namenode.Snapshot.Snapshot
                               .CurrentStateId);
 }