Exemplo n.º 1
0
        public bool CloneDirectoryTlock(int srcfsid, String sourcedir, int destfsid, String destinationdir)
        {
            string destdirpath = ExtractParentPath(destinationdir);

            if (destdirpath == null)
            {
                return(false);
            }


            Inode_Info destdiri = inode_exists_internal(destfsid, destdirpath, "dclone1", false, false);

            if (destdiri == null)
            {
                return(false);
            }
            Inode_Info destdiri2 = inode_exists_internal(destfsid, destinationdir, "dclone2", false, false);

            if (destdiri2 != null)
            {
                return(false);
            }

            Inode_Info srcdirA = inode_exists_internal(srcfsid, sourcedir, "dclone3", true, false);

            if (srcdirA == null)
            {
                return(false);
            }

            int        count   = srcdirA.nodecount;
            int        pino    = destdiri.ino;
            List <int> inolist = NEXT_N_INODE_NUMBERS(destfsid, count);

            CDirectory newdir = REDDY.FSIDList[srcfsid].rootdir.clone_directory_tlock(sourcedir, destfsid, inolist, pino, destdirpath);

            if (newdir == null)
            {
                return(false);
            }

            newdir.rename_directory(ADFN(destinationdir));
            if (REDDY.FSIDList[destfsid].rootdir.insert_clonedirectory_tlock(destdirpath, newdir) == false)
            {
                //delete the wip.
                newdir.remove_orphan_directory();
                return(false);
            }
            return(true);
        }