chore: sync repo

This commit is contained in:
d0p1 🏳️‍⚧️ 2024-07-21 09:32:17 +00:00
parent 8781f567e6
commit ae2abce732
20 changed files with 4399 additions and 743 deletions

View file

@ -1,4 +1,5 @@
obj-m=$(module_DATA)
obj-m += stpdfs.o
stpdfs-objs := $(module_DATA)
MI_OBJS = $(module_DATA)
all clean:

4
compile_flags.txt Normal file
View file

@ -0,0 +1,4 @@
-I.
-I/usr/include/fuse3
-Ilib
-DHAVE_CONFIG_H

1807
config.guess vendored Executable file

File diff suppressed because it is too large Load diff

1960
config.sub vendored Executable file

File diff suppressed because it is too large Load diff

View file

@ -21,7 +21,7 @@ AS_IF([ test "x$host_os" != "xmingw32" ], [
])
AM_CONDITIONAL(BUILD_FUSE, test "x$host_os" != "xmingw32")
AM_CONDITIONAL(BUILD_LINUX, test "x$host_os" = "xlinux")
AM_CONDITIONAL(BUILD_LINUX, test "x$host_os" = "xlinux-gnu")
AC_CHECK_INCLUDES_DEFAULT

BIN
hdd Normal file

Binary file not shown.

139
include/stupidfs.h Normal file
View file

@ -0,0 +1,139 @@
/**
* \file stupidfs.h
*
* StupidFS
* ```
*
* Boot blockSuper blockInodes...InodesData...Data
*
* ```
*/
#ifndef STPDFS_H
# define STPDFS_H 1
# ifndef __KERNEL__
# include <stdint.h>
# include <stddef.h>
# endif
# define STPDFS_SB_MAGIC 0x44505453
# define STPDFS_SB_REV STPDFS_SB_REV_1
# define STPDFS_SB_REV_1 1
# define STPDFS_INO_ROOTDIR 1
# define STPDFS_BLOCK_SIZE 512
# define STPDFS_NAME_MAX 28
# define STPDFS_INODES_PER_BLOCK (STPDFS_BLOCK_SIZE / (sizeof(struct stpdfs_inode)))
# define STPDFS_ZONES_PER_BLOCK (STPDFS_BLOCK_SIZE / sizeof(uint32_t))
# define STPDFS_DIRENT_PER_BLOCK (STPDFS_BLOCK_SIZE / (sizeof(struct stpdfs_dirent)))
# define STPDFS_NDIR 7
# define STPDFS_ROOT_INO 1
# define STPDFS_INO_FLAG_ALOC (1 << 15)
# define STPDFS_INO_FLAG_LZP (1 << 1)
# define STPDFS_INO_FLAG_ENC (1 << 2)
# define STPDFS_S_IFMT 0xF000
# define STPDFS_S_IFSOCK 0xA000
# define STPDFS_S_IFLNK 0xC000
# define STPDFS_S_IFREG 0x8000
# define STPDFS_S_IFBLK 0x6000
# define STPDFS_S_IFDIR 0x4000
# define STPDFS_S_ISUID 0x0800
# define STPDFS_S_ISGID 0x0400
# define STPDFS_S_ISVTX 0x0200
# define STPDFS_S_IRWXU 0x01C0
# define STPDFS_S_IRUSR 0x0100
# define STPDFS_S_IWUSR 0x0080
# define STPDFS_S_IXUSR 0x0040
# define STPDFS_S_IRWXG 0x0038
# define STPDFS_S_IRGRP 0x0020
# define STPDFS_S_IWGRP 0x0010
# define STPDFS_S_IXGRP 0x0008
# define STPDFS_S_IRWXO 0x0007
# define STPDFS_S_IROTH 0x0004
# define STPDFS_S_IWOTH 0x0002
# define STPDFS_S_IXOTH 0x0001
/**
* \brief free block list
* ```
*
* block 99
*
* block 98
*
* ...
*
* block 2
*
* block 1
*
* block 0 block 99
*
* ...
*
* block 0 block 99
*
* ...
*
* block 0
*
* ```
*/
struct stpdfs_free {
uint32_t free[100];
uint8_t nfree;
} __attribute__((packed));
enum stpdfs_state {
STPDFS_CLEANLY_UNMOUNTED = 0,
STPDFS_ERROR = 1,
STPDFS_DIRTY = 1,
};
/**
* \brief StupidFS Superblock
*/
struct stpdfs_sb {
uint32_t magic; /**< MUST be \ref STPDFS_SB_MAGIC */
uint32_t isize; /**< size in block of the I list */
uint32_t fsize; /**< size in block of the entire volume */
struct stpdfs_free freelist; /**< \see stpdfs_free */
uint8_t revision; /**< MUST be \ref STPDFS_SB_REV */
uint16_t state; /**< \see stpdfs_state */
uint64_t time; /**< last time the superblock was modified */
} __attribute__((packed));
#define STPDFS_SB_SIZE sizeof(struct stpdfs_sb)
/**
* \brief StupidFS I-node
*/
struct stpdfs_inode {
uint16_t mode; /**< file mode */
uint16_t nlink; /**< link count */
uint16_t uid; /**< owner user id */
uint16_t gid; /**< group id */
uint16_t flags;
uint32_t size;
uint32_t zones[10];
uint64_t actime;
uint64_t modtime;
} __attribute__((packed));
#define STPDFS_INODE_SIZE sizeof(struct inode)
struct stpdfs_dirent {
uint32_t inode;
char filename[STPDFS_NAME_MAX];
};
#define STPDFS_DIRENT_SIZE sizeof(struct stpdfs_dirent)
#endif /* !STPDFS_H */

View file

@ -1,7 +1,8 @@
noinst_LIBRARIES = libstpdfs.a
libstpdfs_a_SOURCES = block.c \
inode.c \
dir.c
dir.c \
data.c \
superblock.c \
compression/lzp.c \
crypto/hchacha.c \

View file

