From b3089477fde855fc65c2410a05c162d3aa3a509c Mon Sep 17 00:00:00 2001 From: Thomas Schmitt Date: Sat, 6 Dec 2008 14:08:54 +0000 Subject: [PATCH] Using uname() rather than #ifdef __FreeBSD__ --- libisoburn/trunk/xorriso/xorriso.c | 62 +++++++++++++++++--- libisoburn/trunk/xorriso/xorriso_eng.html | 10 +++- libisoburn/trunk/xorriso/xorriso_private.h | 3 + libisoburn/trunk/xorriso/xorriso_timestamp.h | 2 +- libisoburn/trunk/xorriso/xorrisoburn.c | 10 +++- 5 files changed, 73 insertions(+), 14 deletions(-) diff --git a/libisoburn/trunk/xorriso/xorriso.c b/libisoburn/trunk/xorriso/xorriso.c index af1e3351..0bdb6437 100644 --- a/libisoburn/trunk/xorriso/xorriso.c +++ b/libisoburn/trunk/xorriso/xorriso.c @@ -90,6 +90,7 @@ or #include #include #include +#include /* for -charset */ #include @@ -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", diff --git a/libisoburn/trunk/xorriso/xorriso_eng.html b/libisoburn/trunk/xorriso/xorriso_eng.html index 867a4126..162867f9 100644 --- a/libisoburn/trunk/xorriso/xorriso_eng.html +++ b/libisoburn/trunk/xorriso/xorriso_eng.html @@ -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.
  • +Can issue commands to mount older sessions on Linux or FreeBSD. +
  • +
  • Can check media for damages and copy readable blocks to disk.
  • @@ -430,15 +433,18 @@ Enhancements towards previous stable version xorriso-0.2.8.pl01:
    Bug fixes towards xorriso-0.3.0.pl00:
      -
    • - none yet -
    • +
    • Options -extract and -extract_single were not disabled with -osirrox off +
    Enhancements towards stable version 0.3.0.pl00:
      -
    • - none yet -
    • +
    • New options -mount and -mount_cmd
    diff --git a/libisoburn/trunk/xorriso/xorriso_private.h b/libisoburn/trunk/xorriso/xorriso_private.h index d990e66b..f390b327 100644 --- a/libisoburn/trunk/xorriso/xorriso_private.h +++ b/libisoburn/trunk/xorriso/xorriso_private.h @@ -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; diff --git a/libisoburn/trunk/xorriso/xorriso_timestamp.h b/libisoburn/trunk/xorriso/xorriso_timestamp.h index cfc49598..017c26cf 100644 --- a/libisoburn/trunk/xorriso/xorriso_timestamp.h +++ b/libisoburn/trunk/xorriso/xorriso_timestamp.h @@ -1 +1 @@ -#define Xorriso_timestamP "2008.12.05.171700" +#define Xorriso_timestamP "2008.12.06.140828" diff --git a/libisoburn/trunk/xorriso/xorrisoburn.c b/libisoburn/trunk/xorriso/xorrisoburn.c index aca77c45..10dd4436 100644 --- a/libisoburn/trunk/xorriso/xorrisoburn.c +++ b/libisoburn/trunk/xorriso/xorrisoburn.c @@ -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));