misc.c (8363) | misc.c (8556) |
---|---|
1/* 2 * Miscellaneous support routines.. 3 * | 1/* 2 * Miscellaneous support routines.. 3 * |
4 * $Id: misc.c,v 1.3 1995/05/01 21:56:27 jkh Exp $ | 4 * $Id: misc.c,v 1.4 1995/05/08 21:39:39 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 --- 22 unchanged lines hidden (view full) --- 35 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 36 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 37 * SUCH DAMAGE. 38 * 39 */ 40 41#include "sysinstall.h" 42#include <ctype.h> | 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 --- 22 unchanged lines hidden (view full) --- 35 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 36 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 37 * SUCH DAMAGE. 38 * 39 */ 40 41#include "sysinstall.h" 42#include <ctype.h> |
43#include <sys/stat.h> 44#include <sys/errno.h> 45#include <sys/file.h> 46#include <sys/types.h> 47#include <sys/wait.h> 48#include <sys/param.h> 49#include <sys/mount.h> 50#include <sys/reboot.h> 51#include <sys/dkbad.h> 52#include <sys/disklabel.h> |
|
43 44/* Quick check to see if a file is readable */ 45Boolean 46file_readable(char *fname) 47{ 48 if (!access(fname, F_OK)) 49 return TRUE; 50 return FALSE; --- 105 unchanged lines hidden (view full) --- 156/* Toss the items out */ 157void 158items_free(char **list, int *curr, int *max) 159{ 160 safe_free(list); 161 *curr = *max = 0; 162} 163 | 53 54/* Quick check to see if a file is readable */ 55Boolean 56file_readable(char *fname) 57{ 58 if (!access(fname, F_OK)) 59 return TRUE; 60 return FALSE; --- 105 unchanged lines hidden (view full) --- 166/* Toss the items out */ 167void 168items_free(char **list, int *curr, int *max) 169{ 170 safe_free(list); 171 *curr = *max = 0; 172} 173 |
174int 175Mkdir(char *ipath, void *data) 176{ 177 struct stat sb; 178 int final=0; 179 char *p, *path = strdup(ipath); 180 181 msgDebug("mkdir(%s)\n", path); 182 p = path; 183 if (p[0] == '/') /* Skip leading '/'. */ 184 ++p; 185 for (;!final; ++p) { 186 if (p[0] == '\0' || (p[0] == '/' && p[1] == '\0')) 187 final++; 188 else if (p[0] != '/') 189 continue; 190 *p = '\0'; 191 if (stat(path, &sb)) { 192 if (errno != ENOENT) { 193 msgConfirm("Couldn't stat directory %s: %s", path, strerror(errno)); 194 return 1; 195 } 196 msgDebug("mkdir(%s..)\n", path); 197 if (mkdir(path, S_IRWXU | S_IRWXG | S_IRWXO) < 0) { 198 msgConfirm("Couldn't create directory %s: %s", path,strerror(errno)); 199 return 1; 200 } 201 } 202 *p = '/'; 203 } 204 free(path); 205 return 0; 206} 207 208int 209Mount(char *device, void *data) 210{ 211 struct ufs_args ufsargs; 212 char mountpoint[FILENAME_MAX]; 213 214 strcpy(mountpoint, "/mnt"); 215 if (data) 216 sprintf(mountpoint + 4, "/%s", (char *)data); 217 218 memset(&ufsargs,0,sizeof ufsargs); 219 220 if (access(mountpoint, R_OK)) 221 Mkdir(mountpoint, NULL); 222 223 msgDebug("mount %s %s\n", device, mountpoint); 224 ufsargs.fspec = device; 225 if (mount(MOUNT_UFS, mountpoint, 0, (caddr_t)&ufsargs) == -1) { 226 msgConfirm("Error mounting %s on %s : %s\n", 227 device, mountpoint, strerror(errno)); 228 return 1; 229 } 230 return 0; 231} 232 |
|