XINU
device
lfs
lflclose.c
Go to the documentation of this file.
1
/* lflclose.c - lflclose.c */
2
3
#include <
xinu.h
>
4
5
/*------------------------------------------------------------------------
6
* lflclose - Close a file by flushing output and freeing device entry
7
*------------------------------------------------------------------------
8
*/
9
devcall
lflclose
(
10
struct
dentry
*devptr
/* Entry in device switch table */
11
)
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
}
dentry::dvminor
int32 dvminor
Definition:
conf.h:8
xinu.h
全てのシステムヘッダファイルをインクルードする。
SYSERR
#define SYSERR
処理が失敗した場合
Definition:
kernel.h:79
lflcblk
Definition:
lfilesys.h:142
Lf_data
struct lfdata Lf_data
Definition:
lfsinit.c:5
LF_USED
#define LF_USED
Definition:
lfilesys.h:53
lfltab
struct lflcblk lfltab[]
Definition:
lflinit.c:5
OK
#define OK
処理が成功した場合
Definition:
kernel.h:77
lflcblk::lfmutex
sid32 lfmutex
Definition:
lfilesys.h:146
dentry
Definition:
conf.h:6
lflclose
devcall lflclose(struct dentry *devptr)
Definition:
lflclose.c:9
lflcblk::lfstate
byte lfstate
Definition:
lfilesys.h:144
lflcblk::lfdbdirty
bool8 lfdbdirty
Definition:
lfilesys.h:166
lfdata::lf_dirdirty
bool8 lf_dirdirty
Definition:
lfilesys.h:137
LF_FREE
#define LF_FREE
Definition:
lfilesys.h:52
lflcblk::lfibdirty
bool8 lfibdirty
Definition:
lfilesys.h:165
wait
syscall wait(sid32)
Definition:
wait.c:9
signal
syscall signal(sid32)
セマフォにシグナルを送り、待機プロセスがある場合は解除する。
Definition:
signal.c:18
devcall
int32 devcall
デバイスコール関数 返り値の型
Definition:
kernel.h:49
lfflush
status lfflush(struct lflcblk *)
Definition:
lfflush.c:10
Generated by
1.8.13