Make dvm_file_editor use ioall.c
This commit is contained in:
parent
af0bd7a9b4
commit
a750229be6
@ -1,8 +1,8 @@
|
||||
CC=gcc
|
||||
CFLAGS=-Wall
|
||||
CFLAGS=-Wall -I../common
|
||||
all: qubes_penctl qubes_add_pendrive_script qvm-open-in-dvm dvm_file_editor
|
||||
dvm_file_editor: dvm_file_editor.o
|
||||
$(CC) -o dvm_file_editor dvm_file_editor.o
|
||||
dvm_file_editor: dvm_file_editor.o ../common/ioall.o
|
||||
$(CC) -o dvm_file_editor dvm_file_editor.o ../common/ioall.o
|
||||
qubes_penctl: qubes_penctl.o
|
||||
$(CC) -o qubes_penctl qubes_penctl.o -lxenstore
|
||||
qubes_add_pendrive_script: qubes_add_pendrive_script.o
|
||||
|
@ -4,44 +4,9 @@
|
||||
#include <stdlib.h>
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include <ioall.h>
|
||||
#include "dvm2.h"
|
||||
|
||||
int write_all(int fd, void *buf, int size)
|
||||
{
|
||||
int written = 0;
|
||||
int ret;
|
||||
while (written < size) {
|
||||
ret = write(fd, (char *) buf + written, size - written);
|
||||
if (ret <= 0) {
|
||||
perror("write");
|
||||
return 0;
|
||||
}
|
||||
written += ret;
|
||||
}
|
||||
// fprintf(stderr, "sent %d bytes\n", size);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int read_all(int fd, void *buf, int size)
|
||||
{
|
||||
int got_read = 0;
|
||||
int ret;
|
||||
while (got_read < size) {
|
||||
ret = read(fd, (char *) buf + got_read, size - got_read);
|
||||
if (ret == 0) {
|
||||
fprintf(stderr, "EOF\n");
|
||||
return 0;
|
||||
}
|
||||
if (ret < 0) {
|
||||
perror("read");
|
||||
return 0;
|
||||
}
|
||||
got_read += ret;
|
||||
}
|
||||
// fprintf(stderr, "read %d bytes\n", size);
|
||||
return 1;
|
||||
}
|
||||
|
||||
char *get_filename()
|
||||
{
|
||||
char buf[DVM_FILENAME_SIZE];
|
||||
|
Loading…
Reference in New Issue
Block a user