Repository navigation
8000
Expand file tree
/
Copy pathmisc.c
More file actions
98 lines (76 loc) · 2.33 KB
/
Copy pathmisc.c
File metadata and controls
98 lines (76 loc) · 2.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
8000
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
/* Created (MFS based):
* February 2010 (Evgeniy Ivanov)
*/
#include "fs.h"
#include <assert.h>
#include <minix/vfsif.h>
#include <minix/bdev.h>
#include "inode.h"
#include "super.h"
/*===========================================================================*
* fs_sync *
*===========================================================================*/
int fs_sync()
{
/* Perform the sync() system call. Flush all the tables.
* The order in which the various tables are flushed is critical. The
* blocks must be flushed last, since rw_inode() leaves its results in
* the block cache.
*/
struct inode *rip;
assert(lmfs_nr_bufs() > 0);
if (superblock->s_rd_only)
return(OK); /* nothing to sync */
/* Write all the dirty inodes to the disk. */
for(rip = &inode[0]; rip < &inode[NR_INODES]; rip++)
if(rip->i_count > 0 && rip->i_dirt == IN_DIRTY) rw_inode(rip, WRITING);
lmfs_flushall();
if (superblock->s_dev != NO_DEV) {
superblock->s_wtime = clock_time();
write_super(superblock);
}
return(OK); /* sync() can't fail */
}
/*===========================================================================*
* fs_flush *
*===========================================================================*/
int fs_flush()
{
/* Flush the blocks of a device from the cache after writing any dirty blocks
* to disk.
*/
dev_t dev = fs_m_in.m_vfs_fs_flush.device;
if(dev == fs_dev) return(EBUSY);
lmfs_flushall();
lmfs_invalidate(dev);
return(OK);
}
/*===========================================================================*
* fs_new_driver *
*===========================================================================*/
int fs_new_driver(void)
{
/* Set a new driver endpoint for this device. */
dev_t dev;
cp_grant_id_t label_gid;
size_t label_len;
char label[sizeof(fs_dev_label)];
int r;
dev = fs_m_in.m_vfs_fs_new_driver.device;
label_gid = fs_m_in.m_vfs_fs_new_driver.grant;
label_len = fs_m_in.m_vfs_fs_new_driver.path_len;
if (label_len > sizeof(label))
return(EINVAL);
r = sys_safecopyfrom(fs_m_in.m_source, label_gid, (vir_bytes) 0,
(vir_bytes) label, label_len);
if (r != OK) {
printf("ext2: fs_new_driver safecopyfrom failed (%d)\n", r);
return(EINVAL);
}
bdev_driver(dev, label);
return(OK);
}
int fs_bpeek(void)
{
return lmfs_do_bpeek(&fs_m_in);
}
2D2E
div>