Skip to content

Commit

Permalink
many: finish initial valifs driver, add zstd submodule
Browse files Browse the repository at this point in the history
  • Loading branch information
Meulengracht committed Oct 4, 2022
1 parent 2b4bec2 commit 9299546
Show file tree
Hide file tree
Showing 12 changed files with 415 additions and 26 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,6 @@
[submodule "tools/imager"]
path = tools/imager
url = ../diskbuilder
[submodule "librt/zstd"]
path = librt/zstd
url = ../../umbrella-c/zstd
18 changes: 18 additions & 0 deletions librt/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,24 @@ add_subdirectory (libc)
# Libraries that depend on the c lib
add_subdirectory(libyaml)

# build zstd in the static flavor for now. To build the shared one
# we need to fix a few issues in our cmake platform setup
set(ZSTD_LEGACY_SUPPORT OFF CACHE BOOL "Disable legacy support for zstd")
set(ZSTD_BUILD_PROGRAMS OFF CACHE BOOL "Do not build zstd programs")
set(ZSTD_BUILD_CONTRIB OFF CACHE BOOL "Do not build zstd contrib")
set(ZSTD_BUILD_TESTS OFF CACHE BOOL "Do not build zstd tests")
set(ZSTD_BUILD_SHARED OFF CACHE BOOL "Do not build shared library")
add_subdirectory(zstd/build/cmake)

# Unfortunately we have to manually add include paths to the targets
# introduced by zstd, as we are compiling free-standing at this moment
target_include_directories(libzstd_static PRIVATE libos/include)
target_link_libraries(libzstd_static PRIVATE c)

# create an interface library for zstd
add_library(zstd-api INTERFACE)
target_include_directories(zstd-api INTERFACE zstd/lib)

# Export all the ddk targets for easier use
install(EXPORT ddk_targets
FILE ValiDDKTargets.cmake
Expand Down
6 changes: 3 additions & 3 deletions librt/libddk/include/ddk/filesystem.h
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,9 @@ __FSDECL(FsUnlink)(

__FSAPI oserr_t
__FSDECL(FsReadLink)(
_In_ void* instanceData,
_In_ mstring_t* path,
_In_ mstring_t* pathOut);
_In_ void* instanceData,
_In_ mstring_t* path,
_In_ mstring_t** pathOut);

__FSAPI oserr_t
__FSDECL(FsMove)(
Expand Down
56 changes: 56 additions & 0 deletions librt/libos/include/os/services/mount.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/**
* Copyright 2022, Philip Meulengracht
*
* 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 3 of the License, 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 <http://www.gnu.org/licenses/>.
*
* Mount Service Definitions & Structures
* - This header describes the base structure, prototypes
* and functionality, refer to the individual things for descriptions
*/

#ifndef __OS_SERVICE_MOUNT_H__
#define __OS_SERVICE_MOUNT_H__

#include <os/osdefs.h>
#include <os/types/mount.h>
#include <ds/mstring.h>

_CODE_BEGIN

/**
* @brief
* @param path
* @param at
* @param type
* @param flags
* @return
*/
CRTDECL(oserr_t,
Mount(
_In_ mstring_t* path,
_In_ mstring_t* at,
_In_ mstring_t* type,
_In_ unsigned int flags));

/**
* @brief
* @param path
* @return
*/
CRTDECL(oserr_t,
Unmount(
_In_ mstring_t* path));

_CODE_END
#endif //!__OS_SERVICE_MOUNT_H__
24 changes: 24 additions & 0 deletions librt/libos/include/os/types/mount.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/**
* Copyright 2022, Philip Meulengracht
*
* 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 3 of the License, 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 <http://www.gnu.org/licenses/>.
*/

#ifndef __OS_TYPES_MOUNT_H__
#define __OS_TYPES_MOUNT_H__

#define MOUNT_FLAG_READ 0x1
#define MOUNT_FLAG_WRITE 0x2

#endif //!__OS_TYPES_MOUNT_H__
1 change: 1 addition & 0 deletions librt/zstd
Submodule zstd added at 33273e
6 changes: 3 additions & 3 deletions modules/filesystems/mfs/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -186,9 +186,9 @@ FsLink(

oserr_t
FsReadLink(
_In_ void* instanceData,
_In_ mstring_t* path,
_In_ mstring_t* pathOut)
_In_ void* instanceData,
_In_ mstring_t* path,
_In_ mstring_t** pathOut)
{
// TODO implement MFS::ReadLink
return OsNotSupported;
Expand Down
5 changes: 3 additions & 2 deletions modules/filesystems/valifs/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
add_filesystem_target(valifs
main.c
filter.c
main.c
)
target_link_libraries(valifs PRIVATE vafs)
target_link_libraries(valifs PRIVATE vafs zstd-api libzstd_static)
deploy_file_to_initrd(valifs "modules" valifs.yaml)
6 changes: 5 additions & 1 deletion modules/filesystems/valifs/filter.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,13 @@
*/

#include <vafs/vafs.h>
#include <string.h>
#include <zstd.h>

struct VaFsFeatureFilter {
struct VaFsFeatureHeader Header;
};

static struct VaFsGuid g_filterGuid = VA_FS_FEATURE_FILTER;
static struct VaFsGuid g_filterOpsGuid = VA_FS_FEATURE_FILTER_OPS;

Expand All @@ -32,7 +37,6 @@ static int __zstd_decode(void* Input, uint32_t InputLength, void* Output, uint32
size_t decompressedSize;
unsigned long long contentSize = ZSTD_getFrameContentSize(Input, InputLength);
if (contentSize == ZSTD_CONTENTSIZE_ERROR || contentSize == ZSTD_CONTENTSIZE_UNKNOWN) {
fprintf(stderr, "__zstd_decode: failed to get frame content size\n");
return -1;
}

Expand Down
Loading

0 comments on commit 9299546

Please sign in to comment.