chore: sync repo
This commit is contained in:
parent
ec0bd60a10
commit
9a8950c304
22
lib/stpdfs.h
22
lib/stpdfs.h
|
@ -5,13 +5,15 @@
|
||||||
|
|
||||||
# define STPDFS_SB_MAGIC 0x44505453
|
# define STPDFS_SB_MAGIC 0x44505453
|
||||||
|
|
||||||
# define STPDFS_BLOCK_SIZE_BITS 10
|
# define STPDFS_BLOCK_SIZE_BITS 9
|
||||||
# define STPDFS_BLOCK_SIZE (1 << STPDFS_BLOCK_SIZE_BITS)
|
# define STPDFS_BLOCK_SIZE (1 << STPDFS_BLOCK_SIZE_BITS)
|
||||||
|
|
||||||
# define STPDFS_NAME_MAX 255
|
# define STPDFS_NAME_MAX 255
|
||||||
|
|
||||||
# define STPDFS_INODES_PER_BLOCK (STPDFS_BLOCK_SIZE / (sizeof(struct stpdfs_inode)))
|
# define STPDFS_INODES_PER_BLOCK (STPDFS_BLOCK_SIZE / (sizeof(struct stpdfs_inode)))
|
||||||
|
|
||||||
|
# define STPDFS_ROOT_INO 1
|
||||||
|
|
||||||
# define STPDFS_LZP_COMPRESSION (1 << 0)
|
# define STPDFS_LZP_COMPRESSION (1 << 0)
|
||||||
# define STPDFS_FILE_ENCRYPTION (1 << 1)
|
# define STPDFS_FILE_ENCRYPTION (1 << 1)
|
||||||
|
|
||||||
|
@ -25,10 +27,10 @@ struct stpdfs_free {
|
||||||
*/
|
*/
|
||||||
struct stpdfs_sb {
|
struct stpdfs_sb {
|
||||||
uint32_t magic;
|
uint32_t magic;
|
||||||
uint32_t isize; /*< size in block of the I list */
|
uint32_t isize; /**< size in block of the I list */
|
||||||
uint32_t fsize; /*< size in block of the entire volume */
|
uint32_t fsize; /**< size in block of the entire volume */
|
||||||
uint32_t free[100];
|
uint32_t free[100];
|
||||||
uint8_t nfree; /*< number of free block (0-100) */
|
uint8_t nfree; /**< number of free block (0-100) */
|
||||||
uint8_t flock;
|
uint8_t flock;
|
||||||
uint8_t ilock;
|
uint8_t ilock;
|
||||||
uint8_t fmod;
|
uint8_t fmod;
|
||||||
|
@ -38,13 +40,13 @@ struct stpdfs_sb {
|
||||||
/**
|
/**
|
||||||
* \brief StupidFS I-node
|
* \brief StupidFS I-node
|
||||||
*/
|
*/
|
||||||
struct inode {
|
struct stpdfs_inode {
|
||||||
uint16_t mode; /*< file mode */
|
uint16_t mode; /**< file mode */
|
||||||
uint8_t nlink; /*< link count */
|
uint8_t nlink; /**< link count */
|
||||||
uint8_t uid; /*< owner user id */
|
uint8_t uid; /**< owner user id */
|
||||||
uint8_t gid; /*< group id */
|
uint8_t gid; /**< group id */
|
||||||
uint32_t size;
|
uint32_t size;
|
||||||
uint16_t addr[8];
|
uint32_t zones[10];
|
||||||
uint32_t actime[2];
|
uint32_t actime[2];
|
||||||
uint32_t modtime[2];
|
uint32_t modtime[2];
|
||||||
} __attribute__((packed));
|
} __attribute__((packed));
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
#include <time.h>
|
||||||
#ifdef HAVE_CONFIG_H
|
#ifdef HAVE_CONFIG_H
|
||||||
# include "config.h"
|
# include "config.h"
|
||||||
#endif /* HAVE_CONFIG_H */
|
#endif /* HAVE_CONFIG_H */
|
||||||
|
@ -114,8 +115,11 @@ mkfs()
|
||||||
write_block(fd, NULL, 0);
|
write_block(fd, NULL, 0);
|
||||||
|
|
||||||
super.magic = STPDFS_SB_MAGIC;
|
super.magic = STPDFS_SB_MAGIC;
|
||||||
|
super.isize = inodes / STPDFS_INODES_PER_BLOCK;
|
||||||
super.fsize = blocks;
|
super.fsize = blocks;
|
||||||
|
|
||||||
|
super.time = time(NULL);
|
||||||
|
|
||||||
write_block(fd, &super, sizeof(struct stpdfs_sb));
|
write_block(fd, &super, sizeof(struct stpdfs_sb));
|
||||||
|
|
||||||
close(fd);
|
close(fd);
|
||||||
|
|
Loading…
Reference in a new issue