1 /* cdbackup.c |
1 /* cdbackup.c |
2 Copyright (c) 2000-2006 Craig Condit, Stefan Hülswitt. |
2 Copyright (c) 2000-2010 Craig Condit, Stefan Hülswitt. |
3 |
3 |
4 Redistribution and use in source and binary forms, with or without |
4 Redistribution and use in source and binary forms, with or without |
5 modification, are permitted provided that the following conditions are met: |
5 modification, are permitted provided that the following conditions are met: |
6 |
6 |
7 1. Redistributions of source code must retain the above copyright notice, |
7 1. Redistributions of source code must retain the above copyright notice, |
92 return ptr; |
93 return ptr; |
93 } |
94 } |
94 |
95 |
95 void start_cdrecord(void) |
96 void start_cdrecord(void) |
96 { |
97 { |
97 char **args, **p, *exname; |
98 char **args, **p; |
98 int l; |
99 int l; |
99 |
100 |
100 if(!(p=args=calloc(cdrec_opt_count+32,sizeof(char *)))) |
101 if(!(p=args=calloc(cdrec_opt_count+32,sizeof(char *)))) |
101 serror("No memory for cdrecord args\n"); |
102 serror("No memory for cdrecord args\n"); |
102 |
103 |
103 if(dvd) exname="dvdrecord"; else exname="cdrecord"; |
104 *p++=exename; |
104 *p++=exname; |
|
105 |
105 |
106 if(virt_dump || dvd) { |
106 if(virt_dump || dvd) { |
107 *p++="-dao"; |
107 *p++="-dao"; |
108 *p++=make_arg("tsize=%ds",secs); |
108 *p++=make_arg("tsize=%ds",secs); |
109 } |
109 } |
126 fprintf(stderr,"%s: cdrecord command:",prg_name); |
126 fprintf(stderr,"%s: cdrecord command:",prg_name); |
127 for(p=args ; *p ; p++) fprintf(stderr," %s",*p); |
127 for(p=args ; *p ; p++) fprintf(stderr," %s",*p); |
128 fprintf(stderr,"\n"); |
128 fprintf(stderr,"\n"); |
129 } |
129 } |
130 |
130 |
131 execvp(exname,args); |
131 execvp(exename,args); |
132 error("Exec failed (cdrecord)"); |
132 error("Exec failed (cdrecord)"); |
133 } |
133 } |
134 |
134 |
135 long atip_cdrecord(void) |
135 long atip_cdrecord(void) |
136 { |
136 { |
137 char *cmd; |
137 char *cmd; |
138 FILE *p; |
138 FILE *p; |
139 long size=-1; |
139 long size=-1; |
140 |
140 |
141 asprintf(&cmd,"%srecord 2>&1 dev=%s -atip",dvd ? "dvd":"cd",cdr_dev); |
141 asprintf(&cmd,"%s 2>&1 dev=%s -atip",exename,cdr_dev); |
142 DEBUG("%s: cdrecord atip command: %s\n",prg_name,cmd); |
142 DEBUG("%s: cdrecord atip command: %s\n",prg_name,cmd); |
143 |
143 |
144 p=popen(cmd,"r"); |
144 p=popen(cmd,"r"); |
145 if(!p) fprintf(stderr,"%s: atip command failed\n",prg_name); |
145 if(!p) fprintf(stderr,"%s: atip command failed\n",prg_name); |
146 else { |
146 else { |
181 if(val) { |
181 if(val) { |
182 cd_speed=strtol(val,NULL,10); |
182 cd_speed=strtol(val,NULL,10); |
183 DEBUG("cdbackup: using speed %d from CDR_SPEED\n",cd_speed); |
183 DEBUG("cdbackup: using speed %d from CDR_SPEED\n",cd_speed); |
184 } |
184 } |
185 |
185 |
186 while ((i=getopt(argc,argv,"d:r:l:s:p:a:c:mvVXDCi:wR"))>0) { |
186 while ((i=getopt(argc,argv,"d:r:l:s:p:a:c:mvVXDCi:wRE:"))>0) { |
187 switch (i) { |
187 switch (i) { |
188 case 'V': fprintf(stderr,"cdbackup "VERSION" (compiled "__DATE__")\n" |
188 case 'V': fprintf(stderr,"cdbackup "VERSION" (compiled "__DATE__")\n" |
189 "Copyright (C) 2000-2004\n" |
189 "Copyright (C) 2000-2010\n" |
190 "This is free software; see the source for copying conditions.\n" |
190 "This is free software; see the source for copying conditions.\n" |
191 "There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A\n" |
191 "There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A\n" |
192 "PARTICULAR PURPOSE.\n"); |
192 "PARTICULAR PURPOSE.\n"); |
193 exit(0); |
193 exit(0); |
194 case 'v': verbose=1; break; |
194 case 'v': verbose=1; break; |
199 case 'r': cdr_dev=optarg; break; |
199 case 'r': cdr_dev=optarg; break; |
200 case 'a': cd_label=optarg; break; |
200 case 'a': cd_label=optarg; break; |
201 case 'C': crc=0; break; |
201 case 'C': crc=0; break; |
202 case 'i': virt_name=optarg; virtual=1; break; |
202 case 'i': virt_name=optarg; virtual=1; break; |
203 case 'w': virt_dump=1; break; |
203 case 'w': virt_dump=1; break; |
|
204 case 'E': exename=optarg; break; |
204 case 'R': dvd=1; |
205 case 'R': dvd=1; |
205 DEBUG("cdbackup: DVD mode enabled\n"); |
206 DEBUG("cdbackup: DVD mode enabled\n"); |
206 break; |
207 break; |
207 case 'D': verbose=1; debug=1; |
208 case 'D': verbose=1; debug=1; |
208 DEBUG("cdbackup: DEBUG output enabled ("VERSION")\n"); |
209 DEBUG("cdbackup: DEBUG output enabled ("VERSION")\n"); |
229 " -c COMMAND call COMMAND on disk change in multi-disk mode\n" |
230 " -c COMMAND call COMMAND on disk change in multi-disk mode\n" |
230 " -C disable checksum creation for datablocks\n" |
231 " -C disable checksum creation for datablocks\n" |
231 " -i IMAGE use virtual image IMAGE for recording\n" |
232 " -i IMAGE use virtual image IMAGE for recording\n" |
232 " -w dump virtual image to media\n" |
233 " -w dump virtual image to media\n" |
233 " -R enables DVD mode\n" |
234 " -R enables DVD mode\n" |
|
235 " -E EXE set alternative cdrecord executable\n" |
234 " -v be verbose\n" |
236 " -v be verbose\n" |
235 " -D enable DEBUG output\n" |
237 " -D enable DEBUG output\n" |
236 " -V prints version & exits\n" |
238 " -V prints version & exits\n" |
237 " -- pass rest of commandline to cdrecord\n" |
239 " -- pass rest of commandline to cdrecord\n" |
238 "\n", prg_name); |
240 "\n", prg_name); |