XINU
device
nam
mount.c
Go to the documentation of this file.
1
/* mount.c - mount, namlen */
2
3
#include <
xinu.h
>
4
5
/*------------------------------------------------------------------------
6
* mount - Add a prefix mapping to the name space
7
*------------------------------------------------------------------------
8
*/
9
syscall
mount
(
10
char
*prefix,
/* Prefix to add */
11
char
*replace,
/* Replacement string */
12
did32
device
/* Device ID to use */
13
)
14
{
15
intmask
mask;
/* Saved interrupt mask */
16
struct
nmentry
*namptr;
/* Pointer to unused table entry*/
17
int32
psiz, rsiz;
/* Sizes of prefix & replacement*/
18
int32
i;
/* Counter for copy loop */
19
20
mask =
disable
();
21
22
psiz =
namlen
(prefix,
NM_PRELEN
);
23
rsiz =
namlen
(replace,
NM_REPLLEN
);
24
25
/* If arguments are invalid or table is full, return error */
26
27
if
( (psiz ==
SYSERR
) || (rsiz ==
SYSERR
) ||
28
(
isbaddev
(device)) || (
nnames
>=
NNAMES
) ) {
29
restore
(mask);
30
return
SYSERR
;
31
}
32
33
/* Allocate a slot in the table */
34
35
namptr = &
nametab
[
nnames
];
/* Next unused entry in table */
36
37
/* copy prefix and replacement strings and record device ID */
38
39
for
(i=0; i<psiz; i++) {
/* Copy prefix into table entry */
40
namptr->
nprefix
[i] = *prefix++;
41
}
42
43
for
(i=0; i<rsiz; i++) {
/* Copy replacement into entry */
44
namptr->
nreplace
[i] = *replace++;
45
}
46
47
namptr->
ndevice
= device;
/* Record the device ID */
48
49
nnames
++;
/* Increment number of names */
50
51
restore
(mask);
52
return
OK
;
53
}
54
55
56
/*------------------------------------------------------------------------
57
* namlen - Compute the length of a string stopping at maxlen
58
*------------------------------------------------------------------------
59
*/
60
int32
namlen
(
61
char
*name,
/* Name to use */
62
int32
maxlen
/* Maximum length (including a */
63
/* NULLCH) */
64
)
65
{
66
int32
i;
/* Count of characters found */
67
68
/* Search until a null terminator or length reaches max */
69
70
for
(i=0; i < maxlen; i++) {
71
if
(*name++ ==
NULLCH
) {
72
return
i+1;
/* Include NULLCH in length */
73
}
74
}
75
return
SYSERR
;
76
}
namlen
int32 namlen(char *name, int32 maxlen)
Definition:
mount.c:60
restore
void restore(intmask)
xinu.h
全てのシステムヘッダファイルをインクルードする。
SYSERR
#define SYSERR
処理が失敗した場合
Definition:
kernel.h:79
NNAMES
#define NNAMES
プレフィックス定義の数
Definition:
name.h:13
mount
syscall mount(char *prefix, char *replace, did32 device)
Definition:
mount.c:9
OK
#define OK
処理が成功した場合
Definition:
kernel.h:77
NM_REPLLEN
#define NM_REPLLEN
置換(1個)の最大サイズ
Definition:
name.h:9
nnames
int32 nnames
割り当てられたネームテーブルエントリの数
Definition:
naminit.c:23
nametab
struct nmentry nametab[]
名前マッピングのテーブル
Definition:
naminit.c:22
nmentry::ndevice
did32 ndevice
プレフィックス用のデバイスディスクリプタ
Definition:
name.h:26
nmentry
全ての名前マッピングを定義する名前プレフィックステーブルの定義(ネームテーブルエントリ) ...
Definition:
name.h:19
intmask
uint32 intmask
保存された割り込みマスク
Definition:
kernel.h:38
NM_PRELEN
#define NM_PRELEN
プレフィックス文字列の最大サイズ
Definition:
name.h:7
int32
int int32
符号あり32ビット整数(int)
Definition:
kernel.h:11
isbaddev
#define isbaddev(f)
デバイスIDを検証するマクロ。
Definition:
device.h:15
did32
int32 did32
デバイスID
Definition:
kernel.h:28
nmentry::nprefix
char nprefix[NM_PRELEN]
NULL終端のプレフィックス
Definition:
name.h:22
syscall
int32 syscall
システムコール関数 返り値の型
Definition:
kernel.h:47
nmentry::nreplace
char nreplace[NM_REPLLEN]
NULL終端置換
Definition:
name.h:24
NULLCH
#define NULLCH
NULL文字(NULL終端)
Definition:
kernel.h:70
disable
intmask disable(void)
割り込み禁止(intr.Sに定義がある)
Generated by
1.8.13