func addSymlink(directory *filesystem.Directory, fileSystem, oldFS *FileSystem, name string, directoryPathName string, stat *syscall.Stat_t) error { inode, isNewInode := fileSystem.getSymlinkInode(stat) var symlink filesystem.Symlink symlink.Name = name symlink.InodeNumber = stat.Ino symlink.SetInode(inode) if isNewInode { err := scanSymlink(&symlink, fileSystem, directoryPathName) if err != nil { return err } if oldFS != nil && oldFS.SymlinkInodeTable != nil { if oldInode, found := oldFS.SymlinkInodeTable[stat.Ino]; found { if filesystem.CompareSymlinkInodes(inode, oldInode, nil) { inode = oldInode symlink.SetInode(inode) fileSystem.SymlinkInodeTable[stat.Ino] = inode } } } } directory.SymlinkList = append(directory.SymlinkList, &symlink) return nil }
func (decoderData *decoderData) addSymlink(header *tar.Header, parent *filesystem.Directory, name string) error { var newInode filesystem.SymlinkInode newInode.Uid = uint32(header.Uid) newInode.Gid = uint32(header.Gid) newInode.Symlink = header.Linkname decoderData.symlinkInodeTable[header.Name] = decoderData.nextInodeNumber decoderData.fileSystem.SymlinkInodeTable[decoderData.nextInodeNumber] = &newInode var newEntry filesystem.Symlink newEntry.Name = name newEntry.InodeNumber = decoderData.nextInodeNumber parent.SymlinkList = append(parent.SymlinkList, &newEntry) decoderData.nextInodeNumber++ return nil }
func (decoderData *decoderData) addHardlink(header *tar.Header, parent *filesystem.Directory, name string) error { header.Linkname = normaliseFilename(header.Linkname) if inum, ok := decoderData.regularInodeTable[header.Linkname]; ok { var newEntry filesystem.RegularFile newEntry.Name = name newEntry.InodeNumber = inum parent.RegularFileList = append(parent.RegularFileList, &newEntry) } else if inum, ok := decoderData.symlinkInodeTable[header.Linkname]; ok { var newEntry filesystem.Symlink newEntry.Name = name newEntry.InodeNumber = inum parent.SymlinkList = append(parent.SymlinkList, &newEntry) } else if inum, ok := decoderData.inodeTable[header.Linkname]; ok { var newEntry filesystem.File newEntry.Name = name newEntry.InodeNumber = inum parent.FileList = append(parent.FileList, &newEntry) } else { return errors.New(fmt.Sprintf("missing hardlink target: %s", header.Linkname)) } return nil }