# Restore mode, ownership, and any other metadata for the file. This is
# split out from the code above since the code is the same regardless of
# file type.
- my $atime = $info{atime} || time();
my $mtime = $info{mtime} || time();
- utime $atime, $mtime, $dest
- or warn "Unable to update atime/mtime for $dest";
+ utime time(), $mtime, $dest
+ or warn "Unable to update mtime for $dest";
- my $uid = $info{user} || -1;
- my $gid = $info{group} || -1;
+ my $uid = -1;
+ my $gid = -1;
+ $uid = $info{user} + 0 if defined $info{user};
+ $gid = $info{group} + 0 if defined $info{group};
chown $uid, $gid, $dest
or warn "Unable to change ownership for $dest";
open DESCRIPTOR, "<", $descriptor
or die "Cannot open backup descriptor file $descriptor: $!";
my $line = <DESCRIPTOR>;
-if ($line !~ m/^root: (\S+)$/) {
- die "Expected 'root:' specification in backup descriptor file";
+if ($line !~ m/^Root: (\S+)$/) {
+ die "Expected 'Root:' specification in backup descriptor file";
}
my $root = $1;
close DESCRIPTOR;
#include <dirent.h>
#include <errno.h>
#include <fcntl.h>
+#include <pwd.h>
+#include <grp.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
metadata << "name: " << uri_encode(path) << "\n";
file_info["mode"] = encode_int(stat_buf.st_mode & 07777);
- file_info["atime"] = encode_int(stat_buf.st_atime);
- file_info["ctime"] = encode_int(stat_buf.st_ctime);
file_info["mtime"] = encode_int(stat_buf.st_mtime);
file_info["user"] = encode_int(stat_buf.st_uid);
file_info["group"] = encode_int(stat_buf.st_gid);
+ struct passwd *pwd = getpwuid(stat_buf.st_uid);
+ if (pwd != NULL) {
+ file_info["user"] += " (" + uri_encode(pwd->pw_name) + ")";
+ }
+
+ struct group *grp = getgrgid(stat_buf.st_gid);
+ if (pwd != NULL) {
+ file_info["group"] += " (" + uri_encode(grp->gr_name) + ")";
+ }
+
char inode_type;
switch (stat_buf.st_mode & S_IFMT) {
root->checksum();
segment_list.insert(root->get_ref().get_segment());
- descriptor << "root: " << root->get_ref().to_string() << "\n";
+ descriptor << "Root: " << root->get_ref().to_string() << "\n";
strftime(desc_buf, sizeof(desc_buf), "%Y-%m-%d %H:%M:%S %z", &time_buf);
- descriptor << "time: " << desc_buf << "\n";
+ descriptor << "Date: " << desc_buf << "\n";
delete root;
- descriptor << "segments:\n";
+ descriptor << "Segments:\n";
for (std::set<string>::iterator i = segment_list.begin();
i != segment_list.end(); ++i) {
descriptor << " " << *i << "\n";