XINU
Macros | Functions | Variables
naminit.c File Reference

(Syntactic)名前空間を初期化する。 More...

#include <xinu.h>
Include dependency graph for naminit.c:

Go to the source code of this file.

Macros

#define FILESYS   SYSERR
 
#define LFILESYS   SYSERR
 
#define RFILESYS   SYSERR
 

Functions

status naminit (void)
 

Variables

struct nmentry nametab [NNAMES]
 名前マッピングのテーブル More...
 
int32 nnames
 割り当てられたネームテーブルエントリの数 More...
 

Detailed Description

(Syntactic)名前空間を初期化する。

Definition in file naminit.c.

Macro Definition Documentation

◆ FILESYS

#define FILESYS   SYSERR

Definition at line 15 of file naminit.c.

◆ LFILESYS

#define LFILESYS   SYSERR

Definition at line 19 of file naminit.c.

Referenced by naminit().

◆ RFILESYS

#define RFILESYS   SYSERR

Definition at line 11 of file naminit.c.

Referenced by naminit().

Function Documentation

◆ naminit()

status naminit ( void  )

Definition at line 29 of file naminit.c.

References devtab, dentry::dvname, dentry::dvnum, kprintf(), LFILESYS, mount(), NDEVS, NM_MAXLEN, nnames, NULLCH, NULLDEV, NULLSTR, OK, RFILESYS, and SYSERR.

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 OK
処理が成功した場合
Definition: kernel.h:77
int32 status
ステータスを意味する返り値の型(OK/SYSERR)
Definition: kernel.h:57
Definition: conf.h:6
#define NM_MAXLEN
ファイル名の最大サイズ
Definition: name.h:11
#define LFILESYS
Definition: naminit.c:19
struct dentry devtab[]
Definition: conf.c:11
#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
#define NULLCH
NULL文字(NULL終端)
Definition: kernel.h:70
Here is the call graph for this function:

Variable Documentation

◆ nametab

struct nmentry nametab[NNAMES]

名前マッピングのテーブル

Definition at line 22 of file naminit.c.

Referenced by mount(), and namrepl().

◆ nnames

int32 nnames

割り当てられたネームテーブルエントリの数

Definition at line 23 of file naminit.c.

Referenced by mount(), naminit(), nammap(), and namrepl().