From b25b64e526e281cd04719d8f0765b445241117e5 Mon Sep 17 00:00:00 2001 From: Pascal Rigaux Date: Wed, 5 Sep 2007 13:27:02 +0000 Subject: - if you give nfs directory xxx, try to use xxx/ARCH - handle cdroms with and without ARCH at the root and factorize the code into create_IMAGE_LOCATION() --- mdk-stage1/tools.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'mdk-stage1/tools.c') diff --git a/mdk-stage1/tools.c b/mdk-stage1/tools.c index 2909d2e60..6a024eedd 100644 --- a/mdk-stage1/tools.c +++ b/mdk-stage1/tools.c @@ -53,6 +53,26 @@ int image_has_stage2() access(IMAGE_LOCATION "/" LIVE_LOCATION_REL, R_OK) == 0; } +enum return_type create_IMAGE_LOCATION(char *location_full) +{ + struct stat statbuf; + int offset = strncmp(location_full, IMAGE_LOCATION_DIR, sizeof(IMAGE_LOCATION_DIR) - 1) == 0 ? sizeof(IMAGE_LOCATION_DIR) - 1 : 0; + char *with_arch = asprintf_("%s/%s", location_full, ARCH); + + log_message("trying %s", with_arch); + + if (stat(with_arch, &statbuf) == 0 && S_ISDIR(statbuf.st_mode)) + location_full = with_arch; + + log_message("assuming %s is a mirror tree", location_full + offset); + + unlink(IMAGE_LOCATION); + if (symlink(location_full + offset, IMAGE_LOCATION) != 0) + return RETURN_ERROR; + + return RETURN_OK; +} + int ramdisk_possible(void) { if (total_memory() > (IS_RESCUE ? MEM_LIMIT_RESCUE : MEM_LIMIT_DRAKX)) -- cgit v1.2.1