mdmfs.c (163952) | mdmfs.c (166749) |
---|---|
1/* 2 * Copyright (c) 2001 Dima Dorfman. 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 17 unchanged lines hidden (view full) --- 26 27/* 28 * mdmfs (md/MFS) is a wrapper around mdconfig(8), 29 * newfs(8), and mount(8) that mimics the command line option set of 30 * the deprecated mount_mfs(8). 31 */ 32 33#include <sys/cdefs.h> | 1/* 2 * Copyright (c) 2001 Dima Dorfman. 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 17 unchanged lines hidden (view full) --- 26 27/* 28 * mdmfs (md/MFS) is a wrapper around mdconfig(8), 29 * newfs(8), and mount(8) that mimics the command line option set of 30 * the deprecated mount_mfs(8). 31 */ 32 33#include <sys/cdefs.h> |
34__FBSDID("$FreeBSD: head/sbin/mdmfs/mdmfs.c 163952 2006-11-03 12:02:24Z ru $"); | 34__FBSDID("$FreeBSD: head/sbin/mdmfs/mdmfs.c 166749 2007-02-15 13:49:44Z matteo $"); |
35 36#include <sys/param.h> 37#include <sys/mdioctl.h> 38#include <sys/stat.h> 39#include <sys/wait.h> 40 41#include <assert.h> 42#include <err.h> 43#include <fcntl.h> 44#include <grp.h> 45#include <paths.h> 46#include <pwd.h> 47#include <stdarg.h> 48#include <stdio.h> 49#include <stdlib.h> 50#include <string.h> | 35 36#include <sys/param.h> 37#include <sys/mdioctl.h> 38#include <sys/stat.h> 39#include <sys/wait.h> 40 41#include <assert.h> 42#include <err.h> 43#include <fcntl.h> 44#include <grp.h> 45#include <paths.h> 46#include <pwd.h> 47#include <stdarg.h> 48#include <stdio.h> 49#include <stdlib.h> 50#include <string.h> |
51#include <ctype.h> |
|
51#include <unistd.h> 52 53typedef enum { false, true } bool; 54 55struct mtpt_info { 56 uid_t mi_uid; 57 bool mi_have_uid; 58 gid_t mi_gid; 59 bool mi_have_gid; 60 mode_t mi_mode; 61 bool mi_have_mode; 62}; 63 64static bool debug; /* Emit debugging information? */ 65static bool loudsubs; /* Suppress output from helper programs? */ 66static bool norun; /* Actually run the helper programs? */ 67static int unit; /* The unit we're working with. */ 68static const char *mdname; /* Name of memory disk device (e.g., "md"). */ | 52#include <unistd.h> 53 54typedef enum { false, true } bool; 55 56struct mtpt_info { 57 uid_t mi_uid; 58 bool mi_have_uid; 59 gid_t mi_gid; 60 bool mi_have_gid; 61 mode_t mi_mode; 62 bool mi_have_mode; 63}; 64 65static bool debug; /* Emit debugging information? */ 66static bool loudsubs; /* Suppress output from helper programs? */ 67static bool norun; /* Actually run the helper programs? */ 68static int unit; /* The unit we're working with. */ 69static const char *mdname; /* Name of memory disk device (e.g., "md"). */ |
70static const char *mdsuffix; /* Suffix of memory disk device (e.g., ".uzip"). */ |
|
69static size_t mdnamelen; /* Length of mdname. */ 70static const char *path_mdconfig =_PATH_MDCONFIG; 71 72static void argappend(char **, const char *, ...) __printflike(2, 3); 73static void debugprintf(const char *, ...) __printflike(1, 2); 74static void do_mdconfig_attach(const char *, const enum md_types); 75static void do_mdconfig_attach_au(const char *, const enum md_types); 76static void do_mdconfig_detach(void); --- 154 unchanged lines hidden (view full) --- 231 usage(); 232 233 /* Derive 'unit' (global). */ 234 unitstr = argv[0]; 235 if (strncmp(unitstr, "/dev/", 5) == 0) 236 unitstr += 5; 237 if (strncmp(unitstr, mdname, mdnamelen) == 0) 238 unitstr += mdnamelen; | 71static size_t mdnamelen; /* Length of mdname. */ 72static const char *path_mdconfig =_PATH_MDCONFIG; 73 74static void argappend(char **, const char *, ...) __printflike(2, 3); 75static void debugprintf(const char *, ...) __printflike(1, 2); 76static void do_mdconfig_attach(const char *, const enum md_types); 77static void do_mdconfig_attach_au(const char *, const enum md_types); 78static void do_mdconfig_detach(void); --- 154 unchanged lines hidden (view full) --- 233 usage(); 234 235 /* Derive 'unit' (global). */ 236 unitstr = argv[0]; 237 if (strncmp(unitstr, "/dev/", 5) == 0) 238 unitstr += 5; 239 if (strncmp(unitstr, mdname, mdnamelen) == 0) 240 unitstr += mdnamelen; |
239 if (*unitstr == '\0') { | 241 if (!isdigit(*unitstr)) { |
240 autounit = true; 241 unit = -1; | 242 autounit = true; 243 unit = -1; |
244 mdsuffix = unitstr; |
|
242 } else { 243 ul = strtoul(unitstr, &p, 10); | 245 } else { 246 ul = strtoul(unitstr, &p, 10); |
244 if (ul == ULONG_MAX || *p != '\0') | 247 if (ul == ULONG_MAX) |
245 errx(1, "bad device unit: %s", unitstr); | 248 errx(1, "bad device unit: %s", unitstr); |
249 if (*p != '\0') 250 mdsuffix = p; |
|
246 unit = ul; 247 } 248 249 mtpoint = argv[1]; 250 if (!have_mdtype) 251 mdtype = MD_SWAP; 252 if (softdep) 253 argappend(&newfs_arg, "-U"); --- 165 unchanged lines hidden (view full) --- 419/* 420 * Mount the configured memory disk. 421 */ 422static void 423do_mount(const char *args, const char *mtpoint) 424{ 425 int rv; 426 | 251 unit = ul; 252 } 253 254 mtpoint = argv[1]; 255 if (!have_mdtype) 256 mdtype = MD_SWAP; 257 if (softdep) 258 argappend(&newfs_arg, "-U"); --- 165 unchanged lines hidden (view full) --- 424/* 425 * Mount the configured memory disk. 426 */ 427static void 428do_mount(const char *args, const char *mtpoint) 429{ 430 int rv; 431 |
427 rv = run(NULL, "%s%s /dev/%s%d %s", _PATH_MOUNT, args, 428 mdname, unit, mtpoint); | 432 rv = run(NULL, "%s%s /dev/%s%d%s %s", _PATH_MOUNT, args, 433 mdname, unit, mdsuffix, mtpoint); |
429 if (rv) 430 errx(1, "mount exited with error code %d", rv); 431} 432 433/* 434 * Various configuration of the mountpoint. Mostly, enact 'mip'. 435 */ 436static void --- 224 unchanged lines hidden --- | 434 if (rv) 435 errx(1, "mount exited with error code %d", rv); 436} 437 438/* 439 * Various configuration of the mountpoint. Mostly, enact 'mip'. 440 */ 441static void --- 224 unchanged lines hidden --- |