Home | History | Annotate | Download | only in ext2fs

Lines Matching refs:fs

33 errcode_t ext2fs_mmp_read(ext2_filsys fs, blk64_t mmp_blk, void *buf)
38 if ((mmp_blk <= fs->super->s_first_data_block) ||
39 (mmp_blk >= ext2fs_blocks_count(fs->super)))
47 if (fs->mmp_fd <= 0) {
48 fs->mmp_fd = open(fs->device_name, O_RDWR | O_DIRECT);
49 if (fs->mmp_fd < 0) {
55 if (fs->mmp_cmp == NULL) {
56 int align = ext2fs_get_dio_alignment(fs->mmp_fd);
58 retval = ext2fs_get_memalign(fs->blocksize, align,
59 &fs->mmp_cmp);
64 if ((blk64_t) ext2fs_llseek(fs->mmp_fd, mmp_blk * fs->blocksize,
66 mmp_blk * fs->blocksize) {
71 if (read(fs->mmp_fd, fs->mmp_cmp, fs->blocksize) != fs->blocksize) {
76 mmp_cmp = fs->mmp_cmp;
81 if (buf != NULL && buf != fs->mmp_cmp)
82 memcpy(buf, fs->mmp_cmp, fs->blocksize);
93 errcode_t ext2fs_mmp_write(ext2_filsys fs, blk64_t mmp_blk, void *buf)
101 fs->mmp_last_written = tv.tv_sec;
103 if (fs->super->s_mmp_block < fs->super->s_first_data_block ||
104 fs->super->s_mmp_block > ext2fs_blocks_count(fs->super))
113 retval = io_channel_write_blk64(fs->io, mmp_blk, -(int)sizeof(struct mmp_struct), buf);
120 io_channel_flush(fs->io);
149 static errcode_t ext2fs_mmp_reset(ext2_filsys fs)
154 if (fs->mmp_buf == NULL) {
155 retval = ext2fs_get_mem(fs->blocksize, &fs->mmp_buf);
160 memset(fs->mmp_buf, 0, fs->blocksize);
161 mmp_s = fs->mmp_buf;
171 strncpy(mmp_s->mmp_bdevname, fs->device_name,
174 mmp_s->mmp_check_interval = fs->super->s_mmp_update_interval;
178 retval = ext2fs_mmp_write(fs, fs->super->s_mmp_block, fs->mmp_buf);
183 errcode_t ext2fs_mmp_clear(ext2_filsys fs)
187 if (!(fs->flags & EXT2_FLAG_RW))
190 retval = ext2fs_mmp_reset(fs);
195 errcode_t ext2fs_mmp_init(ext2_filsys fs)
197 struct ext2_super_block *sb = fs->super;
207 if (fs->mmp_buf == NULL) {
208 retval = ext2fs_get_mem(fs->blocksize, &fs->mmp_buf);
213 retval = ext2fs_alloc_block2(fs, 0, fs->mmp_buf, &mmp_block);
219 retval = ext2fs_mmp_reset(fs);
228 * Make sure that the fs is not mounted or being fsck'ed while opening the fs.
230 errcode_t ext2fs_mmp_start(ext2_filsys fs)
237 if (fs->mmp_buf == NULL) {
238 retval = ext2fs_get_mem(fs->blocksize, &fs->mmp_buf);
243 retval = ext2fs_mmp_read(fs, fs->super->s_mmp_block, fs->mmp_buf);
247 mmp_s = fs->mmp_buf;
249 mmp_check_interval = fs->super->s_mmp_update_interval;
275 retval = ext2fs_mmp_read(fs, fs->super->s_mmp_block, fs->mmp_buf);
285 if (!(fs->flags & EXT2_FLAG_RW))
294 strncpy(mmp_s->mmp_bdevname, fs->device_name,
297 retval = ext2fs_mmp_write(fs, fs->super->s_mmp_block, fs->mmp_buf);
303 retval = ext2fs_mmp_read(fs, fs->super->s_mmp_block, fs->mmp_buf);
313 retval = ext2fs_mmp_write(fs, fs->super->s_mmp_block, fs->mmp_buf);
329 errcode_t ext2fs_mmp_stop(ext2_filsys fs)
334 if (!(fs->super->s_feature_incompat & EXT4_FEATURE_INCOMPAT_MMP) ||
335 !(fs->flags & EXT2_FLAG_RW) || (fs->flags & EXT2_FLAG_SKIP_MMP))
338 retval = ext2fs_mmp_read(fs, fs->super->s_mmp_block, fs->mmp_buf);
343 mmp = fs->mmp_buf;
344 mmp_cmp = fs->mmp_cmp;
351 retval = ext2fs_mmp_write(fs, fs->super->s_mmp_block, fs->mmp_cmp);
354 if (fs->mmp_fd > 0) {
355 close(fs->mmp_fd);
356 fs->mmp_fd = -1;
367 errcode_t ext2fs_mmp_update(ext2_filsys fs)
373 if (!(fs->super->s_feature_incompat & EXT4_FEATURE_INCOMPAT_MMP) ||
374 !(fs->flags & EXT2_FLAG_RW) || (fs->flags & EXT2_FLAG_SKIP_MMP))
378 if (tv.tv_sec - fs->mmp_last_written < EXT2_MIN_MMP_UPDATE_INTERVAL)
381 retval = ext2fs_mmp_read(fs, fs->super->s_mmp_block, NULL);
385 mmp = fs->mmp_buf;
386 mmp_cmp = fs->mmp_cmp;
393 retval = ext2fs_mmp_write(fs, fs->super->s_mmp_block, fs->mmp_buf);