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 > Redhat > Fedora User

 
 
LinkBack Thread Tools
 
Old 04-01-2011, 06:00 PM
"Brian C. Lane"
 
Default Rewrite nfs url parsing in loader

---
loader/nfsinstall.c | 59 +++++++++++++++++++++++---------------------------
1 files changed, 27 insertions(+), 32 deletions(-)

diff --git a/loader/nfsinstall.c b/loader/nfsinstall.c
index 76529bf..485d1cc 100644
--- a/loader/nfsinstall.c
+++ b/loader/nfsinstall.c
@@ -121,38 +121,32 @@ static int nfsGetSetup(char ** hostptr, char ** dirptr, char ** optsptr) {
return LOADER_OK;
}

+/* Parse nfs: url and return its componenets
+ *
+ * nfs[ptions]:<server>:<path>
+ */
void parseNfsHostPathOpts(char *url, char **host, char **path, char **opts) {
- char *tmp;
- char *hostsrc;
-
/* Skip over the leading nfs: if present. */
if (!strncmp(url, "nfs:", 4))
url += 4;

logMessage(DEBUGLVL, "parseNfsHostPathOpts url: |%s|", url);

- hostsrc = strdup(url);
- *host = hostsrc;
- tmp = strchr(*host, ':');
-
- if (tmp) {
- *path = strdup(tmp + 1);
- *tmp = '';
- }
- else {
- *path = malloc(sizeof(char *));
- **path = '';
- }
-
- tmp = strchr(*path, ':');
- if (tmp && strlen(tmp) > 1) {
- char * c = tmp;
-
- *opts = *path;
- *path = strdup(c + 1);
- *c = '';
+ gchar **parts = g_strsplit(url, ":", 3) ;
+ if (parts == NULL || g_strv_length(parts) < 2) {
+ *opts = g_strdup("");
+ *host = g_strdup("");
+ *path = g_strdup("");
+ } else if (g_strv_length(parts) == 2) {
+ *opts = g_strdup("");
+ *host = g_strdup(parts[0]);
+ *path = g_strdup(parts[1]);
+ g_strfreev(parts);
} else {
- *opts = NULL;
+ *opts = g_strdup(parts[0]);
+ *host = g_strdup(parts[1]);
+ *path = g_strdup(parts[2]);
+ g_strfreev(parts);
}

logMessage(DEBUGLVL, "parseNfsHostPathOpts host: |%s|", *host);
@@ -229,9 +223,9 @@ cleanup3:
cleanup2:
umount("/mnt/isodir");
cleanup1:
- free(host);
- free(path);
- free(opts);
+ g_free(host);
+ g_free(path);
+ g_free(opts);
free(url);
return rc;
}
@@ -314,9 +308,9 @@ int loadNfsImages(struct loaderData_s *loaderData) {
free(url);
}

- free(host);
- free(path);
- free(opts);
+ g_free(host);
+ g_free(path);
+ g_free(opts);
return 1;
}

@@ -457,8 +451,9 @@ int getFileFromNfs(char * url, char * dest, struct loaderData_s * loaderData) {
failed = 1;
}

- free(host);
- free(path);
+ g_free(host);
+ g_free(path);
+ g_free(opts);
if (ip) free(ip);

if (umount("/tmp/mnt") == -1)
--
1.7.4

_______________________________________________
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 08:45 PM.

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