XINU
naminit.c
Go to the documentation of this file.
1 
8 #include <xinu.h>
9 
10 #ifndef RFILESYS
11 #define RFILESYS SYSERR
12 #endif
13 
14 #ifndef FILESYS
15 #define FILESYS SYSERR
16 #endif
17 
18 #ifndef LFILESYS
19 #define LFILESYS SYSERR
20 #endif
21 
22 struct nmentry nametab[NNAMES]; /* Table of name mappings */
23 int32 nnames; /* Number of entries allocated */
24 
25 /*------------------------------------------------------------------------
26  * naminit - Initialize the syntactic namespace
27  *------------------------------------------------------------------------
28  */
30 {
31  did32 i; /* Index into devtab */
32  struct dentry *devptr; /* Pointer to device table entry*/
33  char tmpstr[NM_MAXLEN]; /* String to hold a name */
34  status retval; /* Return value */
35  char *tptr; /* Pointer into tempstring */
36  char *nptr; /* Pointer to device name */
37  char devprefix[] = "/dev/"; /* Prefix to use for devices */
38  int32 len; /* Length of created name */
39  char ch; /* Storage for a character */
40 
41  /* Set prefix table to empty */
42 
43  nnames = 0;
44 
45  for (i = 0; i < NDEVS; i++)
46  {
47  tptr = tmpstr;
48  nptr = devprefix;
49 
50  /* Copy prefix into tmpstr */
51 
52  len = 0;
53  while ((*tptr++ = *nptr++) != NULLCH)
54  {
55  len++;
56  }
57  tptr--; /* Move pointer to position before NULLCH */
58  devptr = &devtab[i];
59  nptr = devptr->dvname; /* Move to device name */
60 
61  /* Map device name to lower case and append */
62 
63  while (++len < NM_MAXLEN)
64  {
65  ch = *nptr++;
66  if ((ch >= 'A') && (ch <= 'Z'))
67  {
68  ch += 'a' - 'A';
69  }
70  if ((*tptr++ = ch) == NULLCH)
71  {
72  break;
73  }
74  }
75 
76  if (len > NM_MAXLEN)
77  {
78  kprintf("namespace: device name %s too long\r\n",
79  devptr->dvname);
80  continue;
81  }
82 
83  retval = mount(tmpstr, NULLSTR, devptr->dvnum);
84  if (retval == SYSERR)
85  {
86  kprintf("namespace: cannot mount device %d\r\n",
87  devptr->dvname);
88  continue;
89  }
90  }
91 
92  /* Add other prefixes (longest prefix first) */
93 
94  mount("/dev/null", "", NULLDEV);
95  mount("/remote/", "remote:", RFILESYS);
96  mount("/local/", NULLSTR, LFILESYS);
97  mount("/dev/", NULLSTR, SYSERR);
98  mount("~/", NULLSTR, LFILESYS);
99  mount("/", "root:", RFILESYS);
100  mount("", "", LFILESYS);
101 
102  return OK;
103 }
syscall kprintf(char *fmt,...)
ポーリングI/Oを使用して、フォーマットされた文字列をコンソールに出力する。
Definition: kprintf.c:98
#define NULLSTR
空文字
Definition: kernel.h:72
#define NDEVS
Definition: conf.h:74
syscall mount(char *, char *, did32)
Definition: mount.c:9
int32 nnames
割り当てられたネームテーブルエントリの数
Definition: naminit.c:23
全てのシステムヘッダファイルをインクルードする。
#define SYSERR
処理が失敗した場合
Definition: kernel.h:79
#define RFILESYS
Definition: naminit.c:11
#define NNAMES
プレフィックス定義の数
Definition: name.h:13
#define OK
処理が成功した場合
Definition: kernel.h:77
int32 status
ステータスを意味する返り値の型(OK/SYSERR)
Definition: kernel.h:57
status naminit(void)
Definition: naminit.c:29
Definition: conf.h:6
#define NM_MAXLEN
ファイル名の最大サイズ
Definition: name.h:11
#define LFILESYS
Definition: naminit.c:19
struct dentry devtab[]
Definition: conf.c:11
全ての名前マッピングを定義する名前プレフィックステーブルの定義(ネームテーブルエントリ) ...
Definition: name.h:19
#define NULLDEV
Definition: conf.h:33
int int32
符号あり32ビット整数(int)
Definition: kernel.h:11
int32 dvnum
Definition: conf.h:7
int32 did32
デバイスID
Definition: kernel.h:28
char * dvname
Definition: conf.h:9
struct nmentry nametab[NNAMES]
名前マッピングのテーブル
Definition: naminit.c:22
#define NULLCH
NULL文字(NULL終端)
Definition: kernel.h:70