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

Go to the source code of this file.

Functions

devcall lflclose (struct dentry *devptr)
 

Function Documentation

◆ lflclose()

devcall lflclose ( struct dentry devptr)

Definition at line 9 of file lflclose.c.

References dentry::dvminor, Lf_data, lfdata::lf_dirdirty, LF_FREE, LF_USED, lflcblk::lfdbdirty, lfflush(), lflcblk::lfibdirty, lfltab, lflcblk::lfmutex, lflcblk::lfstate, OK, signal(), SYSERR, and wait().

12 {
13  struct lflcblk *lfptr; /* Ptr to open file table entry */
14 
15  /* Obtain exclusive use of the file */
16 
17  lfptr = &lfltab[devptr->dvminor];
18  wait(lfptr->lfmutex);
19 
20  /* If file is not open, return an error */
21 
22  if (lfptr->lfstate != LF_USED) {
23  signal(lfptr->lfmutex);
24  return SYSERR;
25  }
26 
27  /* Write index or data blocks to disk if they have changed */
28 
29  if (Lf_data.lf_dirdirty || lfptr->lfdbdirty || lfptr->lfibdirty) {
30  lfflush(lfptr);
31  }
32 
33  /* Set device state to FREE and return to caller */
34 
35  lfptr->lfstate = LF_FREE;
36  signal(lfptr->lfmutex);
37  return OK;
38 }
int32 dvminor
Definition: conf.h:8
#define SYSERR
処理が失敗した場合
Definition: kernel.h:79
struct lfdata Lf_data
Definition: lfsinit.c:5
#define LF_USED
Definition: lfilesys.h:53
struct lflcblk lfltab[]
Definition: lflinit.c:5
#define OK
処理が成功した場合
Definition: kernel.h:77
sid32 lfmutex
Definition: lfilesys.h:146
byte lfstate
Definition: lfilesys.h:144
bool8 lfdbdirty
Definition: lfilesys.h:166
bool8 lf_dirdirty
Definition: lfilesys.h:137
#define LF_FREE
Definition: lfilesys.h:52
bool8 lfibdirty
Definition: lfilesys.h:165
syscall wait(sid32)
Definition: wait.c:9
syscall signal(sid32)
セマフォにシグナルを送り、待機プロセスがある場合は解除する。
Definition: signal.c:18
status lfflush(struct lflcblk *)
Definition: lfflush.c:10
Here is the call graph for this function: