From: Lawrence S. <ljs...@us...> - 2013-04-24 18:12:46
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "A pseudo Operating System for the Dreamcast.". The branch, master has been updated via e89ecd7b4aff0547687d602c57728337352db2d5 (commit) from 5d101ffceb89cd67b6536158974725c556c39216 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit e89ecd7b4aff0547687d602c57728337352db2d5 Author: Lawrence Sebald <ljs...@us...> Date: Wed Apr 24 14:12:14 2013 -0400 Add the fs_ext2_sync() function to sync all changes to the block device. ----------------------------------------------------------------------- Summary of changes: addons/include/ext2/fs_ext2.h | 24 +++++++++++++++++++----- addons/libkosext2fs/fs_ext2.c | 27 +++++++++++++++++++++++++++ 2 files changed, 46 insertions(+), 5 deletions(-) diff --git a/addons/include/ext2/fs_ext2.h b/addons/include/ext2/fs_ext2.h index 2722af5..e0803de 100644 --- a/addons/include/ext2/fs_ext2.h +++ b/addons/include/ext2/fs_ext2.h @@ -1,7 +1,7 @@ /* KallistiOS ##version## ext2/fs_ext2.h - Copyright (C) 2012 Lawrence Sebald + Copyright (C) 2012, 2013 Lawrence Sebald */ #ifndef __EXT2_FS_EXT2_H @@ -103,10 +103,6 @@ int fs_ext2_shutdown(void); \param flags Mount flags. Bitwise OR of values from ext2_mount_flags \retval 0 On success. \retval -1 On error. - - \note All filesystems will currently be mounted as read-only, - regardless of the flags value. The lower-level ext2fs - code does not support writing at this time. */ int fs_ext2_mount(const char *mp, kos_blockdev_t *dev, uint32_t flags); @@ -121,5 +117,23 @@ int fs_ext2_mount(const char *mp, kos_blockdev_t *dev, uint32_t flags); */ int fs_ext2_unmount(const char *mp); +/** \brief Sync an ext2 filesystem, flushing all pending writes to the block + device. + + This function completes all pending writes on the filesystem, making sure + all data and metadata are in a consistent state on the block device. As both + inode and block writes are normally postponed until they are either evicted + from the cache or the filesystem is unmounted, doing this periodically may + be a good idea if there is a chance that the filesystem will not be + unmounted cleanly. + + \param mp The mount point of the filesystem to be synced. + \retval 0 On success. + \retval -1 On error. + + \note This function has no effect if the filesystem was mounted read-only. +*/ +int fs_ext2_sync(const char *mp); + __END_DECLS #endif /* !__EXT2_FS_EXT2_H */ diff --git a/addons/libkosext2fs/fs_ext2.c b/addons/libkosext2fs/fs_ext2.c index bdc4f7c..cd452b6 100644 --- a/addons/libkosext2fs/fs_ext2.c +++ b/addons/libkosext2fs/fs_ext2.c @@ -1453,6 +1453,33 @@ int fs_ext2_unmount(const char *mp) { return rv; } +int fs_ext2_sync(const char *mp) { + fs_ext2_fs_t *i; + int found = 0, rv = 0; + + /* Find the fs in question */ + mutex_lock(&ext2_mutex); + LIST_FOREACH(i, &ext2_fses, entry) { + if(!strcmp(mp, i->vfsh->nmmgr.pathname)) { + found = 1; + break; + } + } + + if(found) { + /* ext2_fs_sync() will set errno if there's a problem. */ + rv = ext2_fs_sync(i->fs); + } + else { + errno = ENOENT; + rv = -1; + } + + mutex_unlock(&ext2_mutex); + return rv; +} + + int fs_ext2_init(void) { if(initted) return 0; hooks/post-receive -- A pseudo Operating System for the Dreamcast. |