XINU
lfscheck.c
Go to the documentation of this file.
1 /* lfscheck.c - lfscheck */
2 
3 #include <xinu.h>
4 #include <ramdisk.h>
5 
6 /*------------------------------------------------------------------------
7  * lfscheck - Check a directory to verify it contains a Xinu file system
8  *------------------------------------------------------------------------
9  */
11  struct lfdir *dirptr /* Ptr to an in-core directory */
12  )
13 {
14  uint32 reverse; /* LFS_ID in reverse byte order */
15 
16  /* Verify the File System ID, all 0's and all 1's fields */
17 
18  if ( (dirptr->lfd_fsysid != LFS_ID) ||
19  (dirptr->lfd_allzeros != 0x00000000) ||
20  (dirptr->lfd_allones != 0xffffffff) ) {
21  return SYSERR;
22  }
23 
24  /* Check the reverse-order File System ID field */
25 
26  reverse = ((LFS_ID>>24) & 0x000000ff) |
27  ((LFS_ID>> 8) & 0x0000ff00) |
28  ((LFS_ID<< 8) & 0x00ff0000) |
29  ((LFS_ID<<24) & 0xff000000) ;
30 
31  if (dirptr->lfd_revid != reverse) {
32  return SYSERR;
33  }
34 
35  /* Extra sanity check - verify file count is positive */
36  if (dirptr->lfd_nfiles < 0){
37  return SYSERR;
38  }
39  return OK;
40 }
uint32 lfd_fsysid
Definition: lfilesys.h:115
全てのシステムヘッダファイルをインクルードする。
#define SYSERR
処理が失敗した場合
Definition: kernel.h:79
#define OK
処理が成功した場合
Definition: kernel.h:77
status lfscheck(struct lfdir *dirptr)
Definition: lfscheck.c:10
int32 status
ステータスを意味する返り値の型(OK/SYSERR)
Definition: kernel.h:57
RAMディスクに関する定義(testing)
uint32 lfd_revid
Definition: lfilesys.h:124
int32 lfd_nfiles
Definition: lfilesys.h:122
#define LFS_ID
Definition: lfilesys.h:80
uint32 lfd_allzeros
Definition: lfilesys.h:118
uint32 lfd_allones
Definition: lfilesys.h:119
unsigned int uint32
符号なし32ビット整数(unsigned int)
Definition: kernel.h:15