mirror of
https://github.com/ps5-payload-dev/ftpsrv.git
synced 2026-10-18 18:03:30 -05:00
100 lines
3.2 KiB
C
100 lines
3.2 KiB
C
/* Copyright (C) 2025 John Törnblom
|
|
|
|
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, 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; see the file COPYING. If not, see
|
|
<http://www.gnu.org/licenses/>. */
|
|
|
|
#include <string.h>
|
|
|
|
#include <sys/_iovec.h>
|
|
#include <sys/mount.h>
|
|
|
|
#include "cmd.h"
|
|
|
|
|
|
/**
|
|
* Convenient macros for nmount.
|
|
**/
|
|
#define IOVEC_SIZE(x) (sizeof(x) / sizeof(struct iovec))
|
|
#define IOVEC_ENTRY(x) {x ? x : 0, x ? strlen(x)+1 : 0}
|
|
|
|
|
|
/**
|
|
* Remount read-only mount points with write permissions.
|
|
**/
|
|
int
|
|
ftp_cmd_MTRW(ftp_env_t *env, const char* arg) {
|
|
struct iovec iov_preinst[] = {
|
|
IOVEC_ENTRY("from"), IOVEC_ENTRY("/dev/da0x0.crypt"),
|
|
IOVEC_ENTRY("fspath"), IOVEC_ENTRY("/preinst"),
|
|
IOVEC_ENTRY("fstype"), IOVEC_ENTRY("exfatfs"),
|
|
IOVEC_ENTRY("large"), IOVEC_ENTRY("yes"),
|
|
IOVEC_ENTRY("timezone"), IOVEC_ENTRY("static"),
|
|
IOVEC_ENTRY("async"), IOVEC_ENTRY(NULL),
|
|
IOVEC_ENTRY("ignoreacl"), IOVEC_ENTRY(NULL),
|
|
};
|
|
struct iovec iov_preinst2[] = {
|
|
IOVEC_ENTRY("from"), IOVEC_ENTRY("/dev/da0x1.crypt"),
|
|
IOVEC_ENTRY("fspath"), IOVEC_ENTRY("/preinst2"),
|
|
IOVEC_ENTRY("fstype"), IOVEC_ENTRY("exfatfs"),
|
|
IOVEC_ENTRY("large"), IOVEC_ENTRY("yes"),
|
|
IOVEC_ENTRY("timezone"), IOVEC_ENTRY("static"),
|
|
IOVEC_ENTRY("async"), IOVEC_ENTRY(NULL),
|
|
IOVEC_ENTRY("ignoreacl"), IOVEC_ENTRY(NULL),
|
|
};
|
|
struct iovec iov_sys[] = {
|
|
IOVEC_ENTRY("from"), IOVEC_ENTRY("/dev/da0x4.crypt"),
|
|
IOVEC_ENTRY("fspath"), IOVEC_ENTRY("/system"),
|
|
IOVEC_ENTRY("fstype"), IOVEC_ENTRY("exfatfs"),
|
|
IOVEC_ENTRY("large"), IOVEC_ENTRY("yes"),
|
|
IOVEC_ENTRY("timezone"), IOVEC_ENTRY("static"),
|
|
IOVEC_ENTRY("async"), IOVEC_ENTRY(NULL),
|
|
IOVEC_ENTRY("ignoreacl"), IOVEC_ENTRY(NULL),
|
|
};
|
|
struct iovec iov_sysex[] = {
|
|
IOVEC_ENTRY("from"), IOVEC_ENTRY("/dev/da0x5.crypt"),
|
|
IOVEC_ENTRY("fspath"), IOVEC_ENTRY("/system_ex"),
|
|
IOVEC_ENTRY("fstype"), IOVEC_ENTRY("exfatfs"),
|
|
IOVEC_ENTRY("large"), IOVEC_ENTRY("yes"),
|
|
IOVEC_ENTRY("timezone"), IOVEC_ENTRY("static"),
|
|
IOVEC_ENTRY("async"), IOVEC_ENTRY(NULL),
|
|
IOVEC_ENTRY("ignoreacl"), IOVEC_ENTRY(NULL),
|
|
};
|
|
|
|
if(nmount(iov_preinst, IOVEC_SIZE(iov_preinst), MNT_UPDATE)) {
|
|
return ftp_perror(env);
|
|
}
|
|
if(nmount(iov_preinst2, IOVEC_SIZE(iov_preinst2), MNT_UPDATE)) {
|
|
return ftp_perror(env);
|
|
}
|
|
if(nmount(iov_sys, IOVEC_SIZE(iov_sys), MNT_UPDATE)) {
|
|
return ftp_perror(env);
|
|
}
|
|
if(nmount(iov_sysex, IOVEC_SIZE(iov_sysex), MNT_UPDATE)) {
|
|
return ftp_perror(env);
|
|
}
|
|
|
|
return ftp_active_printf(env,
|
|
"200- /preinst remounted\r\n"
|
|
"200- /preinst2 remounted\r\n"
|
|
"200- /system remounted\r\n"
|
|
"200 /system_ex remounted\r\n");
|
|
}
|
|
|
|
|
|
/*
|
|
Local Variables:
|
|
c-file-style: "gnu"
|
|
End:
|
|
*/
|