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/config.h>
14 #include <linux/errno.h>
15 #include <linux/time.h>
16 #include <linux/stat.h>
17 #include <linux/fcntl.h>
18 #include <linux/smp_lock.h>
19 #include <linux/buffer_head.h>
22 #include <linux/qnx4_fs.h>
24 #include <asm/system.h>
27 * The functions for qnx4 fs file synchronization.
30 #ifdef CONFIG_QNX4FS_RW
32 static int sync_block(struct inode
*inode
, unsigned short *block
, int wait
)
34 struct buffer_head
*bh
;
40 bh
= sb_find_get_block(inode
->i_sb
, *block
);
47 if (wait
&& buffer_req(bh
) && !buffer_uptodate(bh
)) {
51 if (wait
|| !buffer_uptodate(bh
) || !buffer_dirty(bh
)) {
55 ll_rw_block(WRITE
, 1, &bh
);
56 atomic_dec(&bh
->b_count
);
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
= sb_bread(inode
->i_sb
, tmp
);
86 static int sync_direct(struct inode
*inode
, int wait
)
91 for (i
= 0; i
< 7; i
++) {
92 rc
= sync_block(inode
,
93 (unsigned short *) qnx4_raw_inode(inode
)->di_first_xtnt
.xtnt_blk
+ i
, wait
);
103 static int sync_indirect(struct inode
*inode
, unsigned short *iblock
, int wait
)
106 struct buffer_head
*ind_bh
;
109 rc
= sync_iblock(inode
, iblock
, &ind_bh
, wait
);
113 for (i
= 0; i
< 512; i
++) {
114 rc
= sync_block(inode
,
115 ((unsigned short *) ind_bh
->b_data
) + i
,
126 static int sync_dindirect(struct inode
*inode
, unsigned short *diblock
,
130 struct buffer_head
*dind_bh
;
133 rc
= sync_iblock(inode
, diblock
, &dind_bh
, wait
);
137 for (i
= 0; i
< 512; i
++) {
138 rc
= sync_indirect(inode
,
139 ((unsigned short *) dind_bh
->b_data
) + i
,
151 int qnx4_sync_file(struct file
*file
, struct dentry
*dentry
, int unused
)
153 struct inode
*inode
= dentry
->d_inode
;
157 if (!(S_ISREG(inode
->i_mode
) || S_ISDIR(inode
->i_mode
) ||
158 S_ISLNK(inode
->i_mode
)))
162 for (wait
= 0; wait
<= 1; wait
++) {
163 err
|= sync_direct(inode
, wait
);
165 err
|= qnx4_sync_inode(inode
);
167 return (err
< 0) ? -EIO
: 0;