diff --git a/include/ftpd.h b/include/ftpd.h index 0b997d2..1bd6ac7 100644 --- a/include/ftpd.h +++ b/include/ftpd.h @@ -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 */ diff --git a/include/httpd.h b/include/httpd.h index 02297eb..b74d1e3 100644 --- a/include/httpd.h +++ b/include/httpd.h @@ -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 */ diff --git a/project.toml b/project.toml index b7de886..f9ecc6f 100644 --- a/project.toml +++ b/project.toml @@ -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" @@ -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]] @@ -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" diff --git a/src/ftpdcwd.c b/src/ftpdcwd.c index 3087c71..4b7698d 100644 --- a/src/ftpdcwd.c +++ b/src/ftpdcwd.c @@ -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); @@ -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); @@ -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); diff --git a/src/ftpdmkd.c b/src/ftpdmkd.c index 5bc3e58..6b92a88 100644 --- a/src/ftpdmkd.c +++ b/src/ftpdmkd.c @@ -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 */ diff --git a/src/ftpdpwd.c b/src/ftpdpwd.c index 829dd8e..48c0803 100644 --- a/src/ftpdpwd.c +++ b/src/ftpdpwd.c @@ -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); diff --git a/src/ftpdrmd.c b/src/ftpdrmd.c index 0d5071d..81740bc 100644 --- a/src/ftpdrmd.c +++ b/src/ftpdrmd.c @@ -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 */ diff --git a/src/ftpfqn.c b/src/ftpfqn.c index 01bf1ce..8de98f5 100644 --- a/src/ftpfqn.c +++ b/src/ftpfqn.c @@ -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 */ @@ -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); diff --git a/src/ftpslist.c b/src/ftpslist.c index 541a06b..01d0ebf 100644 --- a/src/ftpslist.c +++ b/src/ftpslist.c @@ -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 */ @@ -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); } diff --git a/src/httpconf.c b/src/httpconf.c index f2f972a..bbef229 100644 --- a/src/httpconf.c +++ b/src/httpconf.c @@ -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: diff --git a/src/httpd.c b/src/httpd.c index 020077e..2953ed6 100644 --- a/src/httpd.c +++ b/src/httpd.c @@ -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; @@ -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; diff --git a/src/httpdsrv.c b/src/httpdsrv.c index ca4eded..1aa3e0a 100644 --- a/src/httpdsrv.c +++ b/src/httpdsrv.c @@ -1,5 +1,6 @@ /* HTTPDSRV.C - CGI Program, Display Server */ #include "httpd.h" +#include "osdcb.h" /* DCB -- was transitively included via ufs.h */ #define httpx (httpd->httpx) @@ -27,12 +28,14 @@ static int display_ufssys(HTTPD *httpd, HTTPC *httpc, UFSSYS *sys); static int display_cgi_row(HTTPD *httpd, HTTPC *httpc, HTTPCGI *cgi, unsigned n); static int display_worker_row(HTTPD *httpd, HTTPC *httpc, CTHDWORK *worker, unsigned n); static int display_queue_data(HTTPD *httpd, HTTPC *httpc, CTHDQUE *q); +#if 0 /* ufs370 internal types -- not available with libufs stub */ static int display_ufsdisk(HTTPD *httpd, HTTPC *httpc, UFSDISK *disk, unsigned n); static int display_ufsdisk_table(HTTPD *httpd, HTTPC *httpc, UFSDISK *disk); static int display_ufspager_table(HTTPD *httpd, HTTPC *httpc, UFSPAGER *pager, unsigned n); static int display_ufsio_table(HTTPD *httpd, HTTPC *httpc, UFSIO *io, unsigned n); static int display_ufsvdisk(HTTPD *httpd, HTTPC *httpc, UFSVDISK *vdisk, unsigned n); static int display_ufsvdisk_table(HTTPD *httpd, HTTPC *httpc, UFSVDISK *vdisk); +#endif static int display_memory(HTTPD *httpd, HTTPC *httpc, const char *title, void *memory, int length, int chunk); static int try_memory(HTTPD *httpd, HTTPC *httpc, const char *title, void *memory, int length, int chunk); @@ -98,6 +101,7 @@ int main(int argc, char **argv) goto quit; } +#if 0 /* ufs370 internal display -- not available with libufs stub */ if (http_cmpn(target, "UFSDISKS", len)==0) { display_ufsdisks(httpd, httpc); goto quit; @@ -122,6 +126,7 @@ int main(int argc, char **argv) display_ufsvdisks(httpd, httpc); goto quit; } +#endif if (http_cmpn(target, "WORKERS", len)==0) { display_workers(httpd, httpc); @@ -581,12 +586,12 @@ display_fs(HTTPD *httpd, HTTPC *httpc) /* convert string to memory pointer */ memory = (char *) strtoul(memory, NULL, 16); - if (memcmp(memory, UFSSYS_EYE, 8)==0) { + if (memcmp(memory, "LIBUFSSY", 8)==0) { sys = (UFSSYS*) strtoul(memory, NULL, 16); display_ufssys(httpd, httpc, sys); goto quit; } - if (memcmp(memory, UFSEYE, 8)==0) { + if (memcmp(memory, "LIBUFSUF", 8)==0) { ufs = (UFS*) strtoul(memory, NULL, 16); display_ufs(httpd, httpc, ufs); goto quit; @@ -605,128 +610,44 @@ static int display_ufssys(HTTPD *httpd, HTTPC *httpc, UFSSYS *sys) { int rc = 0; - UCHAR *u; - unsigned n, count; if (!sys) { /* default to HTTPD ufssys handle */ sys = httpd->ufssys; } - + if (rc = send_resp(httpd, httpc, 200) < 0) goto quit; http_printf(httpc, "

