View | Details | Raw Unified | Return to bug 7366
Collapse All | Expand All

(-)/home/koochy/Projects/fstab.c (-12 / +45 lines)
Lines 9-14 Link Here
9
#include <stdio.h>
9
#include <stdio.h>
10
#include <string.h>
10
#include <string.h>
11
#include <sys/stat.h>
11
#include <sys/stat.h>
12
#include <dirent.h>
12
#include "mntent.h"
13
#include "mntent.h"
13
#include "fstab.h"
14
#include "fstab.h"
14
#include "sundries.h"
15
#include "sundries.h"
Lines 173-198 Link Here
173
	read_mntentchn(mfp, fnam, mc);
174
	read_mntentchn(mfp, fnam, mc);
174
}
175
}
175
176
176
static void
177
static int
177
read_fstab() {
178
read_fstab_file(const char *fnam, struct mntentchn *mc){
178
	mntFILE *mfp = NULL;
179
	const char *fnam;
180
	struct mntentchn *mc = &fstab;
181
182
	got_fstab = 1;
183
	mc->nxt = mc->prev = NULL;
184
179
185
	fnam = _PATH_FSTAB;
180
	mntFILE *mfp = NULL;
181
	
186
	mfp = my_setmntent (fnam, "r");
182
	mfp = my_setmntent (fnam, "r");
183
187
	if (mfp == NULL || mfp->mntent_fp == NULL) {
184
	if (mfp == NULL || mfp->mntent_fp == NULL) {
188
		int errsv = errno;
185
		int errsv = errno;
189
		error(_("warning: can't open %s: %s"),
186
		error(_("warning: can't open %s: %s"),
190
		      _PATH_FSTAB, strerror (errsv));
187
		      fnam, strerror (errsv));
191
		return;
188
		return 0;
192
	}
189
	}
193
	read_mntentchn(mfp, fnam, mc);
190
	read_mntentchn(mfp, fnam, mc);
191
	return 1;
192
193
}
194
195
static void
196
read_fstab() {
197
198
	struct stat st;
199
	char *dir_path;
200
	DIR *dir;
201
	struct dirent *entry;
202
	char entry_path[PATH_MAX + 1];
203
	size_t path_len;
204
	struct mntentchn *mc = &fstab;
205
206
	mc->nxt = mc->prev = NULL;
207
	got_fstab = 1;
208
209
	if(!read_fstab_file(_PATH_FSTAB,mc)) return;
210
211
	dir_path = _PATH_FSTAB ".d/";	
212
	strncpy (entry_path, dir_path, sizeof (entry_path));
213
	dir = opendir (dir_path);
214
	path_len = strlen (dir_path);
215
216
	while((entry=readdir(dir))!=NULL) {
217
218
		strncpy (entry_path + path_len, entry->d_name,
219
			 sizeof (entry_path) - path_len);
220
		lstat (entry_path, &st);
221
		if (S_ISREG (st.st_mode))
222
			read_fstab_file(entry_path,mc);
223
		
224
		
225
	}
226
	closedir(dir);
194
}
227
}
195
     
228
196
229
197
/* Given the name NAME, try to find it in mtab.  */ 
230
/* Given the name NAME, try to find it in mtab.  */ 
198
struct mntentchn *
231
struct mntentchn *

Return to bug 7366