qvm-copy-to-vm: implement --ignore-symlinks option

Can be useful when copying to VM which doesn't support symlinks (or user
doesn't have privilege to create it).
This commit is contained in:
Marek Marczykowski-Górecki 2013-08-14 22:12:46 +02:00
parent 099971dcd5
commit 3cfd7f57b4
4 changed files with 11 additions and 4 deletions

View File

@ -18,6 +18,8 @@ enum {
PROGRESS_FLAG_DONE PROGRESS_FLAG_DONE
}; };
int ignore_symlinks = 0;
unsigned long crc32_sum; unsigned long crc32_sum;
int write_all_with_crc(int fd, void *buf, int size) int write_all_with_crc(int fd, void *buf, int size)
{ {
@ -143,7 +145,7 @@ int single_file_processor(char *filename, struct stat *st)
hdr.filelen = 0; hdr.filelen = 0;
write_headers(&hdr, filename); write_headers(&hdr, filename);
} }
if (S_ISLNK(mode)) { if (S_ISLNK(mode) && !ignore_symlinks) {
char name[st->st_size + 1]; char name[st->st_size + 1];
if (readlink(filename, name, sizeof(name)) != st->st_size) if (readlink(filename, name, sizeof(name)) != st->st_size)
gui_fatal("readlink %s", filename); gui_fatal("readlink %s", filename);
@ -227,6 +229,11 @@ int main(int argc, char **argv)
crc32_sum = 0; crc32_sum = 0;
cwd = getcwd(NULL, 0); cwd = getcwd(NULL, 0);
for (i = 1; i < argc; i++) { for (i = 1; i < argc; i++) {
if (strcmp(argv[i], "--ignore-symlinks")==0) {
ignore_symlinks = 1;
continue;
}
entry = get_abs_path(cwd, argv[i]); entry = get_abs_path(cwd, argv[i]);
do { do {

View File

@ -37,7 +37,7 @@ VM="$1"
shift shift
if [ $PROGRESS_TYPE = console ] ; then if [ $PROGRESS_TYPE = console ] ; then
export FILECOPY_TOTAL_SIZE=$(du --apparent-size -c "$@" | tail -1 | cut -f 1) export FILECOPY_TOTAL_SIZE=$(du --apparent-size -c -- "$@" 2> /dev/null | tail -1 | cut -f 1)
fi fi
exec /usr/lib/qubes/qrexec-client-vm $VM qubes.Filecopy /usr/lib/qubes/qfile-agent "$@" exec /usr/lib/qubes/qrexec-client-vm $VM qubes.Filecopy /usr/lib/qubes/qfile-agent "$@"

View File

@ -23,7 +23,7 @@
VM=$(qvm-mru-entry --title="File Copy" --text="Enter the destination domain name:" --mrufile "qvm-mru-filecopy") VM=$(qvm-mru-entry --title="File Copy" --text="Enter the destination domain name:" --mrufile "qvm-mru-filecopy")
if [ X$VM = X ] ; then exit 0 ; fi if [ X$VM = X ] ; then exit 0 ; fi
SIZE=$(du --apparent-size -c "$@" | tail -1 | cut -f 1) SIZE=$(du --apparent-size -c -- "$@" 2>/dev/null | tail -1 | cut -f 1)
export PROGRESS_TYPE=gui export PROGRESS_TYPE=gui

View File

@ -23,7 +23,7 @@
VM=$(kdialog -inputbox "Enter the VM name to send files to:") VM=$(kdialog -inputbox "Enter the VM name to send files to:")
if [ X$VM = X ] ; then exit 0 ; fi if [ X$VM = X ] ; then exit 0 ; fi
SIZE=$(du --apparent-size -c "$@" | tail -1 | cut -f 1) SIZE=$(du --apparent-size -c -- "$@" 2> /dev/null | tail -1 | cut -f 1)
REF=$(kdialog --progressbar "Copy progress") REF=$(kdialog --progressbar "Copy progress")
qdbus $REF org.freedesktop.DBus.Properties.Set "" maximum $SIZE qdbus $REF org.freedesktop.DBus.Properties.Set "" maximum $SIZE