diff --git a/cdrskin/cdrskin.1 b/cdrskin/cdrskin.1 index 47f294d..7944f5f 100644 --- a/cdrskin/cdrskin.1 +++ b/cdrskin/cdrskin.1 @@ -275,7 +275,12 @@ and device files which have the same SCSI address parameters (e.g. /dev/sg0). .br .PP Option --allow_emulated_drives enables addressing of pseudo-drives -which get emulated on top of a regular data file or a block device. +which get emulated on top of filesystem objects. Regular data files and +block devices result in pseudo-drives which behave much like DVD-RAM. +If the given address does not exist yet but its directory exists, then +it gets created as regular file. +Other file types like character devices or pipes result in pseudo-drives +which behave much like blank DVD-R. The target file address is given after prefix "stdio:". .br E.g.: dev=stdio:/tmp/my_pseudo_drive @@ -283,11 +288,15 @@ E.g.: dev=stdio:/tmp/my_pseudo_drive Warning: Superusers must take care not to spoil their hard disk via its raw block device (like /dev/hda or /dev/sd0). .br -Pseudo-drives behave much like DVD-RAM. They allow -dummy, nevertheless, and -their reply with --tell_media_space can be utopic. If the given address does -not exist yet but its directory exists, then it gets created as regular file -as soon as a write operation occurs. -Note: -dummy burn runs touch the file. +Addresses of the form "stdio:/dev/fd/" are treated special. The +number is read literally and used as open file descriptor. With +dev="stdio:/dev/fd/1" the normal standard output of the program is +redirected to stderr and the stream data of a burn run will appear on stdout. +.br +Not good for terminals ! Redirect it. +.br +Pseudo-drives allow -dummy. Their reply with --tell_media_space can be utopic. +Note: -dummy burn runs touch the file but do not modify its data content. .br .SH OPTIONS .TP diff --git a/cdrskin/cdrskin.c b/cdrskin/cdrskin.c index f6f113a..a541b34 100644 --- a/cdrskin/cdrskin.c +++ b/cdrskin/cdrskin.c @@ -1756,6 +1756,8 @@ struct CdrpreskiN { int demands_cdrecord_caps; int demands_cdrskin_caps; + int result_fd; + }; @@ -1815,6 +1817,7 @@ int Cdrpreskin_new(struct CdrpreskiN **preskin, int flag) o->fallback_program[0]= 0; o->demands_cdrecord_caps= 0; o->demands_cdrskin_caps= 0; + o->result_fd = -1; return(1); } @@ -2118,6 +2121,15 @@ ata_bus:; } +/** Set the eventual output fd for the result of Cdrskin_msinfo() +*/ +int Cdrpreskin_set_result_fd(struct CdrpreskiN *o, int result_fd, int flag) +{ + o->result_fd= result_fd; + return(1); +} + + #ifndef Cdrskin_extra_leaN /** Load content startup files into preskin cache */ @@ -2744,6 +2756,13 @@ final_checks:; int driveno,hret; char *adr,buf[Cdrskin_adrleN]; + if(strcmp(o->raw_device_adr,"stdio:-")==0) { + fprintf(stderr, + "cdrskin: SORRY : Cannot accept drive address \"stdio:-\".\n"); + fprintf(stderr, + "cdrskin: HINT : Use \"stdio:/dev/fd/1\" if you really want to write to stdout.\n"); + {ret= 0; goto ex;} + } adr= o->raw_device_adr; #ifndef Cdrskin_extra_leaN @@ -2807,6 +2826,9 @@ dev_too_long:; /* A60927 : note to myself : no "ret= 1;" here. It breaks --help , -version */ ex:; + /* Eventually replace current stdout by dup(1) from start of program */ + if(strcmp(o->device_adr,"stdio:/dev/fd/1")==0 && o->result_fd >= 0) + sprintf(o->device_adr,"stdio:/dev/fd/%d",o->result_fd); #ifndef Cdrskin_extra_leaN if(ret<=0 || !(flag&1)) @@ -2905,7 +2927,6 @@ struct CdrskiN { int do_checkdrive; int do_msinfo; - int msinfo_fd; char msifile[Cdrskin_strleN]; int do_atip; @@ -3076,7 +3097,6 @@ int Cdrskin_new(struct CdrskiN **skin, struct CdrpreskiN *preskin, int flag) o->do_load= 0; o->do_checkdrive= 0; o->do_msinfo= 0; - o->msinfo_fd= -1; o->msifile[0]= 0; o->do_atip= 0; o->do_blank= 0; @@ -3183,15 +3203,6 @@ int Cdrskin_destroy(struct CdrskiN **o, int flag) } -/** Set the eventual output fd for the result of Cdrskin_msinfo() -*/ -int Cdrskin_set_msinfo_fd(struct CdrskiN *skin, int result_fd, int flag) -{ - skin->msinfo_fd= result_fd; - return(1); -} - - /** Return the addresses of the drive. device_adr is the libburn persistent address of the drive, raw_adr is the address as given by the user. */ @@ -4266,6 +4277,10 @@ int Cdrskin_checkdrive(struct CdrskiN *skin, char *profile_name, int flag) if(ret==0) printf("%s\n","Emulated (null-drive)"); else if(ret==2) + printf("%s\n","Emulated (stdio-drive, 2k random read-write)"); + else if(ret==3) + printf("%s\n","Emulated (stdio-drive, sequential write-only)"); + else if(ret!=1) printf("%s\n","Emulated (stdio-drive)"); else #endif @@ -6085,8 +6100,8 @@ burn_failed:; free_space= burn_disc_available_space(drive,o); sprintf(msg,"%d\n",(int) (free_space/(off_t) 2048)); - if(skin->msinfo_fd>=0) { - write(skin->msinfo_fd,msg,strlen(msg)); + if(skin->preskin->result_fd>=0) { + write(skin->preskin->result_fd,msg,strlen(msg)); } else printf("%s",msg); } @@ -6417,9 +6432,9 @@ obtain_nwa:; } put_out:; - if(skin->msinfo_fd>=0) { + if(skin->preskin->result_fd>=0) { sprintf(msg,"%d,%d\n",lba,nwa); - write(skin->msinfo_fd,msg,strlen(msg)); + write(skin->preskin->result_fd,msg,strlen(msg)); } else printf("%d,%d\n",lba,nwa); @@ -7693,7 +7708,11 @@ int main(int argc, char **argv) /* For -msinfo: Redirect normal stdout to stderr */ for(i=1; i