mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-25 15:26:17 +02:00
* Preserve the executable bit.
This commit is contained in:
parent
54664b6fb7
commit
71cc3ceae5
1 changed files with 13 additions and 0 deletions
|
@ -119,6 +119,10 @@ static void dump(const string & path, DumpSink & sink)
|
|||
if (S_ISREG(st.st_mode)) {
|
||||
writeString("type", sink);
|
||||
writeString("regular", sink);
|
||||
if (st.st_mode & S_IXUSR) {
|
||||
writeString("executable", sink);
|
||||
writeString("", sink);
|
||||
}
|
||||
dumpContents(path, st.st_size, sink);
|
||||
}
|
||||
|
||||
|
@ -295,6 +299,15 @@ static void restore(const string & path, RestoreSource & source)
|
|||
restoreContents(fd, path, source);
|
||||
}
|
||||
|
||||
else if (s == "executable" && type == tpRegular) {
|
||||
readString(source);
|
||||
struct stat st;
|
||||
if (fstat(fd, &st) == -1)
|
||||
throw SysError("fstat");
|
||||
if (fchmod(fd, st.st_mode | (S_IXUSR | S_IXGRP | S_IXOTH)) == -1)
|
||||
throw SysError("fchmod");
|
||||
}
|
||||
|
||||
else if (s == "entry" && type == tpDirectory) {
|
||||
restoreEntry(path, source);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue