Support backup of sockets

This only works on Linux. Darwin does not allow mknod of a socket.
Have not tested BSD.
This commit is contained in:
2023-10-04 02:12:17 -05:00
committed by John K. Luebs
parent 73ca9794ab
commit 28efe91c3f
4 changed files with 33 additions and 19 deletions

View File

@@ -92,3 +92,18 @@ func (entry *Entry) RestoreEarlyDirFlags(path string) error {
func (entry *Entry) RestoreEarlyFileFlags(f *os.File) error {
return nil
}
func (entry *Entry) RestoreSpecial(fullPath string) error {
mode := entry.Mode & uint32(fileModeMask)
if entry.Mode&uint32(os.ModeNamedPipe) != 0 {
mode |= syscall.S_IFIFO
} else if entry.Mode&uint32(os.ModeCharDevice) != 0 {
mode |= syscall.S_IFCHR
} else if entry.Mode&uint32(os.ModeDevice) != 0 {
mode |= syscall.S_IFBLK
} else {
return nil
}
return syscall.Mknod(fullPath, mode, int(entry.GetRdev()))
}