Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion include/ftpd.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
#include "clibthrd.h" /* basic threads */
#include "clibthdi.h" /* thread management */
#include "racf.h" /* security environment */
#include "ufs.h" /* Unix File System */
#include "libufs.h" /* UFS client stubs via UFSD STC */

typedef struct ftpd FTPD; /* FTP Daemon (server) */
typedef struct ftpc FTPC; /* FTP Client */
Expand Down
2 changes: 1 addition & 1 deletion include/httpd.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
#include "clibtry.h" /* try(), tryrc() */

/* ufs headers */
#include "ufs.h" /* Unix "like" File System */
#include "libufs.h" /* UFS client stubs via UFSD STC */

/* our headers */
#include "socket.h" /* sockets via DYN75 */
Expand Down
6 changes: 5 additions & 1 deletion project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ space = ["TRK", 150, 50, 30]

[dependencies]
"mvslovers/crent370" = ">=1.0.6"
"mvslovers/ufs370" = ">=1.0.3"
"mvslovers/ufsd" = "=1.0.0-dev"
"mvslovers/lua370" = ">=1.0.2"
"mvslovers/mqtt370" = ">=1.0.3"

Expand All @@ -65,6 +65,7 @@ setcode = "AC(1)"

[link.module.dep_includes]
"mvslovers/lua370" = "*"
"mvslovers/ufsd" = "*"

# Lua extension module (custom entry point, no CRT)
[[link.module]]
Expand All @@ -83,6 +84,9 @@ entry = "@@CRT0"
options = ["LIST", "MAP", "XREF", "RENT"]
include = ["@@CRT1", "HTTPLUA"]

[link.module.dep_includes]
"mvslovers/ufsd" = "*"

# BREXX say helper (@@CRTM instead of @@CRT1)
[[link.module]]
name = "HTTPSAY"
Expand Down
7 changes: 4 additions & 3 deletions src/ftpdcwd.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "clibary.h"
#include "clibstr.h"
#include "osdcb.h"
#include "osjfcb.h" /* JFCB struct */
#include "clibdscb.h" /* DSCB structs and prototypes */

