From: Michael Vrable Date: Mon, 14 May 2007 20:15:40 +0000 (-0700) Subject: Various minor tweaks to the metadata format. X-Git-Url: http://git.vrable.net/?p=cumulus.git;a=commitdiff_plain;h=25dc252eb3c3db9fe48ffb074cd66aa37a216fbc Various minor tweaks to the metadata format. --- diff --git a/restore.pl b/restore.pl index e7bb5ff..be94078 100755 --- a/restore.pl +++ b/restore.pl @@ -266,13 +266,14 @@ sub process_file { # 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"; @@ -371,8 +372,8 @@ print "Source directory: $OBJECT_DIR\n" if $VERBOSE; open DESCRIPTOR, "<", $descriptor or die "Cannot open backup descriptor file $descriptor: $!"; my $line = ; -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; diff --git a/scandir.cc b/scandir.cc index 29cbc44..0990bda 100644 --- a/scandir.cc +++ b/scandir.cc @@ -6,6 +6,8 @@ #include #include #include +#include +#include #include #include #include @@ -187,12 +189,20 @@ void scanfile(const string& path) 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) { @@ -346,13 +356,13 @@ int main(int argc, char *argv[]) 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::iterator i = segment_list.begin(); i != segment_list.end(); ++i) { descriptor << " " << *i << "\n";