Hello, Milos Nikic, le jeu. 26 juin 2025 23:40:22 -0700, a ecrit: > diff --git a/ext2fs/inode.c b/ext2fs/inode.c > index dc309ac8..a3560630 100644 > --- a/ext2fs/inode.c > +++ b/ext2fs/inode.c > /* these flags aren't actually defined by a header file yet, so temporarily > disable them if necessary. */ > @@ -524,6 +525,8 @@ write_all_disknodes (void) > void > diskfs_write_disknode (struct node *np, int wait) > { > + > + journal_log_metadata(np, &(struct journal_entry_info){ .action = "sync" });
Try to get used to the GNU coding style: there should be a space before opening parentheses > struct ext2_inode *di = write_node (np); > if (di) > { > diff --git a/libdiskfs/journal.c b/libdiskfs/journal.c > new file mode 100644 > index 00000000..4c8681dc > --- /dev/null > +++ b/libdiskfs/journal.c > @@ -0,0 +1,260 @@ > +/* Note that you need to add a copyright header, and assign your copyright to the FSF. > + * journal.c - Experimental journaling layer for Hurd's ext2fs/libdiskfs > + * > + * This is a work-in-progress implementation of a toy journaling layer > + * intended for exploration and learning purposes. It logs basic metadata > + * about file changes into a shared in-memory buffer, which is periodically > + * flushed to a file (/tmp/journal.log). > + * > + * Features: > + * - Logs inode metadata (mode, size, nlink, mtime, ctime, etc.) > + * - Each log entry is wrapped in a transaction with a unique ID and > timestamp > + * - Uses a fixed-size in-memory buffer with auto-flushing on overflow > + * - Timestamp includes millisecond precision > + * - Thread-safe using a mutex > + * > + * Missing / Not Implemented Yet: > + * - Write barriers or guarantees of ordering with actual FS operations > + * - Integration at a lower level to capture all metadata changes (not > just sync hooks) > + * - Actual recovery mechanisms or replays from the journal > + * - Logging of inode or block bitmap changes > + * - File name resolution (only available if passed manually) > + * - UID/GID or finer-grained permission changes > + * - Disk-backed circular journal buffer for continuous logging > + * - Atomicity guarantees across flush boundaries (currently only soft > protection) > + * > + * Warning: > + * This code is experimental and not suitable for production. > + * It is designed to support incremental development and learning. > + * > + * Author: Milos Nikic, 2025 > + */ > +#include <stdio.h> > +#include <inttypes.h> > +#include <time.h> > +#include <string.h> > +#include <errno.h> > +#include <sys/stat.h> > +#include <libdiskfs/journal.h> > +#include <diskfs.h> > +#include <sys/types.h> > +#include <stdbool.h> > +#include <stdint.h> > +#include <sys/time.h> > +#include <pthread.h> > + > +#define JOURNAL_DIR_PATH "/tmp" > +#define JOURNAL_LOG_PATH JOURNAL_DIR_PATH "/journal.log" > +#define JOURNAL_BUF_SIZE (64 * 1024) > +#define MAX_REASONABLE_TIME 4102444800 /* Jan 1, 2100 */ > +#define MIN_REASONABLE_TIME 946684800 /* Jan 1, 2000 */ Better take the current time plus / minus a lot of years, so it'll stay a reasonable guess decades from now. Samuel