static int cwd_error(FTPC *ftpc, char *p);
Expand Down Expand Up @@ -75,7 +76,7 @@ static int cwd_path(FTPC *ftpc, char *path)
if (rc==0) {
ftpc->flags &= ~FTPC_FLAG_CWDDS;
ftpc->flags &= ~FTPC_FLAG_CWDPDS;
ftpcmsg(ftpc, "250 Working directory is '%s'", ftpc->ufs->cwd->path);
ftpcmsg(ftpc, "250 Working directory is '%s'", ftpc->ufs->cwd.path);
}
else {
ftpcmsg(ftpc, "550 Invalid path name '%s'", path);
Expand Down Expand Up @@ -257,13 +258,13 @@ ftpdcwd(FTPC *ftpc)
while(*p=='\'') p++;
strtok(p, "\'");
}
/* wtof("%s cwd=\"%s\"", __func__, ftpc->ufs->cwd->path); */
/* wtof("%s cwd=\"%s\"", __func__, ftpc->ufs->cwd.path); */
rc = ufs_chgdir(ftpc->ufs, p);
/* wtof("%s ufs_chgdir(\"%s\"), rc=%d", __func__, p, rc); */
if (rc==0) {
ftpc->flags &= ~FTPC_FLAG_CWDDS;
ftpc->flags &= ~FTPC_FLAG_CWDPDS;
ftpcmsg(ftpc, "250 Working directory is '%s'", ftpc->ufs->cwd->path);
ftpcmsg(ftpc, "250 Working directory is '%s'", ftpc->ufs->cwd.path);
}
else {
ftpcmsg(ftpc, "550 Invalid path name '%s'", p);
Expand Down
2 changes: 1 addition & 1 deletion src/ftpdmkd.c
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ ftpdmkd(FTPC *ftpc)
if (ftpc->flags & FTPC_FLAG_CWDPDS) goto do_dataset;

/* file system it is */
cwd = ftpc->ufs->cwd->path;
cwd = ftpc->ufs->cwd.path;

if (p) {
/* skip quotes */
Expand Down
2 changes: 1 addition & 1 deletion src/ftpdpwd.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ ftpdpwd(FTPC *ftpc)
if (ftpc->flags & FTPC_FLAG_CWDDS) goto do_send;
if (ftpc->flags & FTPC_FLAG_CWDPDS) goto do_send;

cwd = ftpc->ufs->cwd->path;
cwd = ftpc->ufs->cwd.path;

do_send:
ftpcmsg(ftpc, "257 \"%s\" current directory", cwd);
Expand Down
2 changes: 1 addition & 1 deletion src/ftpdrmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ ftpdrmd(FTPC *ftpc)
if (ftpc->flags & FTPC_FLAG_CWDPDS) goto do_dataset;

/* file system it is */
cwd = ftpc->ufs->cwd->path;
cwd = ftpc->ufs->cwd.path;

if (p) {
/* skip quotes */
Expand Down
8 changes: 4 additions & 4 deletions src/ftpfqn.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,10 @@ ftpfqn(FTPC *ftpc, const char *in, char *out)
goto quit;
}

if (ftpc->ufs && ftpc->ufs->cwd) {
if (ftpc->ufs && ftpc->ufs->cwd.path[0]) {
char *dir;

strcpy(out, ftpc->ufs->cwd->path);
strcpy(out, ftpc->ufs->cwd.path);
dir = strrchr(out+1, '/');
if (dir) {
/* truncate path by one level */
Expand Down Expand Up @@ -146,8 +146,8 @@ ftpfqn(FTPC *ftpc, const char *in, char *out)
}

if (ftpc->ufs) {
if (ftpc->ufs->cwd) {
sprintf(out, "%s/%s", ftpc->ufs->cwd->path, buf);
if (ftpc->ufs->cwd.path[0]) {
sprintf(out, "%s/%s", ftpc->ufs->cwd.path, buf);
}
else {
sprintf(out, "%s/%s", ftpc->cwd, buf);
Expand Down
4 changes: 2 additions & 2 deletions src/ftpslist.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ ftpslist(FTPC *ftpc, int brief)
if (ftpc->flags & FTPC_FLAG_CWDDS) goto do_open;
if (ftpc->flags & FTPC_FLAG_CWDPDS) goto do_open;

cwd = ftpc->ufs->cwd->path;
cwd = ftpc->ufs->cwd.path;

do_open:
/* lets first try to open the data connection */
Expand Down Expand Up @@ -124,7 +124,7 @@ ftpslist(FTPC *ftpc, int brief)
ftpcprtf(ftpc, "%s%s\r\n", list->name, list->attr[0]=='d' ? "/" : "");
}
else {
tm = mlocaltime64((const utime64_t*)&list->mtime);
tm = mlocaltime64(&list->mtime);
if (tm) {
strftime(fmtdate, sizeof(fmtdate), "%Y %b %d %H:%M", tm);
}
Expand Down
51 changes: 12 additions & 39 deletions src/httpconf.c
Original file line number Diff line number Diff line change
Expand Up @@ -511,67 +511,40 @@ process_httpd(lua_State *L, HTTPD *httpd)
return rc;
}

static int
static int
process_httpd_ufs(lua_State *L, HTTPD *httpd)
{
CLIBCRT *crt = __crtget();
int rc = 0;
int i;
UFSSYS *sys;
UFS *ufs;
UFSDISK *disk;
unsigned count;
unsigned n;
char topic[40];
UFS *ufs;

lua_getfield(L,-1,"ufs");
i = (int) lua_tointeger(L, -1);
// wtof("%s: ufs=%d", __func__, i);
lua_pop(L,1);

if (i<=0) goto quit;


/* Stub system handle — signals UFS availability to FTPD */
httpd->ufssys = ufs_sys_new();
if (!httpd->ufssys) {
wtof("HTTPD044W Unable to initialize file system");
goto quit;
}

sys = httpd->ufssys;
if (!sys->fsroot) {
wtof("HTTPD045W No file system root, disconnecting file system");
if (httpd->ftpd) httpd->ftpd->sys = httpd->ufssys;

/* Open server-level UFS session to UFSD STC */
httpd->ufs = ufs = ufsnew();
if (!ufs) {
wtof("HTTPD044W Unable to open UFSD session");
ufs_sys_term();
httpd->ufssys = NULL;
goto quit;
}

if (httpd->ftpd) httpd->ftpd->sys = sys;

/* log the ddname for the UFS disk files */
count = array_count(&sys->disks);
for(n=0; n < count; n++) {
disk = sys->disks[n];
if (!disk) continue;

wtof("HTTPD046I Disk#%u File System on DD %s %s",
n, disk->ddname, disk->readonly ? "READONLY (DISP=SHR)": "READ/WRITE");

/* Publich to MQTT Broker */
sprintf(topic, "ufs/disk%u", n);

http_pubf(httpd, topic,
"{ \"ddname\" : \"%s\" "
", \"dataset\" : \"%s\" "
", \"blksize\" : %u "
", \"dcb\" : \"%06X\" "
", \"mode\" : \"%s\" "
"}",
disk->ddname, disk->dsname, disk->blksize, disk->dcb,
disk->readonly ? "READONLY": "READ/WRITE");
}

/* Initialize a UFS handle for server use */
httpd->ufs = ufs = ufsnew();
wtof("HTTPD046I UFS session opened via UFSD subsystem");

if (crt) crt->crtufs = ufs;

quit:
Expand Down
16 changes: 1 addition & 15 deletions src/httpd.c
Original file line number Diff line number Diff line change
Expand Up @@ -319,20 +319,6 @@ terminate(void)
}

if (httpd->ufssys) {
UFSSYS *sys = httpd->ufssys;
char topic[40];

count = array_count(&sys->disks);
for(n=0; n < count; n++) {
UFSDISK *disk = sys->disks[n];

if (!disk) continue;

/* Delete from MQTT Broker */
sprintf(topic, "ufs/disk%u", n);
http_pubf(httpd, topic, "");
}

wtof("HTTPD047I Terminating File System");
ufs_sys_term();
httpd->ufssys = NULL;
Expand Down Expand Up @@ -681,7 +667,7 @@ socket_thread(void *arg1, void *arg2)
httpc->port = a->sin_port;
httpc->state = CSTATE_IN;
httpsecs(&httpc->start);
if (httpd->ufssys) {
if (httpd->ufs) {
/* create UFS handle */
httpc->ufs = ufsnew();
crt->crtufs = httpc->ufs;
Expand Down
Loading
Loading