UFS System Handle %p

\n", sys); display_memory(httpd, httpc, "UFSSYS", sys, sizeof(UFSSYS), 16); - + http_printf(httpc, "\n"); - http_printf(httpc, + http_printf(httpc, "" "" "" "\n"); - http_printf(httpc, + http_printf(httpc, "" "" "" - "\n", + "\n", O(eye), sys->eye); - count = array_count(&sys->disks); - http_printf(httpc, - "" - "" - "" - "\n", - O(disks), sys->disks, count, sys->disks); - - count = array_count(&sys->pagers); - http_printf(httpc, - "" - "" - "" - "\n", - O(pagers), sys->pagers, count, sys->pagers); - - count = array_count(&sys->io); - http_printf(httpc, - "" - "" - "" - "\n", - O(io), sys->io, count, sys->io); - - count = array_count(&sys->vdisks); - http_printf(httpc, - "" - "" - "" - "\n", - O(vdisks), sys->vdisks, count, sys->vdisks); - - count = array_count(&sys->devs); - http_printf(httpc, - "" - "" - "" - "\n", - O(devs), count, sys->devs); - - http_printf(httpc, - "" - "" - "" - "\n", - O(next_dvnum), sys->next_dvnum); - - http_printf(httpc, - "" - "" - "" - "\n", - O(fsroot), sys->fsroot); - - count = array_count(&sys->names); - http_printf(httpc, - "" - "" - "" - "\n", - O(names), count, sys->names); - - count = array_count(&sys->cwds); - http_printf(httpc, - "" - "" - "" - "\n", - O(cwds), count, sys->cwds); - - count = array_count(&sys->files); - http_printf(httpc, - "" - "" - "" - "\n", - O(files), count, sys->files); - - count = array_count(&sys->mountpoint); - http_printf(httpc, - "" - "" - "" - "\n", - O(mountpoint), count, sys->mountpoint); - + http_printf(httpc, + "\n"); done: http_printf(httpc, "
OffsetData NameDescriptionContents
+%04Xsys->eyeEye Catcher\"%-8.8s\"
\"%-8.8s\"
+%04Xsys->disksArray Of %u Disk Handles%p
+%04Xsys->pagersArray Of %u Pager Handles%p
+%04Xsys->ioArray Of %u I/O Handles%p
+%04Xsys->vdisksArray Of %u Virtual Disk Handles%p
+%04Xsys->devsArray Of %u Device Handles%p
+%04Xsys->next_dvnumNext Device Number To Assign%u
+%04Xsys->fsrootFile System Root Inode \"/\"%p
+%04Xsys->namesArray Of %u Name Handles%p
+%04Xsys->cwdsArray Of %u Current Working Directories%p
+%04Xsys->filesArray Of %u Opened File Descriptors%p
+%04Xsys->mountpointArray Of %u Directories With Mounted Vdisk%p
" + "Disk and inode state is owned by the UFSD STC." + "
\n"); send_last(httpd, httpc); - + quit: - return 0; + return 0; } #if 0 @@ -748,6 +669,8 @@ struct ufs_sys { }; /* 40 (64 bytes) */ #endif +#if 0 /* ufs370 internal display -- not available with libufs stub */ + #ifdef O #undef O #endif @@ -1315,7 +1238,9 @@ display_ufspager_table(HTTPD *httpd, HTTPC *httpc, UFSPAGER *pager, unsigned n) return 0; } +#endif /* ufs370 internal display */ +#if 0 /* ufs370 internal display -- not available with libufs stub */ #ifdef O #undef O #endif @@ -1486,6 +1411,7 @@ display_ufssb(HTTPD *httpd, HTTPC *httpc) return 0; } +#endif /* ufs370 internal display */ #ifdef O #undef O