@ -42,13 +42,13 @@ stpdfs_alloc_block(int fd, struct stpdfs_sb *sb)
sb->state = STPDFS_DIRTY; /* mark state dirty */
redo:
sb->nfree--;
blocknum = sb->free[sb->nfree];
if (sb->nfree == 0 && blocknum != 0)
sb->freelist.nfree--;
blocknum = sb->freelist.free[sb->freelist.nfree];
if (sb->freelist.nfree == 0 && blocknum != 0)
{
stpdfs_read(fd, blocknum, &freelist, sizeof(struct stpdfs_free));
memcpy(sb->free, &freelist, sizeof(uint32_t) * 100);
sb->nfree = freelist.nfree;
memcpy(sb->freelist.free, &freelist, sizeof(uint32_t) * 100);
sb->freelist.nfree = freelist.nfree;
goto redo;
}
@ -69,19 +69,19 @@ stpdfs_free_block(int fd, struct stpdfs_sb *sb, uint32_t blocknum)
sb->state = STPDFS_DIRTY; /* mark state dirty */
if (sb->nfree == 100)
if (sb->freelist.nfree == 100)
{
memcpy(&copy, sb->free, sizeof(uint32_t) * 100);
copy.nfree = sb->nfree;
memcpy(&copy, sb->freelist.free, sizeof(uint32_t) * 100);
copy.nfree = sb->freelist.nfree;
stpdfs_write(fd, blocknum, &copy, sizeof(struct stpdfs_free));
sb->nfree = 1;
sb->free[0] = blocknum;
sb->freelist.nfree = 1;
sb->freelist.free[0] = blocknum;
}
else
{
sb->free[sb->nfree++] = blocknum;
sb->freelist.free[sb->freelist.nfree++] = blocknum;
}
sb->time = time(NULL);

View file

@ -1,82 +1,180 @@
#include "stpdfs.h"
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
static void
write_indirect(int fd, struct stpdfs_sb *sb, struct stpdfs_inode *inode, size_t zone, uint8_t *buffer, size_t size)
{
}
static void
write_zone(int fd, struct stpdfs_sb *sb, struct stpdfs_inode *inode, size_t zone, uint8_t *buffer, size_t size)
static int
stpdfs_write_indirect(int fd, uint32_t blocknum, uint8_t *buffer, size_t size)
{
uint32_t zones[128];
size_t i;
uint32_t zones[STPDFS_ZONES_PER_BLOCK];
size_t byte_read;
if (zone < 7)
{
if (inode->zones[zone] == 0)
{
inode->zones[zone] = stpdfs_alloc_block(fd, sb);
}
stpdfs_write(fd, inode->zones[zone], buffer, size);
stpdfs_read(fd, blocknum, zones, sizeof(zones));
return;
}
if (zone < 135)
byte_read = 0;
for (i = 0; i < STPDFS_ZONES_PER_BLOCK; i++)
{
if (inode->zones[7] == 0)
{
inode->zones[7] = stpdfs_alloc_block(fd, sb);
memset(zones, 0, 512);
stpdfs_write(fd, inode->zones[7], zones, 512);
}
stpdfs_read(fd, zones[i], buffer, STPDFS_BLOCK_SIZE);
byte_read += STPDFS_BLOCK_SIZE;
stpdfs_read(fd, inode->zones[7], zones, 512);
if (zones[zone - 7] == 0)
if (byte_read >= size)
{
zones[zone - 7] = stpdfs_alloc_block(fd, sb);
stpdfs_write(fd, inode->zones[7], zones, 512);
}
stpdfs_write(fd, zones[zone - 7], buffer, size);
return;
}
if (zone < 16519)
{
if (inode->zones[8] == 0)
{
inode->zones[8] = stpdfs_alloc_block(fd, sb);
memset(zones, 0, 512);
stpdfs_write(fd, inode->zones[7], zones, 512);
}
stpdfs_read(fd, inode->zones[8], zones, 512);
if (zones[(zone - 135) / 128] == 0)
{
zones[(zone - 135) / 128] = stpdfs_alloc_block(fd, sb);
return (byte_read);
}
}
return (byte_read);
}
int
stpdfs_write_data(int fd, struct stpdfs_sb *sb, struct stpdfs_inode *inode, uint8_t *buffer, size_t size)
stpdfs_write_data(int fd, struct stpdfs_sb *sb, struct stpdfs_inode *inode, uint8_t *data)
{
size_t idx;
uint32_t zonenum;
size_t max_zone;
size_t i;
size_t j;
size_t byte_write;
uint32_t zones1[STPDFS_ZONES_PER_BLOCK];
uint32_t zones2[STPDFS_ZONES_PER_BLOCK];
for (idx = 0; idx < size; idx += STPDFS_BLOCK_SIZE)
byte_write = 0;
for (i = 0; i < 7; i++)
{
max_zone = idx / STPDFS_BLOCK_SIZE;
for (zonenum = 0; zonenum < max_zone; zonenum++)
if (inode->zones[i] == 0)
{
write_zone(fd, sb, inode, zonenum, buffer + idx, ((idx + 1) * 512) > size ? size % 512 : 512);
inode->zones[i] = stpdfs_alloc_block(fd, sb);
}
stpdfs_write(fd, inode->zones[i], data + byte_write, (inode->size - byte_write) >= STPDFS_BLOCK_SIZE ? STPDFS_BLOCK_SIZE : (inode->size - byte_write));
byte_write += STPDFS_BLOCK_SIZE;
if (byte_write >= inode->size)
{
return (byte_write);
}
}
/*
byte_read += stpdfs_write_indirect(fd, inode->zones[7], *buffer + byte_read, inode->size - byte_read);
if (byte_read >= inode->size)
{
return (byte_read);
}
stpdfs_read(fd, inode->zones[8], zones1, sizeof(zones1));
for (i = 0; i < STPDFS_ZONES_PER_BLOCK; i++)
{
byte_read += stpdfs_read_indirect(fd, zones1[i], *buffer + byte_read, inode->size - byte_read);
if (byte_read >= inode->size)
{
return (byte_read);
}
}
stpdfs_read(fd, inode->zones[9], zones1, sizeof(zones1));
for (i = 0; i < STPDFS_ZONES_PER_BLOCK; i++)
{
stpdfs_read(fd, zones1[i], zones2, sizeof(zones2));
for (j = 0; j < STPDFS_ZONES_PER_BLOCK; j++)
{
byte_read += stpdfs_read_indirect(fd, zones2[i], *buffer + byte_read, inode->size - byte_read);
if (byte_read >= inode->size)
{
return (byte_read);
}
}
}*/
return (byte_write);
}
static int
stpdfs_read_indirect(int fd, uint32_t blocknum, uint8_t *buffer, size_t size)
{
size_t i;
uint32_t zones[STPDFS_ZONES_PER_BLOCK];
size_t byte_read;
stpdfs_read(fd, blocknum, zones, sizeof(zones));
byte_read = 0;
for (i = 0; i < STPDFS_ZONES_PER_BLOCK; i++)
{
stpdfs_read(fd, zones[i], buffer, STPDFS_BLOCK_SIZE);
byte_read += STPDFS_BLOCK_SIZE;
if (byte_read >= size)
{
return (byte_read);
}
}
return (byte_read);
}
int
stpdfs_read_data(int fd, struct stpdfs_sb *sb, struct stpdfs_inode *inode, uint8_t **buffer)
{
size_t i;
size_t j;
size_t byte_read;
uint32_t zones1[STPDFS_ZONES_PER_BLOCK];
uint32_t zones2[STPDFS_ZONES_PER_BLOCK];
*buffer = (uint8_t *)malloc(inode->size + STPDFS_BLOCK_SIZE);
byte_read = 0;
for (i = 0; i < 7; i++)
{
stpdfs_read(fd, inode->zones[i], *buffer, STPDFS_BLOCK_SIZE);
byte_read += STPDFS_BLOCK_SIZE;
if (byte_read >= inode->size)
{
return (byte_read);
}
}
byte_read += stpdfs_read_indirect(fd, inode->zones[7], *buffer + byte_read, inode->size - byte_read);
if (byte_read >= inode->size)
{
return (byte_read);
}
stpdfs_read(fd, inode->zones[8], zones1, sizeof(zones1));
for (i = 0; i < STPDFS_ZONES_PER_BLOCK; i++)
{
byte_read += stpdfs_read_indirect(fd, zones1[i], *buffer + byte_read, inode->size - byte_read);
if (byte_read >= inode->size)
{
return (byte_read);
}
}
stpdfs_read(fd, inode->zones[9], zones1, sizeof(zones1));
for (i = 0; i < STPDFS_ZONES_PER_BLOCK; i++)
{
stpdfs_read(fd, zones1[i], zones2, sizeof(zones2));
for (j = 0; j < STPDFS_ZONES_PER_BLOCK; j++)
{
byte_read += stpdfs_read_indirect(fd, zones2[i], *buffer + byte_read, inode->size - byte_read);
if (byte_read >= inode->size)
{
return (byte_read);
}
}
}
return (0)
return (byte_read);
}

