// Helper function that reads in an INodeUnderConstruction
        // from the input stream
        //
        /// <exception cref="System.IO.IOException"/>
        internal static INodeFile ReadINodeUnderConstruction(DataInput @in, FSNamesystem
                                                             fsNamesys, int imgVersion)
        {
            byte[] name    = ReadBytes(@in);
            long   inodeId = NameNodeLayoutVersion.Supports(LayoutVersion.Feature.AddInodeId, imgVersion
                                                            ) ? @in.ReadLong() : fsNamesys.dir.AllocateNewInodeId();
            short blockReplication   = @in.ReadShort();
            long  modificationTime   = @in.ReadLong();
            long  preferredBlockSize = @in.ReadLong();
            int   numBlocks          = @in.ReadInt();

            BlockInfoContiguous[] blocks = new BlockInfoContiguous[numBlocks];
            Block blk = new Block();
            int   i   = 0;

            for (; i < numBlocks - 1; i++)
            {
                blk.ReadFields(@in);
                blocks[i] = new BlockInfoContiguous(blk, blockReplication);
            }
            // last block is UNDER_CONSTRUCTION
            if (numBlocks > 0)
            {
                blk.ReadFields(@in);
                blocks[i] = new BlockInfoContiguousUnderConstruction(blk, blockReplication, HdfsServerConstants.BlockUCState
                                                                     .UnderConstruction, null);
            }
            PermissionStatus perm          = PermissionStatus.Read(@in);
            string           clientName    = ReadString(@in);
            string           clientMachine = ReadString(@in);
            // We previously stored locations for the last block, now we
            // just record that there are none
            int numLocs = @in.ReadInt();

            System.Diagnostics.Debug.Assert(numLocs == 0, "Unexpected block locations");
            // Images in the pre-protobuf format will not have the lazyPersist flag,
            // so it is safe to pass false always.
            INodeFile file = new INodeFile(inodeId, name, perm, modificationTime, modificationTime
                                           , blocks, blockReplication, preferredBlockSize, unchecked ((byte)0));

            file.ToUnderConstruction(clientName, clientMachine);
            return(file);
        }