Skip to content

Commit

Permalink
Merge pull request #24 from Xpl0itU/refactor_fatfs
Browse files Browse the repository at this point in the history
Fix fatfs by not using its cache
  • Loading branch information
Xpl0itU authored Nov 3, 2022
2 parents 1f37e44 + c73e65b commit 180258e
Show file tree
Hide file tree
Showing 43 changed files with 26,021 additions and 64 deletions.
6 changes: 0 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,6 @@ FROM wiiuenv/devkitppc:20220917 AS final

COPY --from=wiiuenv/libmocha:20220919 /artifacts $DEVKITPRO

RUN git clone --recursive https://github.com/Xpl0itU/libfat --single-branch && \
cd libfat && \
make -j$(nproc) wiiu-install && \
cd .. && \
rm -rf libfat

RUN git clone --recursive https://github.com/yawut/libromfs-wiiu --single-branch && \
cd libromfs-wiiu && \
make -j$(nproc) && \
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ include $(DEVKITPRO)/wut/share/wut_rules
#-------------------------------------------------------------------------------
TARGET := savemii
BUILD := build
SOURCES := src
SOURCES := src src/fatfs src/fatfs/extusb_devoptab
DATA := data
INCLUDES := include
CONTENT :=
Expand All @@ -53,7 +53,7 @@ CXXFLAGS := -std=gnu++20 -g -Wall -Wno-switch -Wno-format-overflow -Ofast -fperm
ASFLAGS := -g $(ARCH)
LDFLAGS = -g $(ARCH) $(RPXSPECS) -Wl,-Map,$(notdir $*.map)

LIBS := -lfat -lwut -lmocha -ljansson `freetype-config --libs`
LIBS := -lwut -lmocha -ljansson `freetype-config --libs`

include $(PORTLIBS_PATH)/wiiu/share/romfs-wiiu.mk
CFLAGS += $(ROMFS_CFLAGS)
Expand Down
2 changes: 0 additions & 2 deletions include/savemng.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@
#include <sys/stat.h>
#include <unistd.h>

#include <fat.h>
#include <mocha/disc_interface.h>
#include <mocha/mocha.h>

#define PATH_SIZE 0x400
Expand Down
24 changes: 24 additions & 0 deletions src/fatfs/LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
FatFs License

FatFs has being developped as a personal project of the author, ChaN. It is free from the code anyone else wrote at current release. Following code block shows a copy of the FatFs license document that heading the source files.

/*----------------------------------------------------------------------------/
/ FatFs - Generic FAT Filesystem Module Rx.xx /
/-----------------------------------------------------------------------------/
/
/ Copyright (C) 20xx, ChaN, all right reserved.
/
/ FatFs module is an open source software. Redistribution and use of FatFs in
/ source and binary forms, with or without modification, are permitted provided
/ that the following condition is met:
/
/ 1. Redistributions of source code must retain the above copyright notice,
/ this condition and the following disclaimer.
/
/ This software is provided by the copyright holder and contributors "AS IS"
/ and any warranties related to this software are DISCLAIMED.
/ The copyright owner or contributors be NOT LIABLE for any damages caused
/ by use of this software.
/----------------------------------------------------------------------------*/

Therefore FatFs license is one of the BSD-style licenses, but there is a significant feature. FatFs is mainly intended for embedded systems. In order to extend the usability for commercial products, the redistributions of FatFs in binary form, such as embedded code, binary library and any forms without source code, do not need to include about FatFs in the documentations. This is equivalent to the 1-clause BSD license. Of course FatFs is compatible with the most of open source software licenses include GNU GPL. When you redistribute the FatFs source code with changes or create a fork, the license can also be changed to GNU GPL, BSD-style license or any open source software license that not conflict with FatFs license.
18 changes: 18 additions & 0 deletions src/fatfs/devices.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#include "devices.h"
#include "ffconf.h"
#include <stddef.h>

#ifdef __cplusplus
extern "C" {
#endif

int deviceFds[FF_VOLUMES] = {-1, -1};
const char *devicePaths[FF_VOLUMES] = {NULL, NULL};

const char *get_fat_usb_path() {
return devicePaths[DEV_USB_EXT];
}

#ifdef __cplusplus
}
#endif
26 changes: 26 additions & 0 deletions src/fatfs/devices.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#pragma once
#include "ffconf.h"

#ifdef __cplusplus
extern "C" {
#endif

/* Definitions of physical drive number for each drive */
#define DEV_SD 0
#define DEV_USB_EXT 1

#define DEV_SD_NAME "sd"
#define DEV_USB_EXT_NAME "extusb"

#define SD_PATH "/dev/sdcard01"
#define USB_EXT1_PATH "/dev/usb01"
#define USB_EXT2_PATH "/dev/usb02"

extern int deviceFds[FF_VOLUMES];
extern const char *devicePaths[FF_VOLUMES];

const char *get_fat_usb_path();

#ifdef __cplusplus
}
#endif
Loading

0 comments on commit 180258e

Please sign in to comment.