XINU
Functions
mount.c File Reference
#include <xinu.h>
Include dependency graph for mount.c:

Go to the source code of this file.

Functions

syscall mount (char *prefix, char *replace, did32 device)
 
int32 namlen (char *name, int32 maxlen)
 

Function Documentation

◆ mount()

syscall mount ( char *  prefix,
char *  replace,
did32  device 
)

Definition at line 9 of file mount.c.

References disable(), isbaddev, nametab, namlen(), nmentry::ndevice, NM_PRELEN, NM_REPLLEN, NNAMES, nnames, nmentry::nprefix, nmentry::nreplace, OK, restore(), and SYSERR.

Referenced by naminit().

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 }
int32 namlen(char *name, int32 maxlen)
Definition: mount.c:60
void restore(intmask)
#define SYSERR
処理が失敗した場合
Definition: kernel.h:79
#define NNAMES
プレフィックス定義の数
Definition: name.h:13
#define OK
処理が成功した場合
Definition: kernel.h:77
#define NM_REPLLEN
置換(1個)の最大サイズ
Definition: name.h:9
int32 nnames
割り当てられたネームテーブルエントリの数
Definition: naminit.c:23
struct nmentry nametab[]
名前マッピングのテーブル
Definition: naminit.c:22
did32 ndevice
プレフィックス用のデバイスディスクリプタ
Definition: name.h:26
全ての名前マッピングを定義する名前プレフィックステーブルの定義(ネームテーブルエントリ) ...
Definition: name.h:19
uint32 intmask
保存された割り込みマスク
Definition: kernel.h:38
#define NM_PRELEN
プレフィックス文字列の最大サイズ
Definition: name.h:7
int int32
符号あり32ビット整数(int)
Definition: kernel.h:11
#define isbaddev(f)
デバイスIDを検証するマクロ。
Definition: device.h:15
char nprefix[NM_PRELEN]
NULL終端のプレフィックス
Definition: name.h:22
char nreplace[NM_REPLLEN]
NULL終端置換
Definition: name.h:24
intmask disable(void)
割り込み禁止(intr.Sに定義がある)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ namlen()

int32 namlen ( char *  name,
int32  maxlen 
)

Definition at line 60 of file mount.c.

References NULLCH, and SYSERR.

Referenced by dns_geta(), mount(), and namrepl().

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 }
#define SYSERR
処理が失敗した場合
Definition: kernel.h:79
int int32
符号あり32ビット整数(int)
Definition: kernel.h:11
#define NULLCH
NULL文字(NULL終端)
Definition: kernel.h:70
Here is the caller graph for this function: