FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > ArchLinux > ArchLinux User Repository

 
 
LinkBack Thread Tools
 
Old 05-01-2010, 11:29 PM
David Cantrell
 
Default Find stage2 install.img on local hd installs

If the user does not provide an hd directory that ends with ".img",
append "/images/install.img".

Use glib string functions consistently throughout the mountHardDrive()
function and glib memory functions.

Related: rhbz#522064
---
loader/hdinstall.c | 47 +++++++++++++++++++++++++++--------------------
1 files changed, 27 insertions(+), 20 deletions(-)

diff --git a/loader/hdinstall.c b/loader/hdinstall.c
index 4397dc2..3d5e4f5 100644
--- a/loader/hdinstall.c
+++ b/loader/hdinstall.c
@@ -132,31 +132,37 @@ char * mountHardDrive(struct installMethod * method,
newtGrid entryGrid, grid, buttons;

int done = 0;
- char * dir = strdup("");
+ char * dir = g_strdup("");
char * tmpDir;
char * url = NULL;
- char * buf, *substr;
+ char * buf;
int numPartitions;

char **partition_list;
char *selpart;
char *kspartition = NULL, *ksdirectory = NULL;
+ char *imgpath = "/images/install.img";

/* handle kickstart/stage2= data first if available */
if (loaderData->method == METHOD_HD && loaderData->stage2Data) {
kspartition = ((struct hdInstallData *)loaderData->stage2Data)->partition;
- ksdirectory = ((struct hdInstallData *)loaderData->stage2Data)->directory;
- logMessage(INFO, "partition is %s, dir is %s", kspartition, ksdirectory);
+ if (kspartition) {
+ kspartition = g_strdup(kspartition);
+ }

- /* if exist, duplicate */
- if (kspartition)
- kspartition = strdup(kspartition);
+ ksdirectory = ((struct hdInstallData *)loaderData->stage2Data)->directory;
if (ksdirectory) {
- ksdirectory = strdup(ksdirectory);
+ if (g_strrstr(ksdirectory, ".img")) {
+ ksdirectory = g_strdup(ksdirectory);
+ } else {
+ ksdirectory = g_strconcat(ksdirectory, imgpath, NULL);
+ }
} else {
- ksdirectory = strdup("/images/install.img");
+ ksdirectory = g_strdup(imgpath);
}

+ logMessage(INFO, "partition is %s, dir is %s", kspartition, ksdirectory);
+
if (!kspartition || !ksdirectory) {
logMessage(ERROR, "missing partition or directory specification");
loaderData->method = -1;
@@ -178,8 +184,8 @@ char * mountHardDrive(struct installMethod * method,
if (loaderData->inferredStage2)
loaderData->invalidRepoParam = 1;
} else {
- free(kspartition);
- free(ksdirectory);
+ g_free(kspartition);
+ g_free(ksdirectory);
return url;
}
}
@@ -237,7 +243,7 @@ char * mountHardDrive(struct installMethod * method,
/* if we had ks data around use it to prime entry, then get rid of it*/
if (kspartition) {
newtListboxSetCurrentByKey(listbox, kspartition);
- free(kspartition);
+ g_free(kspartition);
kspartition = NULL;
}

@@ -249,7 +255,7 @@ char * mountHardDrive(struct installMethod * method,
/* if we had ks data around use it to prime entry, then get rid of it*/
if (ksdirectory) {
newtEntrySet(dirEntry, ksdirectory, 1);
- free(ksdirectory);
+ g_free(ksdirectory);
ksdirectory = NULL;
}

@@ -282,12 +288,12 @@ char * mountHardDrive(struct installMethod * method,

selpart = newtListboxGetCurrent(listbox);

- free(dir);
+ g_free(dir);
if (tmpDir && *tmpDir) {
/* Protect from form free. */
- dir = strdup(tmpDir);
+ dir = g_strdup(tmpDir);
} else {
- dir = strdup("");
+ dir = g_strdup("");
}

newtFormDestroy(form);
@@ -306,9 +312,10 @@ char * mountHardDrive(struct installMethod * method,
/* If the user-provided URL points at a repo instead of a stage2
* image, fix that up now.
*/
- substr = strstr(dir, ".img");
- if (!substr || (substr && *(substr+4) != '')) {
- checked_asprintf(&dir, "%s/images/install.img", dir);
+ if (g_strrstr(dir, ".img") == NULL) {
+ char *tmp = g_strconcat(dir, imgpath, NULL);
+ g_free(dir);
+ dir = tmp;
}

loaderData->invalidRepoParam = 1;
@@ -324,7 +331,7 @@ char * mountHardDrive(struct installMethod * method,
done = 1;
}

- free(dir);
+ g_free(dir);

return url;
}
--
1.6.6.1

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@redhat.com
https://www.redhat.com/mailman/listinfo/anaconda-devel-list
 
Old 05-03-2010, 08:47 AM
Hans de Goede
 
Default Find stage2 install.img on local hd installs

Ack.

On 05/02/2010 01:29 AM, David Cantrell wrote:

If the user does not provide an hd directory that ends with ".img",
append "/images/install.img".

Use glib string functions consistently throughout the mountHardDrive()
function and glib memory functions.

Related: rhbz#522064
---
loader/hdinstall.c | 47 +++++++++++++++++++++++++++--------------------
1 files changed, 27 insertions(+), 20 deletions(-)

diff --git a/loader/hdinstall.c b/loader/hdinstall.c
index 4397dc2..3d5e4f5 100644
--- a/loader/hdinstall.c
+++ b/loader/hdinstall.c
@@ -132,31 +132,37 @@ char * mountHardDrive(struct installMethod * method,
newtGrid entryGrid, grid, buttons;

int done = 0;
- char * dir = strdup("");
+ char * dir = g_strdup("");
char * tmpDir;
char * url = NULL;
- char * buf, *substr;
+ char * buf;
int numPartitions;

char **partition_list;
char *selpart;
char *kspartition = NULL, *ksdirectory = NULL;
+ char *imgpath = "/images/install.img";

/* handle kickstart/stage2= data first if available */
if (loaderData->method == METHOD_HD&& loaderData->stage2Data) {
kspartition = ((struct hdInstallData *)loaderData->stage2Data)->partition;
- ksdirectory = ((struct hdInstallData *)loaderData->stage2Data)->directory;
- logMessage(INFO, "partition is %s, dir is %s", kspartition, ksdirectory);
+ if (kspartition) {
+ kspartition = g_strdup(kspartition);
+ }

- /* if exist, duplicate */
- if (kspartition)
- kspartition = strdup(kspartition);
+ ksdirectory = ((struct hdInstallData *)loaderData->stage2Data)->directory;
if (ksdirectory) {
- ksdirectory = strdup(ksdirectory);
+ if (g_strrstr(ksdirectory, ".img")) {
+ ksdirectory = g_strdup(ksdirectory);
+ } else {
+ ksdirectory = g_strconcat(ksdirectory, imgpath, NULL);
+ }
} else {
- ksdirectory = strdup("/images/install.img");
+ ksdirectory = g_strdup(imgpath);
}

+ logMessage(INFO, "partition is %s, dir is %s", kspartition, ksdirectory);
+
if (!kspartition || !ksdirectory) {
logMessage(ERROR, "missing partition or directory specification");
loaderData->method = -1;
@@ -178,8 +184,8 @@ char * mountHardDrive(struct installMethod * method,
if (loaderData->inferredStage2)
loaderData->invalidRepoParam = 1;
} else {
- free(kspartition);
- free(ksdirectory);
+ g_free(kspartition);
+ g_free(ksdirectory);
return url;
}
}
@@ -237,7 +243,7 @@ char * mountHardDrive(struct installMethod * method,
/* if we had ks data around use it to prime entry, then get rid of it*/
if (kspartition) {
newtListboxSetCurrentByKey(listbox, kspartition);
- free(kspartition);
+ g_free(kspartition);
kspartition = NULL;
}

@@ -249,7 +255,7 @@ char * mountHardDrive(struct installMethod * method,
/* if we had ks data around use it to prime entry, then get rid of it*/
if (ksdirectory) {
newtEntrySet(dirEntry, ksdirectory, 1);
- free(ksdirectory);
+ g_free(ksdirectory);
ksdirectory = NULL;
}

@@ -282,12 +288,12 @@ char * mountHardDrive(struct installMethod * method,

selpart = newtListboxGetCurrent(listbox);

- free(dir);
+ g_free(dir);
if (tmpDir&& *tmpDir) {
/* Protect from form free. */
- dir = strdup(tmpDir);
+ dir = g_strdup(tmpDir);
} else {
- dir = strdup("");
+ dir = g_strdup("");
}

newtFormDestroy(form);
@@ -306,9 +312,10 @@ char * mountHardDrive(struct installMethod * method,
/* If the user-provided URL points at a repo instead of a stage2
* image, fix that up now.
*/
- substr = strstr(dir, ".img");
- if (!substr || (substr&& *(substr+4) != '')) {
- checked_asprintf(&dir, "%s/images/install.img", dir);
+ if (g_strrstr(dir, ".img") == NULL) {
+ char *tmp = g_strconcat(dir, imgpath, NULL);
+ g_free(dir);
+ dir = tmp;
}

loaderData->invalidRepoParam = 1;
@@ -324,7 +331,7 @@ char * mountHardDrive(struct installMethod * method,
done = 1;
}

- free(dir);
+ g_free(dir);

return url;
}


_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@redhat.com
https://www.redhat.com/mailman/listinfo/anaconda-devel-list
 

Thread Tools




All times are GMT. The time now is 03:56 AM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org