Deleted Added
full compact
misc.c (16718) misc.c (17005)
1/*
2 * Miscellaneous support routines..
3 *
1/*
2 * Miscellaneous support routines..
3 *
4 * $Id: misc.c,v 1.19 1996/06/17 21:48:31 jkh Exp $
4 * $Id: misc.c,v 1.20 1996/06/25 18:41:10 jkh Exp $
5 *
6 * Copyright (c) 1995
7 * Jordan Hubbard. All rights reserved.
8 *
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
11 * are met:
12 * 1. Redistributions of source code must retain the above copyright

--- 231 unchanged lines hidden (view full) ---

244 safe_free(list[i].prompt);
245 safe_free(list[i].title);
246 }
247 safe_free(list);
248 *curr = *max = 0;
249}
250
251int
5 *
6 * Copyright (c) 1995
7 * Jordan Hubbard. All rights reserved.
8 *
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
11 * are met:
12 * 1. Redistributions of source code must retain the above copyright

--- 231 unchanged lines hidden (view full) ---

244 safe_free(list[i].prompt);
245 safe_free(list[i].title);
246 }
247 safe_free(list);
248 *curr = *max = 0;
249}
250
251int
252Mkdir(char *ipath, void *data)
252Mkdir(char *ipath)
253{
254 struct stat sb;
253{
254 struct stat sb;
255 int final=0;
255 int final;
256 char *p, *path;
257
258 if (file_readable(ipath) || Fake)
259 return DITEM_SUCCESS;
260
256 char *p, *path;
257
258 if (file_readable(ipath) || Fake)
259 return DITEM_SUCCESS;
260
261 path = strdup(ipath);
261 path = strcpy(alloca(strlen(ipath) + 1), ipath);
262 if (isDebug())
263 msgDebug("mkdir(%s)\n", path);
264 p = path;
265 if (p[0] == '/') /* Skip leading '/'. */
266 ++p;
262 if (isDebug())
263 msgDebug("mkdir(%s)\n", path);
264 p = path;
265 if (p[0] == '/') /* Skip leading '/'. */
266 ++p;
267 for (;!final; ++p) {
267 for (final = FALSE; !final; ++p) {
268 if (p[0] == '\0' || (p[0] == '/' && p[1] == '\0'))
268 if (p[0] == '\0' || (p[0] == '/' && p[1] == '\0'))
269 final++;
269 final = TRUE;
270 else if (p[0] != '/')
271 continue;
272 *p = '\0';
273 if (stat(path, &sb)) {
274 if (errno != ENOENT) {
275 msgConfirm("Couldn't stat directory %s: %s", path, strerror(errno));
276 return DITEM_FAILURE;
277 }
278 if (isDebug())
279 msgDebug("mkdir(%s..)\n", path);
280 if (mkdir(path, S_IRWXU | S_IRWXG | S_IRWXO) < 0) {
281 msgConfirm("Couldn't create directory %s: %s", path,strerror(errno));
282 return DITEM_FAILURE;
283 }
284 }
285 *p = '/';
286 }
270 else if (p[0] != '/')
271 continue;
272 *p = '\0';
273 if (stat(path, &sb)) {
274 if (errno != ENOENT) {
275 msgConfirm("Couldn't stat directory %s: %s", path, strerror(errno));
276 return DITEM_FAILURE;
277 }
278 if (isDebug())
279 msgDebug("mkdir(%s..)\n", path);
280 if (mkdir(path, S_IRWXU | S_IRWXG | S_IRWXO) < 0) {
281 msgConfirm("Couldn't create directory %s: %s", path,strerror(errno));
282 return DITEM_FAILURE;
283 }
284 }
285 *p = '/';
286 }
287 free(path);
288 return DITEM_SUCCESS;
289}
290
291int
292Mount(char *mountp, void *dev)
293{
294 struct ufs_args ufsargs;
295 char device[80];

--- 7 unchanged lines hidden (view full) ---

303 sprintf(mountpoint, "/mnt%s", mountp);
304 }
305 else {
306 strcpy(device, dev);
307 strcpy(mountpoint, mountp);
308 }
309 memset(&ufsargs,0,sizeof ufsargs);
310
287 return DITEM_SUCCESS;
288}
289
290int
291Mount(char *mountp, void *dev)
292{
293 struct ufs_args ufsargs;
294 char device[80];

--- 7 unchanged lines hidden (view full) ---

302 sprintf(mountpoint, "/mnt%s", mountp);
303 }
304 else {
305 strcpy(device, dev);
306 strcpy(mountpoint, mountp);
307 }
308 memset(&ufsargs,0,sizeof ufsargs);
309
311 if (Mkdir(mountpoint, NULL)) {
310 if (Mkdir(mountpoint)) {
312 msgConfirm("Unable to make directory mountpoint for %s!", mountpoint);
313 return DITEM_FAILURE;
314 }
315 if (isDebug())
316 msgDebug("mount %s %s\n", device, mountpoint);
317
318 ufsargs.fspec = device;
319 if (mount(MOUNT_UFS, mountpoint, MNT_ASYNC, (caddr_t)&ufsargs) == -1) {

--- 22 unchanged lines hidden ---
311 msgConfirm("Unable to make directory mountpoint for %s!", mountpoint);
312 return DITEM_FAILURE;
313 }
314 if (isDebug())
315 msgDebug("mount %s %s\n", device, mountpoint);
316
317 ufsargs.fspec = device;
318 if (mount(MOUNT_UFS, mountpoint, MNT_ASYNC, (caddr_t)&ufsargs) == -1) {

--- 22 unchanged lines hidden ---