diff --git a/apps/sync.c b/apps/sync.c new file mode 100644 index 00000000..dcebe7a1 --- /dev/null +++ b/apps/sync.c @@ -0,0 +1,9 @@ +#include +#include +#include +#include + +int main(int argc, char * argv[]) { + int fd = open(".",O_RDONLY|O_DIRECTORY); + return ioctl(fd, IOCTLSYNC, NULL); +} diff --git a/base/usr/include/sys/ioctl.h b/base/usr/include/sys/ioctl.h index e2fa149e..65f8b35b 100644 --- a/base/usr/include/sys/ioctl.h +++ b/base/usr/include/sys/ioctl.h @@ -10,6 +10,8 @@ #define IOCTLTTYNAME 0x4F01 #define IOCTLTTYLOGIN 0x4F02 +#define IOCTLSYNC 0x4F03 #define IOCTL_PACKETFS_QUEUED 0x5050 + diff --git a/modules/ext2.c b/modules/ext2.c index 83b3cf62..48fb6e63 100644 --- a/modules/ext2.c +++ b/modules/ext2.c @@ -16,6 +16,8 @@ #include #include +#include + #define debug_print(lvl, str, ...) do { if (this->flags & EXT2_FLAG_LOUD) { printf("ext2: %s: " str "\n", #lvl __VA_OPT__(,) __VA_ARGS__); } } while (0) #define EXT2_SUPER_MAGIC 0xEF53 @@ -1559,7 +1561,17 @@ static ssize_t readlink_ext2(fs_node_t * node, char * buf, size_t size) { return read_size; } +static int ioctl_ext2(fs_node_t * node, unsigned long request, void * argp) { + ext2_fs_t * this = (ext2_fs_t *)node->device; + switch (request) { + case IOCTLSYNC: + return ext2_sync(this); + + default: + return -EINVAL; + } +} static int node_from_file(ext2_fs_t * this, ext2_inodetable_t *inode, ext2_dir_t *direntry, fs_node_t *fnode) { if (!fnode) { @@ -1629,7 +1641,7 @@ static int node_from_file(ext2_fs_t * this, ext2_inodetable_t *inode, ext2_dir_t fnode->chmod = chmod_ext2; fnode->open = open_ext2; fnode->close = close_ext2; - fnode->ioctl = NULL; + fnode->ioctl = ioctl_ext2; return 1; }