Several directories and files in one session, added display of fifo

This commit is contained in:
Thomas Schmitt 2007-10-08 20:41:42 +00:00
parent f90b3a2342
commit 059f9ffceb

View File

@ -13,6 +13,8 @@
#include <getopt.h> #include <getopt.h>
#include <err.h> #include <err.h>
#include <string.h> #include <string.h>
#include <errno.h>
#include <sys/stat.h>
#include <libisofs/libisofs.h> #include <libisofs/libisofs.h>
@ -30,18 +32,32 @@ extern int optind;
#define With_graft_poinT 1 #define With_graft_poinT 1
static int graft_point(struct iso_volume *volume, const char *disc_path, static int graft_point(struct iso_volume *volume, const char *disk_path,
const char *img_path, struct iso_tree_radd_dir_behavior *behav) const char *img_path, struct iso_tree_radd_dir_behavior *behav)
{ {
char path[4096], *apt, *npt; char path[4096], *apt, *npt;
struct iso_tree_node_dir *dir; struct iso_tree_node_dir *dir;
struct iso_tree_node *node; struct iso_tree_node *node;
int done= 0; int done= 0, is_dir= 0;
struct stat stbuf;
strncpy(path, img_path, sizeof(path)-1); strncpy(path, img_path, sizeof(path)-1);
path[sizeof(path)-1]= 0; path[sizeof(path)-1]= 0;
apt= npt= path; apt= npt= path;
if(lstat(disk_path, &stbuf) == -1) {
fprintf(stderr, "Cannot determine attributes of '%s' : %s (%d)\n",
disk_path, (errno > 0 ? strerror(errno) : "unknown error"), errno);
return(0);
}
if(S_ISDIR(stbuf.st_mode))
is_dir= 1;
else if(!(S_ISREG(stbuf.st_mode) || S_ISLNK(stbuf.st_mode))) {
fprintf(stderr, "File object '%s' is of non-supported file type\n",
disk_path);
return(0);
}
dir= iso_volume_get_root(volume); dir= iso_volume_get_root(volume);
if(dir==NULL) { if(dir==NULL) {
fprintf(stderr, "While grafting '%s' : no root node available\n", img_path); fprintf(stderr, "While grafting '%s' : no root node available\n", img_path);
@ -75,11 +91,21 @@ static int graft_point(struct iso_volume *volume, const char *disc_path,
return(0); return(0);
} }
} }
if(done) if(done) {
iso_tree_radd_dir(dir, path, behav); if(is_dir) {
else iso_tree_radd_dir(dir, disk_path, behav);
} else {
node= iso_tree_add_node(dir, disk_path);
if(node == NULL) {
fprintf(stderr, "While grafting '%s'='%s' : libisofs_errno = %d\n",
img_path, disk_path, libisofs_errno);
}
}
} else
*npt= '/'; *npt= '/';
} }
fprintf(stderr, "NOTE: added %s '%s'='%s'\n", (is_dir ? "directory" : "node"),
img_path, disk_path);
return(1); return(1);
} }
@ -114,7 +140,9 @@ int main(int argc, char **argv)
int c; int c;
struct iso_tree_radd_dir_behavior behav = {0,0,0}; struct iso_tree_radd_dir_behavior behav = {0,0,0};
int flags=0; int flags=0;
int ret=0; int ret=0, i;
int size, free_bytes;
char *status_text;
while ((c = getopt(argc, argv, optstring)) != -1) { while ((c = getopt(argc, argv, optstring)) != -1) {
switch(c) { switch(c) {
@ -189,10 +217,12 @@ int main(int argc, char **argv)
#ifdef With_graft_poinT #ifdef With_graft_poinT
if (graft_point(iso_volset_get_volume(volset, 0), for (i = optind + 1; i < argc; i++) {
argv[optind+1], argv[optind+1], &behav) <= 0) { if (graft_point(iso_volset_get_volume(volset, 0),
fprintf(stderr, "Canot graft '%s'\n", argv[optind+1]); argv[i], argv[i], &behav) <= 0) {
goto exit_cleanup; fprintf(stderr, "Canot graft '%s'\n", argv[optind+1]);
goto exit_cleanup;
}
} }
#else #else
@ -230,20 +260,11 @@ int main(int argc, char **argv)
{ {
struct burn_write_opts *burn_options; struct burn_write_opts *burn_options;
struct burn_progress progress; struct burn_progress progress;
char reasons[BURN_REASONS_LEN];
burn_options = burn_write_opts_new(drive); burn_options = burn_write_opts_new(drive);
burn_drive_set_speed(drive, 0, 0); burn_drive_set_speed(drive, 0, 0);
burn_write_opts_set_underrun_proof(burn_options, 1); burn_write_opts_set_underrun_proof(burn_options, 1);
if (burn_write_opts_auto_write_type(burn_options, disc,
reasons, 0) == BURN_WRITE_NONE) {
fprintf(stderr,
"Failed to find a suitable write mode:\n%s\n", reasons);
ret = 1;
goto volset_cleanup;
}
/* ok, write the new track */ /* ok, write the new track */
isoburn_disc_write(burn_options, disc); isoburn_disc_write(burn_options, disc);
burn_write_opts_free(burn_options); burn_write_opts_free(burn_options);
@ -251,8 +272,19 @@ int main(int argc, char **argv)
while (burn_drive_get_status(drive, NULL) == BURN_DRIVE_SPAWNING) while (burn_drive_get_status(drive, NULL) == BURN_DRIVE_SPAWNING)
usleep(100002); usleep(100002);
while (burn_drive_get_status(drive, &progress) != BURN_DRIVE_IDLE) { while (burn_drive_get_status(drive, &progress)
printf("Writing: sector %d of %d\n", progress.sector, progress.sectors); != BURN_DRIVE_IDLE) {
printf("Writing: sector %d of %d",
progress.sector, progress.sectors);
ret = isoburn_get_fifo_status(drive, &size,
&free_bytes, &status_text);
if (ret > 0 )
printf(" [fifo %s, %2d%% fill]", status_text,
(int) (100.0 - 100.0 *
((double) free_bytes) /
(double) size));
printf("\n");
sleep(1); sleep(1);
} }
} }
@ -262,7 +294,8 @@ int main(int argc, char **argv)
if (isoburn_activate_session(drive) <= 0) { if (isoburn_activate_session(drive) <= 0) {
fprintf(stderr, "Ups, new vol desc write failed\n"); fprintf(stderr, "Ups, new vol desc write failed\n");
} }
ret= 0;
volset_cleanup:; volset_cleanup:;
/* /*
iso_volset_free(volset); iso_volset_free(volset);