49#include <fuse/fuse_lowlevel.h>
63 int unixerr = (int)epocerr;
138 debuglog(
"EPOC error %ld became UNIX code %d", epocerr, unixerr);
157 ret =
a->
dir(file, entries);
159 for (
int i = 0; i < entries.size(); i++) {
168 (*e)->name = strdup(pe.
getName());
215int rfsv_open(
const char *name,
long mode, uint32_t *handle) {
220 if (mode == O_RDONLY)
229int rfsv_read(
char *buf,
long offset,
long len,
const char *name) {
230 uint32_t ret = 0, r_offset, handle;
234 if ((ret =
rfsv_open(name, O_RDONLY, &handle)))
237 offset != r_offset ||
244int rfsv_write(
const char *buf,
long offset,
long len,
const char *name) {
245 uint32_t ret = 0, r_offset, handle;
249 if ((ret =
rfsv_open(name, O_RDWR, &handle)))
252 offset != r_offset ||
285int rfsv_getattr(
const char *name,
long *attr,
long *size,
long *time) {
314 for (i = 0; i < 26; i++) {
322 (*dlist)->
next = next;
324 (*dlist)->total = drive.
getSize();
326 (*dlist)->letter =
'A' + i;
339 "Usage: plpfuse [OPTION...] MOUNTPOINT\n"
343 " -d, --debug Increase debugging level\n"
344 " -h, --help Display this text\n"
345 " -V, --version Print version and exit\n"
346 " -p, --port=[HOST:]PORT Connect to port PORT on host HOST\n"
347 " Default for HOST is 127.0.0.1\n"
348 " Default for PORT is "
349 ) << DPORT <<
"\n\n";
353 {
"help", no_argument,
nullptr,
'h'},
354 {
"debug", no_argument,
nullptr,
'd'},
355 {
"version", no_argument,
nullptr,
'V'},
356 {
"port", required_argument,
nullptr,
'p'},
357 {
nullptr, 0,
nullptr, 0 }
360int fuse(
int argc,
char *argv[])
362 struct fuse_args args = FUSE_ARGS_INIT(argc, argv);
363 struct fuse_chan *ch;
365 int err = -1, foreground;
367 if (fuse_parse_cmdline(&args, &mountpoint, NULL, &foreground) != -1 &&
368 (ch = fuse_mount(mountpoint, &args)) != NULL) {
369 if (fuse_daemonize(foreground) != -1) {
374 fuse_unmount(mountpoint, ch);
376 fuse_opt_free_args(&args);
381int main(
int argc,
char**argv) {
383 string host =
"127.0.0.1";
384 int sockNum = DPORT, i, c, oldoptind = 1;
394 while ((c = getopt_long(argc, argv,
"hVp:d",
opts, NULL)) != -1) {
397 cout <<
_(
"plpfuse version ") << VERSION << endl;
407 cout <<
_(
"Invalid port definition.") << endl;
410 argc -= optind - oldoptind;
411 for (i = oldoptind; i < argc; i++)
412 argv[i] = argv[i + (optind - oldoptind)];
420 if (!skt->
connect(host.c_str(), sockNum)) {
421 cerr <<
_(
"plpfuse: could not connect to ncpd") << endl;
425 if (!skt2->
connect(host.c_str(), sockNum)) {
426 cerr <<
_(
"plpfuse: could not connect to ncpd") << endl;
434 if (
a != NULL &&
r != NULL)
437 debuglog(
"plpfuse: could not create rfsv or rpcs object, connect delayed");
438 return fuse(argc, argv);
A class, representing a directory entry of the Psion.
uint32_t getSize()
Retrieves the file size of a directory entry.
uint32_t getAttr()
Retrieves the file attributes of a directory entry.
const char * getName()
Retrieve the file name of a directory entry.
PsiTime getPsiTime()
Retrieve the modification time of a directory entry.
A class representing information about a Disk drive on the psion.
std::string getName()
Retrieve the volume name of the drive.
uint64_t getSize()
Retrieve the total capacity of the drive.
uint32_t getMediaType()
Retrieve the media type of the drive.
uint64_t getSpace()
Retrieve the free capacity on the drive.
Psion time related utility class.
time_t getTime(void)
Retrieves the instance's current value in Unix time format.
A class for dealing with sockets.
virtual bool connect(const char *const Peer, int PeerPort, const char *const Host=NULL, int HostPort=0)
Connects to a given host.
A generic container for an array of bytes.
Access remote file services of a Psion.
virtual Enum< errs > mkdir(const char *const name)=0
Creates a directory on the Psion.
virtual uint32_t opMode(const uint32_t mode)=0
Converts an open-mode (A combination of the PSI_O_ constants.) from generic representation to the mac...
Enum< errs > getStatus()
Retrieves the current connection status.
virtual Enum< errs > fwrite(const uint32_t handle, const unsigned char *const buffer, const uint32_t len, uint32_t &count)=0
Write to a file on the Psion.
virtual Enum< errs > fsetattr(const char *const name, const uint32_t seta, const uint32_t unseta)=0
virtual Enum< errs > devlist(uint32_t &devbits)=0
Retrieves available drives on the Psion.
virtual Enum< errs > fsetmtime(const char *const name, const PsiTime mtime)=0
Sets the modification time of a file on the Psion.
virtual Enum< errs > fclose(const uint32_t handle)=0
Close a file on the Psion whih was previously opened/created by using fopen , fcreatefile ,...
virtual Enum< errs > fsetsize(const uint32_t handle, const uint32_t size)=0
Resizes an open file on the Psion.
virtual Enum< errs > fseek(const uint32_t handle, const int32_t offset, const uint32_t mode, uint32_t &resultpos)=0
Sets the current file position of a file on the Psion.
virtual Enum< errs > rename(const char *const oldname, const char *const newname)=0
Renames a file on the Psion.
virtual Enum< errs > fopen(const uint32_t attr, const char *const name, uint32_t &handle)=0
Opens a file.
virtual Enum< errs > dircount(const char *const name, uint32_t &count)=0
Counts number of entries in a directory.
virtual Enum< errs > fread(const uint32_t handle, unsigned char *const buffer, const uint32_t len, uint32_t &count)=0
Reads from a file on the Psion.
virtual Enum< errs > fgeteattr(const char *const name, PlpDirent &e)=0
Retrieves attributes, size and modification time of a file on the Psion.
virtual Enum< errs > rmdir(const char *const name)=0
Removes a directory on the Psion.
virtual Enum< errs > remove(const char *const name)=0
Removes a file on the Psion.
virtual Enum< errs > dir(const char *const name, PlpDir &ret)=0
Reads a directory on the Psion.
virtual Enum< errs > fcreatefile(const uint32_t attr, const char *const name, uint32_t &handle)=0
Creates a named file.
virtual Enum< errs > devinfo(const char drive, PlpDrive &dinfo)=0
Retrieves details about a drive.
A factory for automatically instantiating the correct rfsv protocol variant depending on the connecte...
virtual rfsv * create(bool)
Creates a new rfsv instance.
Remote procedure call services via PLP.
A factory for automatically instantiating the correct protocol variant depending on the connected Psi...
virtual rpcs * create(bool reconnect)
Creates a new rpcs instance.
void debuglog(const char *fmt,...)
struct fuse_operations plp_oper
bool parse_port(const std::string &arg, std::string *host, int *port)
int lookup_default_port()
int rfsv_rmdir(const char *name)
int rfsv_dir(const char *file, dentry **e)
int rfsv_drivelist(int *cnt, device **dlist)
int epocerr_to_errno(long epocerr)
int rfsv_open(const char *name, long mode, uint32_t *handle)
int rfsv_mkdir(const char *file)
int rfsv_getattr(const char *name, long *attr, long *size, long *time)
int main(int argc, char **argv)
int rfsv_dircount(const char *file, uint32_t *count)
int rfsv_remove(const char *file)
static struct option opts[]
int rfsv_setmtime(const char *name, long time)
int rfsv_write(const char *buf, long offset, long len, const char *name)
int rfsv_fcreate(long attr, const char *file, uint32_t *handle)
int rfsv_setattr(const char *name, long sattr, long dattr)
int rfsv_fclose(long handle)
int rfsv_rename(const char *oldname, const char *newname)
int rfsv_setsize(const char *name, long size)
int fuse(int argc, char *argv[])
int rfsv_read(char *buf, long offset, long len, const char *name)
std::deque< class PlpDirent > PlpDir
Description of a Psion-Device.