View file

@ -4,60 +4,15 @@
#include <stdlib.h>
int
stpdfs_dir_add_entry(int fd, uint8_t inonum, const char *name, uint32_t target)
stpdfs_dir_add_entry(int fd, struct stpdfs_sb *sb, uint32_t inonum, const char *name, uint32_t target)
{
struct stpdfs_inode inode;
struct stpdfs_dirent dirent[STPDFS_DIRENT_PER_BLOCK];
struct stpdfs_sb sb;
size_t max_zone;
size_t zone;
uint32_t blocknum;
stpdfs_read_superblock(fd, &sb);
stpdfs_read_inode(fd, inonum, &inode);
if (!(inode.mode & STPDFS_S_IFDIR))
{
return (-1);
}
max_zone = (inode.size + sizeof(struct stpdfs_dirent)) / STPDFS_DIRENT_PER_BLOCK;
zone = max_zone;
if (max_zone > 2113671)
{
}
if (max_zone > 16519)
{
}
else if (max_zone > 135)
{
}
else if (max_zone > 7)
{
}
else
{
if (inode.zones[max_zone] == 0)
{
inode.zones[max_zone] = stpdfs_alloc_block(fd, &sb);
}
blocknum = inode.zones[max_zone];
}
stpdfs_read(fd, blocknum, &dirent, sizeof(struct stpdfs_dirent) * STPDFS_DIRENT_PER_BLOCK);
dirent[inode.size % STPDFS_DIRENT_PER_BLOCK].inode = target;
memcpy(dirent[inode.size % STPDFS_DIRENT_PER_BLOCK].filename, name, STPDFS_NAME_MAX);
stpdfs_write(fd, blocknum, &dirent, sizeof(struct stpdfs_dirent) * STPDFS_DIRENT_PER_BLOCK);
inode.size += sizeof(struct stpdfs_dirent);
stpdfs_write_inode(fd, inonum, &inode);
stpdfs_write(fd, 1, &sb, sizeof(struct stpdfs_sb));
return (0);
}

View file

