PageRenderTime 12ms CodeModel.GetById 1ms app.highlight 8ms RepoModel.GetById 1ms app.codeStats 0ms

/filesystems/unixfs/minixfs/minixfs_mainx.c

http://macfuse.googlecode.com/
C | 82 lines | 66 code | 11 blank | 5 comment | 7 complexity | d04ae21f619c4ff71ee5001fc29b0a2f MD5 | raw file
 1/*
 2 * Minix File System Famiy for MacFUSE
 3 * Copyright (c) 2008 Amit Singh
 4 * http://osxbook.com
 5 */
 6
 7#include "unixfs.h"
 8
 9#include <errno.h>
10#include <stddef.h>
11#include <stdio.h>
12#include <stdlib.h>
13#include <string.h>
14#include <unistd.h>
15#include <ctype.h>
16#include <dlfcn.h>
17
18static const char* PROGNAME = "minixfs";
19static const char* PROGVERS = "1.0";
20
21static struct filesystems {
22    int   isalias;
23    char* fstypename;
24    char* fstypename_canonical;
25} filesystems[] = {
26    { 1, "Minix", "minix" },
27    { 0, NULL, NULL },
28};
29
30__private_extern__
31void
32unixfs_usage(void)
33{
34    fprintf(stderr,
35    "%s (version %s): Minix File System for MacFUSE\n"
36    "Amit Singh <http://osxbook.com>\n"
37    "usage:\n"
38    "      %s [--force] --dmg DMG MOUNTPOINT [MacFUSE args...]\n"
39    "where:\n"
40    "     . DMG must point to a Minix disk image\n"
41    "     . --force attempts mounting even if there are warnings or errors\n",
42    PROGNAME, PROGVERS, PROGNAME);
43}
44
45__private_extern__
46struct unixfs*
47unixfs_preflight(char* dmg, char** type, struct unixfs** unixfsp)
48{
49    int i;
50    *unixfsp = NULL;
51
52    if (!type)
53        goto out;
54
55    *type = "minix"; /* quick fix */
56
57    for (i = 0; filesystems[i].fstypename != NULL; i++) {
58        if (strcasecmp(*type, filesystems[i].fstypename) == 0) {
59            char symb[255];
60            snprintf(symb, 255, "%s_%s", "unixfs",
61                     filesystems[i].fstypename_canonical);
62            void* impl = dlsym(RTLD_DEFAULT, symb);
63            if (impl != NULL) {
64                *unixfsp = (struct unixfs*)impl;
65                break;
66            }
67        }
68    }
69
70out:
71    return *unixfsp;
72}
73
74__private_extern__
75void
76unixfs_postflight(char* fsname, char* volname, char* extra_args)
77{
78    snprintf(extra_args, UNIXFS_ARGLEN,
79        "-oro,sparse,defer_permissions,daemon_timeout=5,"
80        "volname=%s,fsname=%s File System",
81        volname, fsname);
82}