Git-Url: http://git.frugalware.org/gitweb/gitweb.cgi?p=fvbe.git;a=commitdiff;h=66df1ac3228489759410d21f434201e19d4ca9f1
commit 66df1ac3228489759410d21f434201e19d4ca9f1 Author: James Buren <[email protected]> Date: Thu Apr 11 17:42:00 2013 -0500 move isodevice detection to main module. mounting is still done later, but this will enable it to be filtered out from block device programs. diff --git a/src/local.h b/src/local.h index 5c1de4b..dc26fc3 100644 --- a/src/local.h +++ b/src/local.h @@ -75,6 +75,7 @@ struct global bool insetup; const char *hostroot; const char *guestroot; + char *isodevice; char **fstabdata; char *groups; }; diff --git a/src/main.c b/src/main.c index a1f0db6..10c1d77 100644 --- a/src/main.c +++ b/src/main.c @@ -17,6 +17,52 @@ #include "local.h" +static void find_iso(void) +{ + blkid_cache cache = 0; + blkid_dev_iterate iter = 0; + blkid_dev dev = 0; + char path[PATH_MAX] = {0}; + + if(blkid_get_cache(&cache,"/dev/null") != 0) + { + error("failed to create blkid cache"); + goto bail; + } + + if(blkid_probe_all(cache) != 0) + { + error("failed to probe blkid devices"); + goto bail; + } + + if(blkid_probe_all_removable(cache) != 0) + { + error("failed to probe removable blkid devices"); + goto bail; + } + + if((iter = blkid_dev_iterate_begin(cache)) == 0) + { + error("failed to create blkid dev iter"); + goto bail; + } + + while(blkid_dev_next(iter,&dev) == 0) + if(blkid_dev_has_tag(dev,"TYPE","iso9660") && blkid_dev_has_tag(dev,"LABEL","FVBE")) + strfcpy(path,sizeof(path),"%s",blkid_dev_devname(dev)); + + blkid_dev_iterate_end(iter); + + if(strlen(path) != 0) + g->isodevice = strdup(path); + +bail: + + if(cache != 0) + blkid_put_cache(cache); +} + static void global_cleanup(void) { char **p = 0; @@ -26,6 +72,8 @@ static void global_cleanup(void) if(g->logfile) fclose(g->logfile); + free(g->isodevice); + if(g->fstabdata != 0) { for( p = g->fstabdata ; *p != 0 ; ++p ) @@ -89,6 +137,8 @@ extern int main(int argc,char **argv) g->hostroot = "/"; g->guestroot = "/mnt/install"; + + find_iso(); } else { diff --git a/src/preconfig.c b/src/preconfig.c index dac22ad..a9b3d53 100644 --- a/src/preconfig.c +++ b/src/preconfig.c @@ -17,52 +17,6 @@ #include "local.h" -static inline bool preconfig_find_iso(char *path,size_t size) -{ - blkid_cache cache = 0; - blkid_dev_iterate iter = 0; - blkid_dev dev = 0; - - *path = 0; - - if(blkid_get_cache(&cache,"/dev/null") != 0) - { - error("failed to create blkid cache"); - goto bail; - } - - if(blkid_probe_all(cache) != 0) - { - error("failed to probe blkid devices"); - goto bail; - } - - if(blkid_probe_all_removable(cache) != 0) - { - error("failed to probe removable blkid devices"); - goto bail; - } - - if((iter = blkid_dev_iterate_begin(cache)) == 0) - { - error("failed to create blkid dev iter"); - goto bail; - } - - while(blkid_dev_next(iter,&dev) == 0) - if(blkid_dev_has_tag(dev,"TYPE","iso9660") && blkid_dev_has_tag(dev,"LABEL","FVBE")) - strfcpy(path,size,"%s",blkid_dev_devname(dev)); - - blkid_dev_iterate_end(iter); - -bail: - - if(cache != 0) - blkid_put_cache(cache); - - return (*path != 0); -} - static inline bool preconfig_copy_fdb(const char *fdb) { char old[PATH_MAX] = {0}; @@ -155,18 +109,17 @@ extern bool preconfig_mount_extra(void) static bool preconfig_prepare_source(void) { bool fvbe = infvbe(); - char iso[PATH_MAX] = {0}; char path[PATH_MAX] = {0}; struct stat st = {0}; char groups[LINE_MAX] = {0}; const char *source = "unknown"; - if(fvbe && preconfig_find_iso(iso,sizeof(iso))) + if(fvbe && g->isodevice != 0) { if(!mkdir_recurse(ISO_ROOT)) return false; - if(mount(iso,ISO_ROOT,"iso9660",MS_RDONLY,0) == -1) + if(mount(g->isodevice,ISO_ROOT,"iso9660",MS_RDONLY,0) == -1) { error(strerror(errno)); return false; _______________________________________________ Frugalware-git mailing list [email protected] http://frugalware.org/mailman/listinfo/frugalware-git
