Commit 8e131041 authored by Thomas Schmitt's avatar Thomas Schmitt

New options -mount and -mount_cmd

parent e7ab799c
......@@ -2,7 +2,7 @@
.\" First parameter, NAME, should be all caps
.\" Second parameter, SECTION, should be 1-8, maybe w/ subsection
.\" other parameters are allowed: see man(7), man(1)
.TH XORRISO 1 "Nov 28, 2008"
.TH XORRISO 1 "Dec 05, 2008"
.\" Please adjust this date whenever revising the manpage.
.\"
.\" Some roff macros, for reference:
......@@ -547,7 +547,8 @@ address. The following entities are defined:
.br
"lba" or "sbsector" with a number as of a line "ISO ...", column "sbsector".
.br
"volid" with a text as of a line "ISO ...", column "Volume Id".
"volid" with a search pattern for a text as of a line "ISO ...",
column "Volume Id".
.br
Adressing a non-existing entity or one which does not represent an ISO
image will either abandon -indev or at least lead to a blank image.
......@@ -1791,6 +1792,34 @@ to be the most recent real session then.
Some read-only drives and media show no usable session history at all.
Eventually option -rom_toc_scan might help.
.TP
\fB\-mount_cmd\fR drive entity id command_form
Print to the result channel an appropriate command line for mounting the
ISO session which is depicted by drive, entity and id. The id can be a block
address with entity "sbsector", a track number with "track", a session number
with "session", a volume id search pattern with "volid", or any text with
"auto". See also option -load.
.br
drive can be "indev", "outdev" or the address of a not yet aquired drive.
Prefix "stdio:" for non MMC drives is not mandatory.
.br
command_form is either "linux:"path , or "freebsd:"path, or "shell:"command,
or a path.
The path will be used as moint point and has already to exist as directory.
A command line with suitable options is then generated.
If no recognizable prefix is given then xorriso guesses on which kind of
system it runs and uses the whole command_form as path.
.br
If shell:command is given, then xorriso will substitute in the command text
the following parameter names:
.br
"%device%" will be substituted by the mountable device path of the drive
address.
.br
"%sbsector%" will be substituted by the session start sector.
.br
"%track%", "%session%", "%volid%" will be substituted by track number,
session number, resp. volume id of the depicted session.
.TP
\fB\-print_size\fR
Print the foreseeable consumption of 2048 byte blocks
by next -commit. This can last a while as a -commit gets
......@@ -2168,6 +2197,14 @@ Read the content of a ISO data file and write it into a data file on disk
beginning at the byte_offset. Write at most byte_count bytes.
This is the inverse of option -cut_out.
.TP
\fB\-mount\fR drive entity id command_form
Produce the same line as -mount_cmd and then execute it as shell command
after giving up the depicted drive.
This demands -osirrox to be enabled and normally will succeed only for the
superuser. For safety reasons it will refuse to execute the command line
if it stems from command_form shell:command or if setuid or setgid are in
effect. In these cases -mount will default to -mount_cmd and a SORRY event.
.TP
.B Command compatibility emulations:
.PP
Writing of ISO 9660 on CD is traditionally done by program mkisofs
......@@ -2499,14 +2536,27 @@ which shall be able to use the drives with xorriso.
2 -dev '/dev/sr2' rwrw-- : 'PHILIPS ' 'SPD3300L'
.SS
.B Blank media and compose a new ISO image as batch run
Aquire drive /dev/sr2, blank media resp. invalidate existing ISO image.
Add the files from hard disk directories /home/me/sounds and /pictures.
Omit some unwanted stuff by removing it from the image directory tree.
Re-add some wanted stuff.
Aquire drive /dev/sr2, make media ready for writing a new image,
fill the image with the files from hard disk directories /home/me/sounds
and /home/me/pictures.
.br
Because no -dialog "on" is given, the program will then end by committing the
Because no -dialog "on" is given, the program will then end by writing the
session to media.
.br
\fB$\fR xorriso -outdev /dev/sr2 \\
.br
-blank as_needed \\
.br
-map /home/me/sounds /sounds \\
.br
-map /home/me/pictures /pictures
.br
.br
The ISO image may be shaped in a more elaborate way like the following:
Omit some unwanted stuff by removing it from the image directory tree.
Re-add some wanted stuff.
.br
\fB$\fR cd /home/me
.br
\fB$\fR xorriso -outdev /dev/sr2 \\
......@@ -2790,13 +2840,20 @@ This makes sense if the full backup leaves substantial remaining capacity
on media and if the expected changes are much smaller than the full backup.
An update run will probably save no time but last longer than a full backup.
.br
With \fBmount\fR option -o \fB"sbsector="\fR on Linux resp. \fB-s\fR on FreeBSD
With \fBmount\fR option \fB-o "sbsector="\fR on Linux resp. \fB-s\fR on FreeBSD
it is possible to access the session trees which represent the older backup
versions. With CD media, Linux mount accepts session numbers directly by
its option "session=".
.br
Multi-session media and most overwriteable media written by xorriso can tell
the sbsectors of their sessions by xorriso option -toc.
Used after -commit the following option prints the matching mount command for
the newly written session (here for mount point /mnt):
.br
-mount_cmd "indev" "auto" "auto" /mnt
.br
Options -mount_cmd and -mount are also able to produce the mount commands for
older sessions in the table-of-content.
.br
Sessions on multi-session media are separated by several MB of unused blocks.
So with small sessions the payload capacity can become substantially lower
......@@ -2821,7 +2878,7 @@ First check which backup sessions are on the media:
Then load the desired session and copy the file trees to disk.
Avoid to eventually create /home/thomas/restored without rwx-permission.
.br
\fB$\fR xorriso -load volid PROJECTS_MAIL_2008_06_19_205956 \\
\fB$\fR xorriso -load volid 'PROJECTS_MAIL_2008_06_19*' \\
.br
-indev /dev/sr0 \\
.br
......
This diff is collapsed.
......@@ -533,6 +533,13 @@ int Xorriso_option_mark(struct XorrisO *xorriso, char *mark, int flag);
int Xorriso_option_mkdiri(struct XorrisO *xorriso, int argc, char **argv,
int *idx, int flag);
/* Option -mount */
/* @param bit0= print mount command to result channel rather than performing it
*/
int Xorriso_option_mount(struct XorrisO *xorriso, char *dev, char *adr_mode,
char *adr, char *cmd, int flag);
/* Option -mv alias -mvi */
int Xorriso_option_mvi(struct XorrisO *xorriso, int argc, char **argv,
int *idx, int flag);
......
......@@ -593,6 +593,11 @@ int Xorriso_open_job_data_to(struct XorrisO *xorriso,
int Xorriso_no_findjob(struct XorrisO *xorriso, char *cmd, int flag);
int Xorriso_make_mount_cmd(struct XorrisO *xorriso, char *cmd,
int lba, int track, int session, char *volid,
char *devadr, char result[SfileadrL], int flag);
int Sfile_str(char target[SfileadrL], char *source, int flag);
double Sfile_microtime(int flag);
......
#define Xorriso_timestamP "2008.12.05.171005"
#define Xorriso_timestamP "2008.12.05.171700"
......@@ -20,6 +20,7 @@
#include <time.h>
#include <fcntl.h>
#include <utime.h>
#include <wait.h>
/* for -charset */
#include <iconv.h>
......@@ -524,7 +525,7 @@ int Xorriso_aquire_drive(struct XorrisO *xorriso, char *adr, int flag)
dinfo= out_dinfo;
} else if((flag&3)==2 && xorriso->in_drive_handle!=NULL) {
ret= Xorriso_get_drive_handles(xorriso, &in_dinfo, &in_drive,
"on attempt to compare new indev with outdev", 0);
"on attempt to compare new outdev with indev", 0);
if(ret<=0)
goto ex;
ret= burn_drive_equals_adr(in_drive, libburn_adr, 1);
......@@ -8412,3 +8413,168 @@ int Xorriso_get_relax_text(struct XorrisO *xorriso, char mode[1024],
}
/**
@param flag bit0= print mount command to result channel rather than
performing it
*/
int Xorriso_mount(struct XorrisO *xorriso, char *dev, int adr_mode,
char *adr_value, char *cmd, int flag)
{
int ret, lba, track, session, params_flag= 0, is_safe= 0, is_extra_drive= 0;
int give_up= 0;
char volid[33], *devadr, mount_command[SfileadrL], adr_data[163], *adr_pt;
char *dev_path, libburn_adr[BURN_DRIVE_ADR_LEN + SfileadrL];
char sfe[5 * SfileadrL], *dpt;
struct stat stbuf;
struct burn_drive_info *dinfo= NULL;
struct burn_drive *drive= NULL;
devadr= dev;
adr_pt= adr_value;
if(strcmp(dev, "indev") == 0) {
ret= Xorriso_get_drive_handles(xorriso, &dinfo, &drive,
"on attempt to perform -mount \"indev\"", 0);
if(ret<=0)
goto ex;
devadr= xorriso->indev;
if(xorriso->in_drive_handle == xorriso->out_drive_handle)
give_up= 3;
else
give_up= 1;
} else if(strcmp(dev, "outdev") == 0) {
ret= Xorriso_get_drive_handles(xorriso, &dinfo, &drive,
"on attempt to perform -mount \"outdev\"",
2);
if(ret<=0)
goto ex;
devadr= xorriso->outdev;
if(xorriso->in_drive_handle == xorriso->out_drive_handle)
give_up= 3;
else
give_up= 2;
} else {
is_extra_drive= 1;
dev_path= dev;
if(strncmp(dev_path, "stdio:", 6) == 0)
dev_path+= 6;
/* do only accept regular files and block devices */
ret= stat(dev_path, &stbuf);
if(ret == -1) {
sprintf(xorriso->info_text, "Cannot determine properties of file %s",
Text_shellsafe(dev_path, sfe, 0));
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
ret= 0; goto ex;
}
if(!(S_ISREG(stbuf.st_mode) || S_ISBLK(stbuf.st_mode))) {
sprintf(xorriso->info_text,
"File object is not suitable as mount device: %s",
Text_shellsafe(dev_path, sfe, 0));
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
ret= 0; goto ex;
}
/* Aquire drive as direct libburn address or via stdio: prefix */
ret= burn_drive_convert_fs_adr(dev, libburn_adr);
Xorriso_process_msg_queues(xorriso,0);
if(ret < 0)
{ret= -1; goto ex;}
if(ret == 0 && strncmp(dev, "stdio:", 6) != 0)
sprintf(libburn_adr, "stdio:%s", dev);
ret= isoburn_drive_aquire(&dinfo, libburn_adr, 1);
Xorriso_process_msg_queues(xorriso,0);
if(ret <= 0)
{ret= 0; goto ex;}
drive= dinfo[0].drive;
}
if(adr_mode == 4 && strlen(adr_pt) <= 80) {
ret= Xorriso__bourne_to_reg(adr_pt, adr_data, 0);
if(ret == 1) {
params_flag|= 4;
adr_pt= adr_data;
}
}
ret= isoburn_get_mount_params(drive, adr_mode, adr_pt, &lba, &track,
&session, volid, params_flag);
Xorriso_process_msg_queues(xorriso,0);
if(ret <= 0)
goto ex;
if(session <= 0 || track <= 0 || ret == 2) {
Xorriso_msgs_submit(xorriso, 0,
"-mount : Given address does not point to an ISO 9660 session",
0, "FAILURE", 0);
ret= 0; goto ex;
}
if(strstr(devadr, "stdio:") == devadr)
devadr+= 6;
ret= Xorriso_make_mount_cmd(xorriso, cmd, lba, track, session, volid, devadr,
mount_command, 0);
if(ret <= 0)
goto ex;
if(ret == 2)
is_safe= 1;
if(is_extra_drive) {
isoburn_drive_release(drive, 0);
burn_drive_info_free(dinfo);
drive= NULL;
} else if(give_up > 0 && !(flag & 1)) {
Xorriso_give_up_drive(xorriso, give_up);
if(ret <= 0)
goto ex;
}
Xorriso_process_msg_queues(xorriso,0);
sprintf(xorriso->info_text, "Volume id : %s\n",
Text_shellsafe(volid, sfe, 0));
Xorriso_info(xorriso, 0);
if(flag & 1) {
sprintf(xorriso->result_line, "%s\n", mount_command);
Xorriso_result(xorriso,0);
} else {
sprintf(xorriso->info_text, "Mount command: %s\n", mount_command);
Xorriso_info(xorriso, 0);
if(geteuid() != getuid() || getgid() != getegid()) {
Xorriso_msgs_submit(xorriso, 0,
"-mount : Detected own setuid/gid identity. Will not perform mount command.",
0, "SORRY", 0);
sprintf(xorriso->result_line, "%s\n", mount_command);
Xorriso_result(xorriso,0);
} else if(!is_safe) {
Xorriso_msgs_submit(xorriso, 0,
"-mount : Will not perform mount command which stems from command template.",
0, "SORRY", 0);
sprintf(xorriso->result_line, "%s\n", mount_command);
Xorriso_result(xorriso,0);
} else {
/* >>> find safer way to perform command */;
ret= system(mount_command);
if(WIFEXITED(ret) && WEXITSTATUS(ret) != 0) {
sprintf(xorriso->info_text,
"-mount : mount command failed with exit value %d",
(int) WEXITSTATUS(ret));
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
ret= 0; goto ex;
}
sprintf(xorriso->info_text, "Mounted session %d of device %s",
session, Text_shellsafe(dev_path, sfe, 0));
dpt= strchr(cmd, ':');
if(dpt == NULL)
dpt= cmd;
sprintf(xorriso->info_text + strlen(xorriso->info_text),
" as directory %s\n", Text_shellsafe(dpt + 1, sfe, 0));
Xorriso_info(xorriso, 0);
}
}
ret= 1;
ex:;
if(is_extra_drive && drive != NULL) {
isoburn_drive_release(drive, 0);
burn_drive_info_free(dinfo);
Xorriso_process_msg_queues(xorriso,0);
}
return(ret);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment