1 /* ----------------------------------------------------------------------- *
2  *
3  *   Copyright 2013 Intel Corporation; author: Matt Fleming
4  *
5  *   This program is free software; you can redistribute it and/or modify
6  *   it under the terms of the GNU General Public License as published by
7  *   the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
8  *   Boston MA 02110-1301, USA; either version 2 of the License, or
9  *   (at your option) any later version; incorporated herein by reference.
10  *
11  * ----------------------------------------------------------------------- */
12 
13 #include <klibc/compiler.h>
14 #include <linux/list.h>
15 #include <fs.h>
16 #include <string.h>
17 
18 __export LIST_HEAD(PATH);
19 
path_add(const char * str)20 __export struct path_entry *path_add(const char *str)
21 {
22     struct path_entry *entry;
23 
24     if (!strlen(str))
25 	return NULL;
26 
27     entry = malloc(sizeof(*entry));
28     if (!entry)
29 	return NULL;
30 
31     entry->str = strdup(str);
32     if (!entry->str)
33 	goto bail;
34 
35     list_add(&entry->list, &PATH);
36 
37     return entry;
38 
39 bail:
40     free(entry);
41     return NULL;
42 }
43