@ -8,7 +8,6 @@
*
* ```
*/
#include <cstdint>
#ifndef STPDFS_H
# define STPDFS_H 1
@ -27,8 +26,9 @@
# define STPDFS_NAME_MAX 28
# define STPDFS_INODES_PER_BLOCK (STPDFS_BLOCK_SIZE / (sizeof(struct stpdfs_inode)))
# define STPDFS_ZONES_PER_BLOCK (STPDFS_BLOCK_SIZE / sizeof(uint32_t))
# define STPDFS_DIRENT_PER_BLOCK (STPDFS_BLOCK_SIZE / (sizeof(struct stpdfs_dirent)))
# define STPDFS_NDIR 7
# define STPDFS_ROOT_INO 1
# define STPDFS_INO_FLAG_ALOC (1 << 15)
@ -43,9 +43,27 @@
# define STPDFS_S_IFBLK 0x6000
# define STPDFS_S_IFDIR 0x4000
# define STPDFS_S_ISUID 0x0800
# define STPDFS_S_ISGID 0x0400
# define STPDFS_S_ISVTX 0x0200
# define STPDFS_S_IRWXU 0x01C0
# define STPDFS_S_IRUSR 0x0100
# define STPDFS_S_IWUSR 0x0080
# define STPDFS_S_IXUSR 0x0040
# define STPDFS_S_IRWXG 0x0038
# define STPDFS_S_IRGRP 0x0020
# define STPDFS_S_IWGRP 0x0010
# define STPDFS_S_IXGRP 0x0008
# define STPDFS_S_IRWXO 0x0007
# define STPDFS_S_IROTH 0x0004
# define STPDFS_S_IWOTH 0x0002
# define STPDFS_S_IXOTH 0x0001
typedef uint32_t zone_t; /**< zone number */
typedef uint32_t block_t; /**< block number */
typedef uint32_t ino_t;
/**
* \brief free block list
@ -117,7 +135,7 @@ struct stpdfs_inode {
#define STPDFS_INODE_SIZE sizeof(struct inode)
struct stpdfs_dirent {
ino_t inode;
uint32_t inode;
char filename[STPDFS_NAME_MAX];
};

View file

@ -5,8 +5,8 @@ MOD_DEVDIR = $(PWD)
export module_DATA
EXTRA_PROGRAMS = stpdfs_module
stpdfs_module_SOURCES = module.c
module_DATA = module.o
stpdfs_module_SOURCES = module.c super.c
module_DATA = module.o super.o
$(module_DATA): $(stpdfs_module_SOURCES)
mv Makefile Makefile.automake

View file

@ -1,610 +0,0 @@
# Makefile.in generated by automake 1.16.5 from Makefile.am.
# linux/Makefile. Generated from Makefile.in by configure.
# Copyright (C) 1994-2021 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE.
am__is_gnu_make = { \
if test -z '$(MAKELEVEL)'; then \
false; \
elif test -n '$(MAKE_HOST)'; then \
true; \
elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \
true; \
else \
false; \
fi; \
}
am__make_running_with_option = \
case $${target_option-} in \
?) ;; \
*) echo "am__make_running_with_option: internal error: invalid" \
"target option '$${target_option-}' specified" >&2; \
exit 1;; \
esac; \
has_opt=no; \
sane_makeflags=$$MAKEFLAGS; \
if $(am__is_gnu_make); then \
sane_makeflags=$$MFLAGS; \
else \
case $$MAKEFLAGS in \
*\\[\ \ ]*) \
bs=\\; \
sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \
| sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \
esac; \
fi; \
skip_next=no; \
strip_trailopt () \
{ \
flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \
}; \
for flg in $$sane_makeflags; do \
test $$skip_next = yes && { skip_next=no; continue; }; \
case $$flg in \
*=*|--*) continue;; \
-*I) strip_trailopt 'I'; skip_next=yes;; \
-*I?*) strip_trailopt 'I';; \
-*O) strip_trailopt 'O'; skip_next=yes;; \
-*O?*) strip_trailopt 'O';; \
-*l) strip_trailopt 'l'; skip_next=yes;; \
-*l?*) strip_trailopt 'l';; \
-[dEDm]) skip_next=yes;; \
-[JT]) skip_next=yes;; \
esac; \
case $$flg in \
*$$target_option*) has_opt=yes; break;; \
esac; \
done; \
test $$has_opt = yes
am__make_dryrun = (target_option=n; $(am__make_running_with_option))
am__make_keepgoing = (target_option=k; $(am__make_running_with_option))
pkgdatadir = $(datadir)/stupidfs
pkgincludedir = $(includedir)/stupidfs
pkglibdir = $(libdir)/stupidfs
pkglibexecdir = $(libexecdir)/stupidfs
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
install_sh_DATA = $(install_sh) -c -m 644
install_sh_PROGRAM = $(install_sh) -c
install_sh_SCRIPT = $(install_sh) -c
INSTALL_HEADER = $(INSTALL_DATA)
transform = $(program_transform_name)
NORMAL_INSTALL = :
PRE_INSTALL = :
POST_INSTALL = :
NORMAL_UNINSTALL = :
PRE_UNINSTALL = :
POST_UNINSTALL = :
build_triplet = x86_64-w64-mingw32
host_triplet = x86_64-w64-mingw32
EXTRA_PROGRAMS = stpdfs_module$(EXEEXT)
subdir = linux
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/configure.ac
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON)
mkinstalldirs = $(install_sh) -d
CONFIG_CLEAN_FILES =
CONFIG_CLEAN_VPATH_FILES =
am_stpdfs_module_OBJECTS = module.$(OBJEXT)
stpdfs_module_OBJECTS = $(am_stpdfs_module_OBJECTS)
stpdfs_module_LDADD = $(LDADD)
AM_V_P = $(am__v_P_$(V))
am__v_P_ = $(am__v_P_$(AM_DEFAULT_VERBOSITY))
am__v_P_0 = false
am__v_P_1 = :
AM_V_GEN = $(am__v_GEN_$(V))
am__v_GEN_ = $(am__v_GEN_$(AM_DEFAULT_VERBOSITY))
am__v_GEN_0 = @echo " GEN " $@;
am__v_GEN_1 =
AM_V_at = $(am__v_at_$(V))
am__v_at_ = $(am__v_at_$(AM_DEFAULT_VERBOSITY))
am__v_at_0 = @
am__v_at_1 =
DEFAULT_INCLUDES = -I.
depcomp = $(SHELL) $(top_srcdir)/depcomp
am__maybe_remake_depfiles = depfiles
am__depfiles_remade = ./$(DEPDIR)/module.Po
am__mv = mv -f
COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
AM_V_CC = $(am__v_CC_$(V))
am__v_CC_ = $(am__v_CC_$(AM_DEFAULT_VERBOSITY))
am__v_CC_0 = @echo " CC " $@;
am__v_CC_1 =
CCLD = $(CC)
LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
AM_V_CCLD = $(am__v_CCLD_$(V))
am__v_CCLD_ = $(am__v_CCLD_$(AM_DEFAULT_VERBOSITY))
am__v_CCLD_0 = @echo " CCLD " $@;
am__v_CCLD_1 =
SOURCES = $(stpdfs_module_SOURCES)
DIST_SOURCES = $(stpdfs_module_SOURCES)
am__can_run_installinfo = \
case $$AM_UPDATE_INFO_DIR in \
n|no|NO) false;; \
*) (install-info --version) >/dev/null 2>&1;; \
esac
am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
am__vpath_adj = case $$p in \
$(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
*) f=$$p;; \
esac;
am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`;
am__install_max = 40
am__nobase_strip_setup = \
srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'`
am__nobase_strip = \
for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||"
am__nobase_list = $(am__nobase_strip_setup); \
for p in $$list; do echo "$$p $$p"; done | \
sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \
$(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \
if (++n[$$2] == $(am__install_max)) \
{ print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \
END { for (dir in files) print dir, files[dir] }'
am__base_list = \
sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \
sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g'
am__uninstall_files_from_dir = { \
test -z "$$files" \
|| { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \
|| { echo " ( cd '$$dir' && rm -f" $$files ")"; \
$(am__cd) "$$dir" && rm -f $$files; }; \
}
am__installdirs = "$(DESTDIR)$(moduledir)"
DATA = $(module_DATA)
am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
# Read a list of newline-separated strings from the standard input,
# and print each of them once, without duplicates. Input order is
# *not* preserved.
am__uniquify_input = $(AWK) '\
BEGIN { nonempty = 0; } \
{ items[$$0] = 1; nonempty = 1; } \
END { if (nonempty) { for (i in items) print i; }; } \
'
# Make sure the list of sources is unique. This is necessary because,
# e.g., the same source file might be shared among _SOURCES variables
# for different programs/libraries.
am__define_uniq_tagged_files = \
list='$(am__tagged_files)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | $(am__uniquify_input)`
am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/depcomp
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
ACLOCAL = ${SHELL} '/c/Users/conta/Workspace/StupidFS/missing' aclocal-1.16
AMTAR = $${TAR-tar}
AM_DEFAULT_VERBOSITY = 1
AR = ar
AUTOCONF = ${SHELL} '/c/Users/conta/Workspace/StupidFS/missing' autoconf
AUTOHEADER = ${SHELL} '/c/Users/conta/Workspace/StupidFS/missing' autoheader
AUTOMAKE = ${SHELL} '/c/Users/conta/Workspace/StupidFS/missing' automake-1.16
AWK = gawk
CC = gcc
CCDEPMODE = depmode=gcc3
CFLAGS = -g -O2
CPP = gcc -E
CPPFLAGS =
CSCOPE = cscope
CTAGS = ctags
CYGPATH_W = cygpath -w
DEFS = -DPACKAGE_NAME=\"StupidFS\" -DPACKAGE_TARNAME=\"stupidfs\" -DPACKAGE_VERSION=\"0.0\" -DPACKAGE_STRING=\"StupidFS\ 0.0\" -DPACKAGE_BUGREPORT=\"\" -DPACKAGE_URL=\"\" -DPACKAGE=\"stupidfs\" -DVERSION=\"0.0\" -DHAVE_STDIO_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_STRINGS_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_UNISTD_H=1 -DSTDC_HEADERS=1
DEPDIR = .deps
ECHO_C =
ECHO_N = -n
ECHO_T =
ETAGS = etags
EXEEXT = .exe
FUSE_CFLAGS =
FUSE_LIBS =
INSTALL = /usr/bin/install -c
INSTALL_DATA = ${INSTALL} -m 644
INSTALL_PROGRAM = ${INSTALL}
INSTALL_SCRIPT = ${INSTALL}
INSTALL_STRIP_PROGRAM = $(install_sh) -c -s
LDFLAGS =
LIBOBJS =
LIBS =
LTLIBOBJS =
MAKEINFO = ${SHELL} '/c/Users/conta/Workspace/StupidFS/missing' makeinfo
MKDIR_P = /usr/bin/mkdir -p
OBJEXT = o
PACKAGE = stupidfs
PACKAGE_BUGREPORT =
PACKAGE_NAME = StupidFS
PACKAGE_STRING = StupidFS 0.0
PACKAGE_TARNAME = stupidfs
PACKAGE_URL =
PACKAGE_VERSION = 0.0
PATH_SEPARATOR = :
PKG_CONFIG = /ucrt64/bin/pkg-config
PKG_CONFIG_LIBDIR =
PKG_CONFIG_PATH = /ucrt64/lib/pkgconfig:/ucrt64/share/pkgconfig
RANLIB = ranlib
SET_MAKE =
SHELL = /bin/sh
STRIP =
VERSION = 0.0
abs_builddir = /c/Users/conta/Workspace/StupidFS/linux
abs_srcdir = /c/Users/conta/Workspace/StupidFS/linux
abs_top_builddir = /c/Users/conta/Workspace/StupidFS
abs_top_srcdir = /c/Users/conta/Workspace/StupidFS
ac_ct_AR = ar
ac_ct_CC = gcc
am__include = include
am__leading_dot = .
am__quote =
am__tar = $${TAR-tar} chof - "$$tardir"
am__untar = $${TAR-tar} xf -
bindir = ${exec_prefix}/bin
build = x86_64-w64-mingw32
build_alias = x86_64-w64-mingw32
build_cpu = x86_64
build_os = mingw32
build_vendor = w64
builddir = .
datadir = ${datarootdir}
datarootdir = ${prefix}/share
docdir = ${datarootdir}/doc/${PACKAGE_TARNAME}
dvidir = ${docdir}
exec_prefix = ${prefix}
host = x86_64-w64-mingw32
host_alias =
host_cpu = x86_64
host_os = mingw32
host_vendor = w64
htmldir = ${docdir}
includedir = ${prefix}/include
infodir = ${datarootdir}/info
install_sh = ${SHELL} /c/Users/conta/Workspace/StupidFS/install-sh
libdir = ${exec_prefix}/lib
libexecdir = ${exec_prefix}/libexec
localedir = ${datarootdir}/locale
localstatedir = ${prefix}/var
mandir = ${datarootdir}/man
mkdir_p = $(MKDIR_P)
oldincludedir = /usr/include
pdfdir = ${docdir}
prefix = /ucrt64
program_transform_name = s,x,x,
psdir = ${docdir}
runstatedir = ${localstatedir}/run
sbindir = ${exec_prefix}/sbin
sharedstatedir = ${prefix}/com
srcdir = .
sysconfdir = ${prefix}/etc
target_alias =
top_build_prefix = ../
top_builddir = ..
top_srcdir = ..
moduledir = @moduledir@
KBUILD_VERBOSE = 1
MOD_DEVDIR = $(PWD)
stpdfs_module_SOURCES = module.c
module_DATA = module.o
CLEANFILES = $(module_DATA) .$(module_DATA).flags $(module_DATA:.o=.mod.c) $(module_DATA:.o=.@kernelext@)
all: all-am
.SUFFIXES:
.SUFFIXES: .c .o .obj
$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
@for dep in $?; do \
case '$(am__configure_deps)' in \
*$$dep*) \
( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
&& { if test -f $@; then exit 0; else break; fi; }; \
exit 1;; \
esac; \
done; \
echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign linux/Makefile'; \
$(am__cd) $(top_srcdir) && \
$(AUTOMAKE) --foreign linux/Makefile
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
@case '$?' in \
*config.status*) \
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
*) \
echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles)'; \
cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles);; \
esac;
$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(top_srcdir)/configure: $(am__configure_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(ACLOCAL_M4): $(am__aclocal_m4_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(am__aclocal_m4_deps):
stpdfs_module$(EXEEXT): $(stpdfs_module_OBJECTS) $(stpdfs_module_DEPENDENCIES) $(EXTRA_stpdfs_module_DEPENDENCIES)
@rm -f stpdfs_module$(EXEEXT)
$(AM_V_CCLD)$(LINK) $(stpdfs_module_OBJECTS) $(stpdfs_module_LDADD) $(LIBS)
mostlyclean-compile:
-rm -f *.$(OBJEXT)
distclean-compile:
-rm -f *.tab.c
include ./$(DEPDIR)/module.Po # am--include-marker
$(am__depfiles_remade):
@$(MKDIR_P) $(@D)
@echo '# dummy' >$@-t && $(am__mv) $@-t $@
am--depfiles: $(am__depfiles_remade)
.c.o:
$(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\
$(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\
$(am__mv) $$depbase.Tpo $$depbase.Po
# $(AM_V_CC)source='$<' object='$@' libtool=no \
# DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) \
# $(AM_V_CC_no)$(COMPILE) -c -o $@ $<
.c.obj:
$(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\
$(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\
$(am__mv) $$depbase.Tpo $$depbase.Po
# $(AM_V_CC)source='$<' object='$@' libtool=no \
# DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) \
# $(AM_V_CC_no)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
install-moduleDATA: $(module_DATA)
@$(NORMAL_INSTALL)
@list='$(module_DATA)'; test -n "$(moduledir)" || list=; \
if test -n "$$list"; then \
echo " $(MKDIR_P) '$(DESTDIR)$(moduledir)'"; \
$(MKDIR_P) "$(DESTDIR)$(moduledir)" || exit 1; \
fi; \
for p in $$list; do \
if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
echo "$$d$$p"; \
done | $(am__base_list) | \
while read files; do \
echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(moduledir)'"; \
$(INSTALL_DATA) $$files "$(DESTDIR)$(moduledir)" || exit $$?; \
done
uninstall-moduleDATA:
@$(NORMAL_UNINSTALL)
@list='$(module_DATA)'; test -n "$(moduledir)" || list=; \
files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \
dir='$(DESTDIR)$(moduledir)'; $(am__uninstall_files_from_dir)
ID: $(am__tagged_files)
$(am__define_uniq_tagged_files); mkid -fID $$unique
tags: tags-am
TAGS: tags
tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
set x; \
here=`pwd`; \
$(am__define_uniq_tagged_files); \
shift; \
if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
test -n "$$unique" || unique=$$empty_fix; \
if test $$# -gt 0; then \
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
"$$@" $$unique; \
else \
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
$$unique; \
fi; \
fi
ctags: ctags-am
CTAGS: ctags
ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
$(am__define_uniq_tagged_files); \
test -z "$(CTAGS_ARGS)$$unique" \
|| $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
$$unique
GTAGS:
here=`$(am__cd) $(top_builddir) && pwd` \
&& $(am__cd) $(top_srcdir) \
&& gtags -i $(GTAGS_ARGS) "$$here"
cscopelist: cscopelist-am
cscopelist-am: $(am__tagged_files)
list='$(am__tagged_files)'; \
case "$(srcdir)" in \
[\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \
*) sdir=$(subdir)/$(srcdir) ;; \
esac; \
for i in $$list; do \
if test -f "$$i"; then \
echo "$(subdir)/$$i"; \
else \
echo "$$sdir/$$i"; \
fi; \
done >> $(top_builddir)/cscope.files
distclean-tags:
-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
distdir: $(BUILT_SOURCES)
$(MAKE) $(AM_MAKEFLAGS) distdir-am
distdir-am: $(DISTFILES)
@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
list='$(DISTFILES)'; \
dist_files=`for file in $$list; do echo $$file; done | \
sed -e "s|^$$srcdirstrip/||;t" \
-e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
case $$dist_files in \
*/*) $(MKDIR_P) `echo "$$dist_files" | \
sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
sort -u` ;; \
esac; \
for file in $$dist_files; do \
if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
if test -d $$d/$$file; then \
dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
if test -d "$(distdir)/$$file"; then \
find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
fi; \
if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
fi; \
cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
else \
test -f "$(distdir)/$$file" \
|| cp -p $$d/$$file "$(distdir)/$$file" \
|| exit 1; \
fi; \
done
check-am: all-am
check: check-am
all-am: Makefile $(DATA)
installdirs:
for dir in "$(DESTDIR)$(moduledir)"; do \
test -z "$$dir" || $(MKDIR_P) "$$dir"; \
done
install: install-am
install-exec: install-exec-am
install-data: install-data-am
uninstall: uninstall-am
install-am: all-am
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
installcheck: installcheck-am
install-strip:
if test -z '$(STRIP)'; then \
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
install; \
else \
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
"INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \
fi
mostlyclean-generic:
clean-generic:
-test -z "$(CLEANFILES)" || rm -f $(CLEANFILES)
distclean-generic:
-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
-test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
maintainer-clean-generic:
@echo "This command is intended for maintainers to use"
@echo "it deletes files that may require special tools to rebuild."
clean: clean-am
clean-am: clean-generic mostlyclean-am
distclean: distclean-am
-rm -f ./$(DEPDIR)/module.Po
-rm -f Makefile
distclean-am: clean-am distclean-compile distclean-generic \
distclean-tags
dvi: dvi-am
dvi-am:
html: html-am
html-am:
info: info-am
info-am:
install-data-am: install-moduleDATA
install-dvi: install-dvi-am
install-dvi-am:
install-exec-am:
install-html: install-html-am
install-html-am:
install-info: install-info-am
install-info-am:
install-man:
install-pdf: install-pdf-am
install-pdf-am:
install-ps: install-ps-am
install-ps-am:
installcheck-am:
maintainer-clean: maintainer-clean-am
-rm -f ./$(DEPDIR)/module.Po
-rm -f Makefile
maintainer-clean-am: distclean-am maintainer-clean-generic
mostlyclean: mostlyclean-am
mostlyclean-am: mostlyclean-compile mostlyclean-generic
pdf: pdf-am
pdf-am:
ps: ps-am
ps-am:
uninstall-am: uninstall-moduleDATA
.MAKE: install-am install-strip
.PHONY: CTAGS GTAGS TAGS all all-am am--depfiles check check-am clean \
clean-generic cscopelist-am ctags ctags-am distclean \
distclean-compile distclean-generic distclean-tags distdir dvi \
dvi-am html html-am info info-am install install-am \
install-data install-data-am install-dvi install-dvi-am \
install-exec install-exec-am install-html install-html-am \
install-info install-info-am install-man install-moduleDATA \
install-pdf install-pdf-am install-ps install-ps-am \
install-strip installcheck installcheck-am installdirs \
maintainer-clean maintainer-clean-generic mostlyclean \
mostlyclean-compile mostlyclean-generic pdf pdf-am ps ps-am \
tags tags-am uninstall uninstall-am uninstall-moduleDATA
.PRECIOUS: Makefile
export module_DATA
$(module_DATA): $(stpdfs_module_SOURCES)
mv Makefile Makefile.automake
cp $(srcdir)/../Makefile.kernel Makefile
CPPFLAGS="" CFLAGS="" LDFLAGS="" \
$(MAKE) -C /lib/modules/$(shell uname -r)/build \
ARCH="x86" CC="gcc" M=$(PWD) modules\
KBUILD_VERBOSE=$(KBUILD_VERBOSE)
mv Makefile.automake Makefile
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
.NOEXPORT:

View file

@ -2,19 +2,70 @@
* \addtogroup driver
* @{
*/
#include <linux/init.h>
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
#include <linux/fs.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include "module.h"
/**
* \defgroup linux Linux Kernel Module
* @{
*/
struct dentry *
stpdfs_mount(struct file_system_type *fs_type, int flags,
const char *devname, void *data)
{
struct dentry *dentry;
dentry = mount_bdev(fs_type, flags, devname, data, stpdfs_fill_super);
if (IS_ERR(dentry))
{
pr_err("'%s' mount failure\n", devname);
}
else
{
pr_info("'%s' mount success\n", devname);
}
return (dentry);
}
void
stpdfs_kill_sb(struct super_block *sb)
{
(void)sb;
}
static struct file_system_type stpdfs_file_system_type = {
.owner = THIS_MODULE,
.name = "stupidfs",
.mount = stpdfs_mount,
.kill_sb = stpdfs_kill_sb,
.fs_flags = FS_REQUIRES_DEV,
.next = NULL,
};
static int __init
stpdfs_mod_init(void)
{
printk("Hello, world!\n");
return 0;
int ret;
ret = register_filesystem(&stpdfs_file_system_type);
if (ret != 0)
{
pr_err("Failed to register filesystem\n");
goto err;
}
pr_info("module loaded\n");
return (0);
err:
return (ret);
}
module_init(stpdfs_mod_init);
@ -22,7 +73,12 @@ module_init(stpdfs_mod_init);
static void __exit
stpdfs_mod_exit(void)
{
printk("Goodbye, world!\n");
if (unregister_filesystem(&stpdfs_file_system_type) != 0)
{
pr_err("Failed to unregister filesystem\n");
}
pr_info("module unloaded\n");
}
module_exit(stpdfs_mod_exit);

15
linux/module.h Normal file
View file

@ -0,0 +1,15 @@
#ifndef MODULE_H
# define MODULE_H
# include "../include/stupidfs.h"
struct stpdfs_sb_info {
struct stpdfs_sb sb;
uint32_t freeblock;
uint32_t freeinode;
};
int stpdfs_fill_super(struct super_block *sb, void *data, int silent);
#endif /* !MODULE_H */

59
linux/super.c Normal file
View file

@ -0,0 +1,59 @@
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
#include <linux/buffer_head.h>
#include <linux/fs.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/slab.h>
#include <linux/statfs.h>
#include <linux/blkdev.h>
#include <linux/jbd2.h>
#include <linux/namei.h>
#include <linux/parser.h>
#include "module.h"
static struct super_operations stpdfs_super_ops = {
};
int
stpdfs_fill_super(struct super_block *sb, void *data, int silent)
{
struct buffer_head *bh = NULL;
struct stpdfs_sb_info *sbi = NULL;
sb->s_magic = STPDFS_SB_MAGIC;
sb_set_blocksize(sb, STPDFS_BLOCK_SIZE);
sb->s_maxbytes = (u32)-1;
sb->s_op = &stpdfs_super_ops;
bh = sb_bread(sb, 1);
if (bh == NULL)
{
return (-EIO);
}
if (((struct stpdfs_sb *)bh->b_data)->magic != sb->s_magic)
{
pr_err("Invalid magic number\n");
brelse(bh);
return (-EINVAL);
}
sbi = kzalloc(sizeof(struct stpdfs_sb), GFP_KERNEL);
if (sbi == NULL)
{
brelse(bh);
return (-ENOMEM);
}
memcpy(&sbi->sb, bh->b_data, sizeof(struct stpdfs_sb));
sb->s_fs_info = sbi;
brelse(bh);
return (0);
}

153
test-driver Executable file
View file

@ -0,0 +1,153 @@
#! /bin/sh
# test-driver - basic testsuite driver script.
scriptversion=2018-03-07.03; # UTC
# Copyright (C) 2011-2021 Free Software Foundation, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
# As a special exception to the GNU General Public License, if you
# distribute this file as part of a program that contains a
# configuration script generated by Autoconf, you may include it under
# the same distribution terms that you use for the rest of that program.
# This file is maintained in Automake, please report
# bugs to <bug-automake@gnu.org> or send patches to
# <automake-patches@gnu.org>.
# Make unconditional expansion of undefined variables an error. This
# helps a lot in preventing typo-related bugs.
set -u
usage_error ()
{
echo "$0: $*" >&2
print_usage >&2
exit 2
}
print_usage ()
{
cat <<END
Usage:
test-driver --test-name NAME --log-file PATH --trs-file PATH
[--expect-failure {yes|no}] [--color-tests {yes|no}]
[--enable-hard-errors {yes|no}] [--]
TEST-SCRIPT [TEST-SCRIPT-ARGUMENTS]
The '--test-name', '--log-file' and '--trs-file' options are mandatory.
See the GNU Automake documentation for information.
END
}
test_name= # Used for reporting.
log_file= # Where to save the output of the test script.
trs_file= # Where to save the metadata of the test run.
expect_failure=no
color_tests=no
enable_hard_errors=yes
while test $# -gt 0; do
case $1 in
--help) print_usage; exit $?;;
--version) echo "test-driver $scriptversion"; exit $?;;
--test-name) test_name=$2; shift;;
--log-file) log_file=$2; shift;;
--trs-file) trs_file=$2; shift;;
--color-tests) color_tests=$2; shift;;
--expect-failure) expect_failure=$2; shift;;
--enable-hard-errors) enable_hard_errors=$2; shift;;
--) shift; break;;
-*) usage_error "invalid option: '$1'";;
*) break;;
esac
shift
done
missing_opts=
test x"$test_name" = x && missing_opts="$missing_opts --test-name"
test x"$log_file" = x && missing_opts="$missing_opts --log-file"
test x"$trs_file" = x && missing_opts="$missing_opts --trs-file"
if test x"$missing_opts" != x; then
usage_error "the following mandatory options are missing:$missing_opts"
fi
if test $# -eq 0; then
usage_error "missing argument"
fi
if test $color_tests = yes; then
# Keep this in sync with 'lib/am/check.am:$(am__tty_colors)'.
red='' # Red.
grn='' # Green.
lgn='' # Light green.
blu='' # Blue.
mgn='' # Magenta.
std='' # No color.
else
red= grn= lgn= blu= mgn= std=
fi
do_exit='rm -f $log_file $trs_file; (exit $st); exit $st'
trap "st=129; $do_exit" 1
trap "st=130; $do_exit" 2
trap "st=141; $do_exit" 13
trap "st=143; $do_exit" 15
# Test script is run here. We create the file first, then append to it,
# to ameliorate tests themselves also writing to the log file. Our tests
# don't, but others can (automake bug#35762).
: >"$log_file"
"$@" >>"$log_file" 2>&1
estatus=$?
if test $enable_hard_errors = no && test $estatus -eq 99; then
tweaked_estatus=1
else
tweaked_estatus=$estatus
fi
case $tweaked_estatus:$expect_failure in
0:yes) col=$red res=XPASS recheck=yes gcopy=yes;;
0:*) col=$grn res=PASS recheck=no gcopy=no;;
77:*) col=$blu res=SKIP recheck=no gcopy=yes;;
99:*) col=$mgn res=ERROR recheck=yes gcopy=yes;;
*:yes) col=$lgn res=XFAIL recheck=no gcopy=yes;;
*:*) col=$red res=FAIL recheck=yes gcopy=yes;;
esac
# Report the test outcome and exit status in the logs, so that one can
# know whether the test passed or failed simply by looking at the '.log'
# file, without the need of also peaking into the corresponding '.trs'
# file (automake bug#11814).
echo "$res $test_name (exit status: $estatus)" >>"$log_file"
# Report outcome to console.
echo "${col}${res}${std}: $test_name"
# Register the test result, and other relevant metadata.
echo ":test-result: $res" > $trs_file
echo ":global-test-result: $res" >> $trs_file
echo ":recheck: $recheck" >> $trs_file
echo ":copy-in-global-log: $gcopy" >> $trs_file
# Local Variables:
# mode: shell-script
# sh-indentation: 2
# eval: (add-hook 'before-save-hook 'time-stamp)
# time-stamp-start: "scriptversion="
# time-stamp-format: "%:y-%02m-%02d.%02H"
# time-stamp-time-zone: "UTC0"
# time-stamp-end: "; # UTC"
# End:

View file

@ -124,7 +124,7 @@ mkfs()
super.revision = STPDFS_SB_REV;
super.isize = inodes / STPDFS_INODES_PER_BLOCK;
super.fsize = blocks;
super.nfree = 0;
super.freelist.nfree = 0;
/* write inodes */
lseek(fd, 2 * STPDFS_BLOCK_SIZE, SEEK_SET);
@ -150,7 +150,7 @@ mkfs()
inds[STPDFS_INO_ROOTDIR].actime = time(NULL);
inds[STPDFS_INO_ROOTDIR].size = sizeof(struct stpdfs_dirent) * 2;
inds[STPDFS_INO_ROOTDIR].flags = STPDFS_INO_FLAG_ALOC;
inds[STPDFS_INO_ROOTDIR].mode = STPDFS_S_IFDIR;
inds[STPDFS_INO_ROOTDIR].mode = STPDFS_S_IFDIR | STPDFS_S_IRUSR | STPDFS_S_IWUSR | STPDFS_S_IXUSR | STPDFS_S_IRGRP | STPDFS_S_IXGRP | STPDFS_S_IXOTH;
inds[STPDFS_INO_ROOTDIR].zones[0] = stpdfs_alloc_block(fd, &super);
inds[STPDFS_INO_ROOTDIR].size = sizeof(struct stpdfs_dirent) * 2;
stpdfs_read(fd, inds[STPDFS_INO_ROOTDIR].zones[0], rootdirent, sizeof(struct stpdfs_dirent) * 2);

BIN
tools/tools.stpd Executable file

Binary file not shown.