2 * QNX4 file system, Linux implementation.
6 * Using parts of the xiafs filesystem.
10 * 24-03-1998 by Richard Frowijn : first release.
13 #include <linux/errno.h>
14 #include <linux/sched.h>
15 #include <linux/stat.h>
16 #include <linux/fcntl.h>
17 #include <linux/locks.h>
20 #include <linux/qnx4_fs.h>
22 #include <asm/segment.h>
23 #include <asm/system.h>
25 #define blocksize QNX4_BLOCK_SIZE
28 * The functions for qnx4 fs file synchronization.
31 #ifdef CONFIG_QNX4FS_RW
33 static int sync_block(struct inode
*inode
, unsigned short *block
, int wait
)
35 struct buffer_head
*bh
;
41 bh
= get_hash_table(inode
->i_dev
, *block
, blocksize
);
48 if (wait
&& buffer_req(bh
) && !buffer_uptodate(bh
)) {
52 if (wait
|| !buffer_uptodate(bh
) || !buffer_dirty(bh
)) {
56 ll_rw_block(WRITE
, 1, &bh
);
61 static int sync_iblock(struct inode
*inode
, unsigned short *iblock
,
62 struct buffer_head
**bh
, int wait
)
71 rc
= sync_block(inode
, iblock
, wait
);
74 *bh
= bread(inode
->i_dev
, tmp
, blocksize
);
85 static int sync_direct(struct inode
*inode
, int wait
)
90 for (i
= 0; i
< 7; i
++) {
91 rc
= sync_block(inode
,
92 (unsigned short *) inode
->u
.qnx4_i
.i_first_xtnt
.xtnt_blk
+ i
, wait
);
101 static int sync_indirect(struct inode
*inode
, unsigned short *iblock
, int wait
)
104 struct buffer_head
*ind_bh
;
107 rc
= sync_iblock(inode
, iblock
, &ind_bh
, wait
);
111 for (i
= 0; i
< 512; i
++) {
112 rc
= sync_block(inode
,
113 ((unsigned short *) ind_bh
->b_data
) + i
,
124 static int sync_dindirect(struct inode
*inode
, unsigned short *diblock
,
128 struct buffer_head
*dind_bh
;
131 rc
= sync_iblock(inode
, diblock
, &dind_bh
, wait
);
135 for (i
= 0; i
< 512; i
++) {
136 rc
= sync_indirect(inode
,
137 ((unsigned short *) dind_bh
->b_data
) + i
,
148 int qnx4_sync_file(struct file
*file
, struct dentry
*dentry
)
150 struct inode
*inode
= dentry
->d_inode
;
154 if (!(S_ISREG(inode
->i_mode
) || S_ISDIR(inode
->i_mode
) ||
155 S_ISLNK(inode
->i_mode
)))
158 for (wait
= 0; wait
<= 1; wait
++) {
159 err
|= sync_direct(inode
, wait
);
161 err
|= qnx4_sync_inode(inode
);
162 return (err
< 0) ? -EIO
: 0;