/* * a. Check that the destination directory exists, and get its inode number * b. Allocate a new inode in the destination fsid. * c. clone the source file. * d. Insert into the destination. * e. If failed, do error handling. */ public bool CloneFileTLock(int srcfsid, String sourcefile, int destfsid, String destinationfile) { string destdirpath = ExtractParentPath(destinationfile); if (destdirpath == null) { DEFS.DEBUG("CLONEF", "couldnot parse parent path"); return(false); } Inode_Info destdiri = inode_exists_internal(destfsid, destdirpath, "clone", false, false); if (destdiri == null || destdiri.fa == FileAttributes.Normal) { DEFS.DEBUG("CLONEF", "destdir is absent or is a file"); return(false); } int pino = destdiri.ino; int newino = find_free_ino_bit(destfsid); CFile newfile = REDDY.FSIDList[srcfsid].rootdir.clone_file_tlock(sourcefile, destfsid, newino, pino, destinationfile); if (newfile == null) { DEFS.DEBUG("CLONEF", "failed to clone file " + sourcefile); return(false); } newfile.rename_file(ADFN(destinationfile)); if (REDDY.FSIDList[destfsid].rootdir.insert_clonefile_tlock(destdirpath, newfile) == false) { //delete the wip. newfile.remove_ondisk_data2(); return(false); } REDDY.FSIDList[destfsid].set_dirty(true); return(true); }