http://code.google.com/p/ftpii/source/detail?r=285
Deleted:
/trunk/patches
Modified:
/trunk
/trunk/Makefile
/trunk/README.txt
/trunk/hbc/meta.xml
/trunk/release.sh
/trunk/source/fs.c
/trunk/source/fs.h
/trunk/source/ftp.c
/trunk/source/ftp.h
/trunk/source/ftpii.c
/trunk/source/net.c
/trunk/source/reset.c
/trunk/source/reset.h
=======================================
--- /trunk/Makefile Sat Jan 17 20:18:16 2009
+++ /trunk/Makefile Sun Dec 20 07:24:37 2009
@@ -11,7 +11,7 @@
BUILD = build
CFLAGS = -g -O2 -Wall $(MACHDEP) $(INCLUDE)
-LDFLAGS = -L$(LIBOGC_LIB) -lisfs -lnandimg -lfst -lwod -liso -ldi
-lwiiuse -lbte -lfat -logc -lm -g $(MACHDEP) -Wl,-Map,$(notdir
$@).map,--section-start,.init=0x80a00000
+LDFLAGS = -L$(LIBOGC_LIB) -lotp -lisfs -lnandimg -lfst -lwod -liso -ldi
-lwiiuse -lbte -lfat -logc -lm -g $(MACHDEP) -Wl,-Map,$(notdir
$@).map,--section-start,.init=0x80a00000
PRELOADER_LDFLAGS = -L$(LIBOGC_LIB) -logc -g $(MACHDEP) -Wl,-Map,$(notdir
$@).map
ifneq ($(BUILD),$(notdir $(CURDIR)))
=======================================
--- /trunk/README.txt Sun Apr 26 02:19:48 2009
+++ /trunk/README.txt Sun Dec 20 07:24:37 2009
@@ -1,11 +1,10 @@
-
ftpii is an FTP server for the Nintendo Wii.
*** USAGE ***
Copy ftpii/ to /apps/ on an SD-card and use The Homebrew Channel,
-or load boot.dol using your favourite mechanism (wiiload, Twilight Hack,
ISO etc...).
+or load boot.elf using your favourite mechanism (wiiload, Twilight Hack,
ISO etc...).
To specify a password via The Homebrew Channel, rename the apps/ftpii
directory to apps/ftpii_YourPassword.
To specify a password via wiiload, pass an argument e.g. wiiload boot.dol
YourPassword.
@@ -34,6 +33,10 @@
For subversion changes since 0.0.6, see
http://code.google.com/p/ftpii/source/list
+20091221 0.0.20 Attempt to reinitialise network after failure.
+ Added OTP filesystem support at /otp (libotp).
+ Attempt to show real timestamps in directory listings.
+ Built with devkitPPC release 19, libogc 1.8.1 (r3846),
libfat 1.0.6 (r3846).
20090426 0.0.19 Fixed spurious error when reading bad sectors from NAND.
Add support for SDHC Gecko. (thanks emu_kidid!)
Attempt to fix hang when auto-mounting DVD.
=======================================
--- /trunk/hbc/meta.xml Sun Apr 26 02:19:48 2009
+++ /trunk/hbc/meta.xml Sun Dec 20 07:24:37 2009
@@ -3,7 +3,7 @@
<name>ftpii</name>
<coder>joedj</coder>
<version>0.0.19</version>
- <release_date>20090426200000</release_date>
+ <release_date>20091221010000</release_date>
<short_description>An FTP server</short_description>
<long_description>ftpii is an FTP server.
=======================================
--- /trunk/release.sh Sat Jan 17 20:18:16 2009
+++ /trunk/release.sh Sun Dec 20 07:24:37 2009
@@ -11,7 +11,7 @@
make && \
mkdir ftpii && \
mv README.txt LICENSE.txt hbc/* ftpii && \
-mv ftpii.dol ftpii/boot.dol && \
+mv ftpii.elf ftpii/boot.elf && \
make clean && \
rm -rf Makefile data source hbc patches && \
(find . -name .svn | xargs rm -rf) && \
=======================================
--- /trunk/source/fs.c Wed Dec 9 05:05:57 2009
+++ /trunk/source/fs.c Sun Dec 20 07:24:37 2009
@@ -29,7 +29,9 @@
#include <nandimg/nandimg.h>
#include <ogc/lwp_watchdog.h>
#include <ogc/mutex.h>
+#include <ogc/system.h>
#include <ogc/usbstorage.h>
+#include <otp/otp.h>
#include <sdcard/gcsd.h>
#include <sdcard/wiisd_io.h>
#include <stdio.h>
@@ -54,7 +56,8 @@
{ "Wii disc image", "/wod", "wod", "wod:/", false, false, NULL },
{ "Wii disc filesystem", "/fst", "fst", "fst:/", false, false, NULL },
{ "NAND images", "/nand", "nand", "nand:/", false, false, NULL },
- { "NAND filesystem", "/isfs", "isfs", "isfs:/", false, false, NULL }
+ { "NAND filesystem", "/isfs", "isfs", "isfs:/", false, false, NULL },
+ { "OTP filesystem", "/otp", "otp", "otp:/", false, false, NULL }
};
const u32 MAX_VIRTUAL_PARTITIONS = (sizeof(VIRTUAL_PARTITIONS) /
sizeof(VIRTUAL_PARTITION));
@@ -67,6 +70,7 @@
VIRTUAL_PARTITION *PA_FST = VIRTUAL_PARTITIONS + 6;
VIRTUAL_PARTITION *PA_NAND = VIRTUAL_PARTITIONS + 7;
VIRTUAL_PARTITION *PA_ISFS = VIRTUAL_PARTITIONS + 8;
+VIRTUAL_PARTITION *PA_OTP = VIRTUAL_PARTITIONS + 9;
static VIRTUAL_PARTITION *to_virtual_partition(const char *virtual_prefix)
{
u32 i;
@@ -165,6 +169,8 @@
success = NANDIMG_Mount();
} else if (partition == PA_ISFS) {
success = ISFS_Mount();
+ } else if (partition == PA_OTP) {
+ success = OTP_Mount();
}
printf(success ? "succeeded.\n" : "failed.\n");
if (success && is_gecko(partition)) partition->geckofail = false;
@@ -193,6 +199,8 @@
success = NANDIMG_Unmount();
} else if (partition == PA_ISFS) {
success = ISFS_Unmount();
+ } else if (partition == PA_OTP) {
+ success = OTP_Unmount();
}
printf(success ? "succeeded.\n" : "failed.\n");
@@ -290,6 +298,7 @@
void initialise_fs() {
NANDIMG_Mount();
+ OTP_Mount();
ISFS_SU();
if (ISFS_Initialize() == IPC_OK) ISFS_Mount();
initialise_fat();
=======================================
--- /trunk/source/fs.h Sat Jan 17 20:18:16 2009
+++ /trunk/source/fs.h Sun Dec 20 07:24:37 2009
@@ -36,7 +36,7 @@
const DISC_INTERFACE *disc;
} VIRTUAL_PARTITION;
-VIRTUAL_PARTITION VIRTUAL_PARTITIONS[9];
+VIRTUAL_PARTITION VIRTUAL_PARTITIONS[10];
const u32 MAX_VIRTUAL_PARTITIONS;
VIRTUAL_PARTITION *PA_GCSDA;
VIRTUAL_PARTITION *PA_GCSDB;
@@ -47,6 +47,7 @@
VIRTUAL_PARTITION *PA_FST;
VIRTUAL_PARTITION *PA_NAND;
VIRTUAL_PARTITION *PA_ISFS;
+VIRTUAL_PARTITION *PA_OTP;
void initialise_fs();
=======================================
--- /trunk/source/ftp.c Tue Jun 2 03:47:56 2009
+++ /trunk/source/ftp.c Sun Dec 20 07:24:37 2009
@@ -314,7 +314,9 @@
char reply[49];
u16 port = bindAddress.sin_port;
u32 ip = net_gethostip();
- printf("Listening for data connections at %s:%u...\n",
inet_ntoa(*(struct in_addr *)&ip), port);
+ struct in_addr addr;
+ addr.s_addr = ip;
+ printf("Listening for data connections at %s:%u...\n",
inet_ntoa(addr), port);
sprintf(reply, "Entering Passive Mode (%u,%u,%u,%u,%u,%u).", (ip >>
24) & 0xff, (ip >> 16) & 0xff, (ip >> 8) & 0xff, ip & 0xff, (port >> 8) &
0xff, port & 0xff);
return write_reply(client, 227, reply);
}
@@ -407,7 +409,9 @@
struct stat st;
char line[MAXPATHLEN + 56 + CRLF_LENGTH + 1];
while (vrt_dirnext(dir, filename, &st) == 0) {
- sprintf(line, "%crwxr-xr-x 1 0 0 %10llu Jan 01
1970 %s\r\n", (st.st_mode & S_IFDIR) ? 'd' : '-', st.st_size, filename);
+ char timestamp[13];
+ strftime(timestamp, sizeof(timestamp), "%b %d %Y",
localtime(&st.st_mtime));
+ sprintf(line, "%crwxr-xr-x 1 0 0 %10llu %s %s\r\n",
(st.st_mode & S_IFDIR) ? 'd' : '-', st.st_size, timestamp, filename);
if ((result = send_exact(data_socket, line, strlen(line))) < 0) {
break;
}
@@ -458,7 +462,6 @@
if (!f) {
return write_reply(client, 550, strerror(errno));
}
- setbuf(f, NULL);
int fd = fileno(f);
if (client->restart_marker && lseek(fd, client->restart_marker,
SEEK_SET) != client->restart_marker) {
@@ -478,7 +481,6 @@
if (!f) {
return write_reply(client, 550, strerror(errno));
}
- setbuf(f, NULL);
s32 result = prepare_data_connection(client, recv_to_file, f, fclose);
if (result < 0) fclose(f);
return result;
@@ -694,14 +696,14 @@
}
}
-static void process_accept_events(s32 server) {
+static bool process_accept_events(s32 server) {
s32 peer;
struct sockaddr_in client_address;
socklen_t addrlen = sizeof(client_address);
while ((peer = net_accept(server, (struct sockaddr *)&client_address,
&addrlen)) != -EAGAIN) {
if (peer < 0) {
- net_close(server);
- die("Error accepting connection", -peer);
+ printf("Error accepting connection: [%i] %s\n", -peer,
strerror(-peer));
+ return false;
}
printf("Accepted connection from %s!\n",
inet_ntoa(client_address.sin_addr));
@@ -709,14 +711,14 @@
if (num_clients == MAX_CLIENTS) {
printf("Maximum of %u clients reached, not accepting
client.\n", MAX_CLIENTS);
net_close(peer);
- return;
+ return true;
}
client_t *client = malloc(sizeof(client_t));
if (!client) {
printf("Could not allocate memory for client state, not
accepting client.\n");
net_close(peer);
- return;
+ return true;
}
client->socket = peer;
client->representation_type = 'A';
@@ -748,6 +750,7 @@
num_clients++;
}
}
+ return true;
}
static void process_data_events(client_t *client) {
@@ -852,8 +855,8 @@
cleanup_client(client);
}
-void process_ftp_events(s32 server) {
- process_accept_events(server);
+bool process_ftp_events(s32 server) {
+ bool network_down = !process_accept_events(server);
int client_index;
for (client_index = 0; client_index < MAX_CLIENTS; client_index++) {
client_t *client = clients[client_index];
@@ -865,4 +868,5 @@
}
}
}
-}
+ return network_down;
+}
=======================================
--- /trunk/source/ftp.h Sat Aug 16 00:01:04 2008
+++ /trunk/source/ftp.h Sun Dec 20 07:24:37 2009
@@ -28,7 +28,7 @@
void accept_ftp_client(s32 server);
void set_ftp_password(char *new_password);
-void process_ftp_events(s32 server);
+bool process_ftp_events(s32 server);
void cleanup_ftp();
#endif /* _FTP_H_ */
=======================================
--- /trunk/source/ftpii.c Tue May 19 02:10:32 2009
+++ /trunk/source/ftpii.c Sun Dec 20 07:24:37 2009
@@ -115,11 +115,19 @@
set_password_from_executable(argv[0]);
}
- s32 server = create_server(PORT);
- printf("Listening on TCP port %u...\n", PORT);
+ bool network_down = true;
+ s32 server = -1;
while (!reset()) {
+ if (network_down) {
+ net_close(server);
+ initialise_network();
+ server = create_server(PORT);
+ if (server < 0) continue;
+ printf("Listening on TCP port %u...\n", PORT);
+ network_down = false;
+ }
check_dvd_mount();
- process_ftp_events(server);
+ network_down = process_ftp_events(server);
process_wiimote_events();
process_gamecube_events();
process_timer_events();
@@ -132,11 +140,10 @@
printf("\nKTHXBYE\n");
- if (dvd_mountWait()) printf("NOTE: Due to a known bug in libdi, ftpii
is unable to exit until a DVD is inserted.\n");
dvd_stop();
DI_Close();
ISFS_Deinitialize();
- poweroff_or_sysmenu();
+ maybe_poweroff();
return 0;
}
=======================================
--- /trunk/source/net.c Sat Jan 17 20:18:16 2009
+++ /trunk/source/net.c Sun Dec 20 07:24:37 2009
@@ -41,6 +41,7 @@
printf("Waiting for network to initialise...\n");
s32 result = -1;
while (!check_reset_synchronous() && result < 0) {
+ net_deinit();
while (!check_reset_synchronous() && (result = net_init()) ==
-EAGAIN);
if (result < 0) printf("net_init() failed: [%i] %s,
retrying...\n", result, strerror(-result));
}
@@ -50,7 +51,11 @@
ip = net_gethostip();
if (!ip) printf("net_gethostip() failed, retrying...\n");
} while (!check_reset_synchronous() && !ip);
- if (ip) printf("Network initialised. Wii IP address: %s\n",
inet_ntoa(*(struct in_addr *)&ip));
+ if (ip) {
+ struct in_addr addr;
+ addr.s_addr = ip;
+ printf("Network initialised. Wii IP address: %s\n",
inet_ntoa(addr));
+ }
}
}
@@ -80,11 +85,13 @@
s32 ret;
if ((ret = net_bind(server, (struct sockaddr *)&bindAddress,
sizeof(bindAddress))) < 0) {
net_close(server);
- die("Error binding socket", -ret);
+ printf("Error binding socket: [%i] %s\n", -ret, strerror(-ret));
+ return ret;
}
if ((ret = net_listen(server, 3)) < 0) {
net_close(server);
- die("Error listening on socket", -ret);
+ printf("Error listening on socket: [%i] %s\n", -ret,
strerror(-ret));
+ return ret;
}
return server;
=======================================
--- /trunk/source/reset.c Sat Jan 17 20:18:16 2009
+++ /trunk/source/reset.c Sun Dec 20 07:24:37 2009
@@ -55,19 +55,14 @@
return _reset || check_wiimote(WPAD_BUTTON_A) ||
check_gamecube(PAD_BUTTON_A);
}
-static bool exit_stub() {
- return !!*(u32 *)0x80001800;
-}
-
-void poweroff_or_sysmenu() {
+void maybe_poweroff() {
if (_power) SYS_ResetSystem(SYS_POWEROFF, 0, 0);
- else if (!exit_stub()) SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0);
}
void die(char *msg, int errnum) {
printf("%s: [%i] %s\n", msg, errnum, strerror(errnum));
printf("Program halted. Press reset to exit.\n");
while (!check_reset_synchronous()) VIDEO_WaitVSync();
- poweroff_or_sysmenu();
+ maybe_poweroff();
exit(1);
}
=======================================
--- /trunk/source/reset.h Sat Jan 17 20:18:16 2009
+++ /trunk/source/reset.h Sun Dec 20 07:24:37 2009
@@ -34,6 +34,6 @@
bool check_reset_synchronous();
-void poweroff_or_sysmenu();
+void maybe_poweroff();
#endif /* _RESET_H_ */