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

Go to the source code of this file.

Functions

status lfscheck (struct lfdir *dirptr)
 

Function Documentation

◆ lfscheck()

status lfscheck ( struct lfdir dirptr)

Definition at line 10 of file lfscheck.c.

References lfdir::lfd_allones, lfdir::lfd_allzeros, lfdir::lfd_fsysid, lfdir::lfd_nfiles, lfdir::lfd_revid, LFS_ID, OK, and SYSERR.

Referenced by lfsckfmt(), lfsopen(), and xsh_ls().

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
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
Here is the caller graph for this function: