51#include <fuse/fuse_lowlevel.h>
65 int unixerr = (int)epocerr;
140 debuglog(
"EPOC error %ld became UNIX code %d", epocerr, unixerr);
159 ret =
a->
dir(file, entries);
161 for (
int i = 0; i < entries.size(); i++) {
170 (*e)->name = strdup(pe.
getName());
217int rfsv_open(
const char *name,
long mode, uint32_t *handle) {
222 if (mode == O_RDONLY)
231int rfsv_read(
char *buf,
long offset,
long len,
const char *name) {
232 uint32_t ret = 0, r_offset, handle;
236 if ((ret =
rfsv_open(name, O_RDONLY, &handle)))
239 offset != r_offset ||
246int rfsv_write(
const char *buf,
long offset,
long len,
const char *name) {
247 uint32_t ret = 0, r_offset, handle;
251 if ((ret =
rfsv_open(name, O_RDWR, &handle)))
254 offset != r_offset ||
287int rfsv_getattr(
const char *name,
long *attr,
long *size,
long *time) {
316 for (i = 0; i < 26; i++) {
324 (*dlist)->
next = next;
326 (*dlist)->total = drive.
getSize();
328 (*dlist)->letter =
'A' + i;
329 (*dlist)->attrib =
static_cast<uint32_t
>(drive.
getMediaType());
341 "Usage: plpfuse [OPTION...] MOUNTPOINT\n"
345 " -d, --debug Increase debugging level\n"
346 " -h, --help Display this text\n"
347 " -V, --version Print version and exit\n"
348 " -p, --port=[HOST:]PORT Connect to port PORT on host HOST\n"
349 " Default for HOST is 127.0.0.1\n"
350 " Default for PORT is "
351 ) << DPORT <<
"\n\n";
355 {
"help", no_argument,
nullptr,
'h'},
356 {
"debug", no_argument,
nullptr,
'd'},
357 {
"version", no_argument,
nullptr,
'V'},
358 {
"port", required_argument,
nullptr,
'p'},
359 {
nullptr, 0,
nullptr, 0 }
362int fuse(
int argc,
char *argv[])
364 struct fuse_args args = FUSE_ARGS_INIT(argc, argv);
365 struct fuse_chan *ch;
367 int err = -1, foreground;
369 if (fuse_parse_cmdline(&args, &mountpoint, NULL, &foreground) != -1 &&
370 (ch = fuse_mount(mountpoint, &args)) != NULL) {
371 if (fuse_daemonize(foreground) != -1) {
376 fuse_unmount(mountpoint, ch);
378 fuse_opt_free_args(&args);
383int main(
int argc,
char**argv) {
384 string host =
"127.0.0.1";
385 int sockNum = DPORT, i, c, oldoptind = 1;
395 while ((c = getopt_long(argc, argv,
"hVp:d",
opts, NULL)) != -1) {
398 cout <<
_(
"plpfuse version ") << VERSION << endl;
408 cout <<
_(
"Invalid port definition.") << endl;
411 argc -= optind - oldoptind;
412 for (i = oldoptind; i < argc; i++)
413 argv[i] = argv[i + (optind - oldoptind)];
424 if (
a != NULL &&
r != NULL)
427 debuglog(
"plpfuse: could not create rfsv or RPCS object, connect delayed");
428 return fuse(argc, argv);
A generic container for an array of bytes.
A class representing information about a Disk drive on the psion.
MediaType getMediaType() const
Retrieve the media type of the drive.
uint64_t getSpace() const
Retrieve the free capacity on the drive.
uint64_t getSize() const
Retrieve the total capacity of the drive.
std::string getName() const
Retrieve the volume name of the drive.
A class, representing a directory entry of the Psion.
uint32_t getAttr() const
Retrieves the file attributes of a directory entry.
const char * getName() const
Retrieve the file name of a directory entry.
PsiTime getPsiTime()
Retrieve the modification time of a directory entry.
uint32_t getSize() const
Retrieves the file size of a directory entry.
Psion time related utility class.
time_t getTime(void)
Retrieves the instance's current value in Unix time format.
A factory for automatically instantiating the correct RFSV protocol variant depending on the connecte...
RFSV * create(bool, Enum< ConnectionError > *error=nullptr)
Creates a new RFSV instance.
Access remote file services of a Psion.
virtual Enum< errs > fsetsize(const uint32_t handle, const uint32_t size)=0
Resizes an open file on the Psion.
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 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...
virtual Enum< errs > remove(const char *const name)=0
Removes a 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 > fopen(const uint32_t attr, const char *const name, uint32_t &handle)=0
Opens a file.
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 > fsetattr(const char *const name, const uint32_t seta, const uint32_t unseta)=0
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 > fcreatefile(const uint32_t attr, const char *const name, uint32_t &handle)=0
Creates a named file.
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 > mkdir(const char *const name)=0
Creates a directory 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 ,...
Enum< errs > getStatus()
Retrieves the current connection status.
virtual Enum< errs > dir(const char *const name, PlpDir &ret)=0
Reads a directory on the Psion.
virtual Enum< errs > dircount(const char *const name, uint32_t &count)=0
Counts number of entries in a directory.
virtual Enum< errs > rmdir(const char *const name)=0
Removes a directory on the Psion.
virtual Enum< errs > devlist(uint32_t &devbits)=0
Retrieves available drives on the Psion.
virtual Enum< errs > devinfo(const char drive, Drive &dinfo)=0
Retrieves details about a drive.
virtual Enum< errs > rename(const char *const oldname, const char *const newname)=0
Renames a file on the Psion.
A factory for automatically instantiating the correct protocol variant depending on the connected Psi...
RPCS * create(bool, Enum< ConnectionError > *error=nullptr)
Creates a new RPCS instance.
Remote procedure call services via PLP.
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.