Skip to content
Snippets Groups Projects
Commit fb484e94 authored by Pekka Enberg's avatar Pekka Enberg
Browse files

cpio: Symbolic link support


Add symbolic link support to cpiod.so parser.  As OSv does not yet
support symlinks, the files are never created on the filesystem.

This is needed for streaming rpm2cpio to OSv guest.

Reviewed-by: default avatarNadav Har'El <nyh@cloudius-systems.com>
Signed-off-by: default avatarPekka Enberg <penberg@cloudius-systems.com>
parent 06625d1c
No related branches found
No related tags found
No related merge requests found
......@@ -96,6 +96,13 @@ bool cpio_in::parse_one(istream& is, cpio_in& out)
out.add_file(name, file);
break;
}
case C_ISLNK: {
unique_ptr<char[]> targetbuf{new char[filesize]};
is.read(targetbuf.get(), filesize);
string target{targetbuf.get(), filesize};
out.add_symlink(name, target);
break;
}
default:
cout << name << ": unknown type " << type << "\n";
is.ignore(filesize);
......
......@@ -18,6 +18,7 @@ class cpio_in {
public:
virtual ~cpio_in();
virtual void add_file(std::string name, std::istream& is) = 0;
virtual void add_symlink(std::string oldpath, std::string newpath) = 0;
public:
static void parse(std::istream& is, cpio_in& out);
private:
......
......@@ -34,6 +34,9 @@ public:
ofstream os(name);
os << is.rdbuf();
}
virtual void add_symlink(string oldpath, string newpath) override {
cout << "Skipping symlink " << oldpath << "...\n";
}
private:
std::string _prefix;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment