changeset 276:d332fbf5c145

etmsync: host_mkdir() function factored out of fc-fsio
author Mychaela Falconia <falcon@freecalypso.org>
date Fri, 17 Nov 2017 00:26:09 +0000
parents 81da9717babe
children 4469d73bbc60
files rvinterf/etmsync/Makefile rvinterf/etmsync/fsread.c rvinterf/etmsync/hostmkdir.c
diffstat 3 files changed, 39 insertions(+), 28 deletions(-) [+]
line wrap: on
line diff
--- a/rvinterf/etmsync/Makefile	Fri Nov 17 00:03:21 2017 +0000
+++ b/rvinterf/etmsync/Makefile	Fri Nov 17 00:26:09 2017 +0000
@@ -9,8 +9,9 @@
 
 FSIO_OBJS=	cl_des.o connect.o dispatch.o fdcmd.o fileio.o fsbasics.o \
 		fscmdtab.o fserr.o fsiomain.o fsmisc.o fspath.o fsread.o \
-		fsupload.o fswrite.o help.o interf.o launchrvif.o memcmd.o \
-		memops.o pirimei.o pirmagnetite.o rfcap.o stddirs.o symlink.o
+		fsupload.o fswrite.o help.o hostmkdir.o interf.o launchrvif.o \
+		memcmd.o memops.o pirimei.o pirmagnetite.o rfcap.o stddirs.o \
+		symlink.o
 
 MEMDUMP_OBJS=	connect.o interf.o launchrvif.o memdump.o memops.o
 
--- a/rvinterf/etmsync/fsread.c	Fri Nov 17 00:03:21 2017 +0000
+++ b/rvinterf/etmsync/fsread.c	Fri Nov 17 00:26:09 2017 +0000
@@ -203,32 +203,6 @@
 	return fd_close(tfd);
 }
 
-host_mkdir(pathname)
-	char *pathname;
-{
-	int rc;
-	struct stat st;
-
-	rc = stat(pathname, &st);
-	if (rc < 0) {
-		rc = mkdir(pathname, 0777);
-		if (rc < 0) {
-			perror(pathname);
-			return(ERROR_UNIX);
-		}
-		return(0);
-	} else {
-		if (S_ISDIR(st.st_mode))
-			return(0);
-		else {
-			fprintf(stderr,
-			"error: %s already exists and is not a directory\n",
-				pathname);
-			return(ERROR_UNIX);
-		}
-	}
-}
-
 cpout_dir(ffspath_dir, hostpath_dir)
 	char *ffspath_dir, *hostpath_dir;
 {
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/rvinterf/etmsync/hostmkdir.c	Fri Nov 17 00:26:09 2017 +0000
@@ -0,0 +1,36 @@
+/*
+ * host_mkdir() function has been factored out into this module.
+ */
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include "exitcodes.h"
+
+host_mkdir(pathname)
+	char *pathname;
+{
+	int rc;
+	struct stat st;
+
+	rc = stat(pathname, &st);
+	if (rc < 0) {
+		rc = mkdir(pathname, 0777);
+		if (rc < 0) {
+			perror(pathname);
+			return(ERROR_UNIX);
+		}
+		return(0);
+	} else {
+		if (S_ISDIR(st.st_mode))
+			return(0);
+		else {
+			fprintf(stderr,
+			"error: %s already exists and is not a directory\n",
+				pathname);
+			return(ERROR_UNIX);
+		}
+	}
+}