Using uname() rather than #ifdef __FreeBSD__

This commit is contained in:
Thomas Schmitt 2008-12-06 14:08:54 +00:00
parent ef834e0a11
commit b3089477fd
5 changed files with 73 additions and 14 deletions

View File

@ -90,6 +90,7 @@ or
#include <pwd.h>
#include <grp.h>
#include <signal.h>
#include <sys/utsname.h>
/* for -charset */
#include <iconv.h>
@ -1530,6 +1531,31 @@ int Wait_for_input(int fd, int microsec, int flag)
}
int System_uname(char **sysname, char **release, char **version,
char **machine, int flag)
{
int ret;
static struct utsname uts;
static int initialized= 0;
if(initialized == 0) {
ret= uname(&uts);
if(ret != 0)
initialized = -1;
}
if(initialized == -1)
return(0);
if(sysname != NULL)
*sysname= uts.sysname;
if(release != NULL)
*release= uts.release;
if(version != NULL)
*version= uts.version;
if(machine != NULL)
*machine= uts.machine;
return(1);
}
/* ------------------------------------------------------------------------ */
@ -10319,7 +10345,7 @@ int Xorriso_make_mount_cmd(struct XorrisO *xorriso, char *cmd,
{
int ret, reg_file= 0, is_safe= 0, sys_code= 0;
char form[6*SfileadrL], session_text[12], track_text[12], lba_text[12];
char *vars[5][2], sfe[5*SfileadrL], volid_sfe[5*80+1], *cpt;
char *vars[5][2], sfe[5*SfileadrL], volid_sfe[5*80+1], *cpt, *sysname;
struct stat stbuf;
if(strlen(cmd) > SfileadrL) {
@ -10345,11 +10371,22 @@ too_long:;
strcpy(form, cpt);
} else {
cpt= cmd;
#ifdef __FreeBSD__
sys_code= 2;
#else
sys_code= 1;
#endif
ret= System_uname(&sysname, NULL, NULL, NULL, 0);
if(ret <= 0) {
Xorriso_msgs_submit(xorriso, 0,
"-mount*: Cannot determine current system type",
0, "FAILURE", 0);
return(0);
} else if(strcmp(sysname, "FreeBSD") == 0) {
sys_code= 2;
} else if(strcmp(sysname, "Linux") == 0) {
sys_code= 1;
} else {
sprintf(xorriso->info_text, "-mount*: Unsupported system type %s",
Text_shellsafe(sysname, sfe, 0));
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
return(0);
}
}
if(sys_code == 1) { /* Linux */
@ -10364,10 +10401,19 @@ too_long:;
(Real CD drives look like /dev/cd0)
*/
if(reg_file) {
/* <<<
strcpy(form, "n=$(mdconfig -a -t vnode -f %device%)");
sprintf(form + strlen(form),
" && mount -t cd9660 -o noexec,nosuid -s %%sbsector%% \"$n\" %s",
Text_shellsafe(cmd+8, sfe, 0));
" && mount -t cd9660 -o noexec,nosuid -s %%sbsector%% /dev/\"$n\" %s",
Text_shellsafe(cmd+8, sfe, 0));
*/
Xorriso_msgs_submit(xorriso, 0,
"Detected regular file as mount device with FreeBSD style command.",
0, "FAILURE", 0);
Xorriso_msgs_submit(xorriso, 0,
"Command mdconfig -a -t vnode -f can create a device node which uses the file",
0, "HINT", 0);
return(0);
} else
sprintf(form,
"mount -t cd9660 -o noexec,nosuid -s %%sbsector%% %%device%% %s",

View File

@ -120,6 +120,9 @@ Can perform multi-session tasks as emulation of mkisofs and cdrecord.
Can restore single files and whole trees from ISO image to disk filesystem.
</LI>
<LI>
Can issue commands to mount older sessions on Linux or FreeBSD.
</LI>
<LI>
Can check media for damages and copy readable blocks to disk.
</LI>
<LI>
@ -430,15 +433,18 @@ Enhancements towards previous stable version xorriso-0.2.8.pl01:
<DD>Bug fixes towards xorriso-0.3.0.pl00:
<UL>
<LI>- none yet -</LI>
<LI>Options -extract and -extract_single were not disabled with -osirrox off
</LI>
<!--
<LI>- none yet -</LI>
-->
</UL>
</DD>
<DD>Enhancements towards stable version 0.3.0.pl00:
<UL>
<LI>- none yet -</LI>
<LI>New options -mount and -mount_cmd</LI>
<!--
<LI>- none yet -</LI>
-->
</UL>
</DD>

View File

@ -647,6 +647,9 @@ char *Ftypetxt(mode_t st_mode, int flag);
*/
char *Ftimetxt(time_t t, char timetext[40], int flag);
int System_uname(char **sysname, char **release, char **version,
char **machine, int flag);
struct DirseQ;

View File

@ -1 +1 @@
#define Xorriso_timestamP "2008.12.05.171700"
#define Xorriso_timestamP "2008.12.06.140828"

View File

@ -8421,10 +8421,10 @@ 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;
int give_up= 0, mount_chardev= 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;
char sfe[5 * SfileadrL], *dpt, *sysname= "";
struct stat stbuf;
struct burn_drive_info *dinfo= NULL;
struct burn_drive *drive= NULL;
@ -8466,7 +8466,11 @@ int Xorriso_mount(struct XorrisO *xorriso, char *dev, int adr_mode,
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))) {
ret= System_uname(&sysname, NULL, NULL, NULL, 0);
if(ret > 0 && strcmp(sysname, "FreeBSD") == 0)
mount_chardev= 1;
if(!(S_ISREG(stbuf.st_mode) || (S_ISBLK(stbuf.st_mode) && !mount_chardev)
|| (S_ISCHR(stbuf.st_mode) && !mount_chardev))) {
sprintf(xorriso->info_text,
"File object is not suitable as mount device: %s",
Text_shellsafe(dev_path, sfe, 0));