aboutsummaryrefslogtreecommitdiff
path: root/mtab.c
diff options
context:
space:
mode:
Diffstat (limited to 'mtab.c')
-rw-r--r--mtab.c24
1 files changed, 7 insertions, 17 deletions
diff --git a/mtab.c b/mtab.c
index 98e42a383..41d88184b 100644
--- a/mtab.c
+++ b/mtab.c
@@ -5,21 +5,13 @@
5#include <string.h> 5#include <string.h>
6#include <stdio.h> 6#include <stdio.h>
7#include <mntent.h> 7#include <mntent.h>
8#include <fstab.h>
8#include <sys/mount.h> 9#include <sys/mount.h>
9 10
10extern const char mtab_file[]; /* Defined in utility.c */ 11extern const char mtab_file[]; /* Defined in utility.c */
11 12
12static char *
13stralloc(const char * string)
14{
15 int length = strlen(string) + 1;
16 char * n = malloc(length);
17 memcpy(n, string, length);
18 return n;
19}
20 13
21extern void 14void erase_mtab(const char * name)
22erase_mtab(const char * name)
23{ 15{
24 struct mntent entries[20]; 16 struct mntent entries[20];
25 int count = 0; 17 int count = 0;
@@ -39,10 +31,10 @@ erase_mtab(const char * name)
39 } 31 }
40 32
41 while ( (m = getmntent(mountTable)) != 0 ) { 33 while ( (m = getmntent(mountTable)) != 0 ) {
42 entries[count].mnt_fsname = stralloc(m->mnt_fsname); 34 entries[count].mnt_fsname = strdup(m->mnt_fsname);
43 entries[count].mnt_dir = stralloc(m->mnt_dir); 35 entries[count].mnt_dir = strdup(m->mnt_dir);
44 entries[count].mnt_type = stralloc(m->mnt_type); 36 entries[count].mnt_type = strdup(m->mnt_type);
45 entries[count].mnt_opts = stralloc(m->mnt_opts); 37 entries[count].mnt_opts = strdup(m->mnt_opts);
46 entries[count].mnt_freq = m->mnt_freq; 38 entries[count].mnt_freq = m->mnt_freq;
47 entries[count].mnt_passno = m->mnt_passno; 39 entries[count].mnt_passno = m->mnt_passno;
48 count++; 40 count++;
@@ -65,8 +57,7 @@ erase_mtab(const char * name)
65 perror(mtab_file); 57 perror(mtab_file);
66} 58}
67 59
68extern void 60void write_mtab(char* blockDevice, char* directory,
69write_mtab(char* blockDevice, char* directory,
70 char* filesystemType, long flags, char* string_flags) 61 char* filesystemType, long flags, char* string_flags)
71{ 62{
72 FILE *mountTable = setmntent(mtab_file, "a+"); 63 FILE *mountTable = setmntent(mtab_file, "a+");
@@ -110,4 +101,3 @@ write_mtab(char* blockDevice, char* directory,
110 } 101 }
111} 102}
112 103
113