diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/callproc.c | 27 | ||||
-rw-r--r-- | src/fileio.c | 2 | ||||
-rw-r--r-- | src/msdos.c | 102 | ||||
-rw-r--r-- | src/msdos.h | 2 | ||||
-rw-r--r-- | src/process.c | 17 | ||||
-rw-r--r-- | src/thread.h | 1 |
6 files changed, 148 insertions, 3 deletions
diff --git a/src/callproc.c b/src/callproc.c index fad81694b0a..f7c55d04863 100644 --- a/src/callproc.c +++ b/src/callproc.c @@ -25,6 +25,10 @@ along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */ #include <sys/types.h> #include <unistd.h> +#ifdef MSDOS +extern char **environ; +#endif + #include <sys/file.h> #include <fcntl.h> @@ -1200,6 +1204,11 @@ static CHILD_SETUP_TYPE child_setup (int in, int out, int err, char **new_argv, char **env, const char *current_dir) { +#ifdef MSDOS + char *pwd_var; + char *temp; + ptrdiff_t i; +#endif #ifdef WINDOWSNT int cpid; HANDLE handles[3]; @@ -1252,6 +1261,22 @@ child_setup (int in, int out, int err, char **new_argv, char **env, exec_failed (new_argv[0], errnum); #else /* MSDOS */ + i = strlen (current_dir); + pwd_var = xmalloc (i + 5); + temp = pwd_var + 4; + memcpy (pwd_var, "PWD=", 4); + stpcpy (temp, current_dir); + + if (i > 2 && IS_DEVICE_SEP (temp[1]) && IS_DIRECTORY_SEP (temp[2])) + { + temp += 2; + i -= 2; + } + + /* Strip trailing slashes for PWD, but leave "/" and "//" alone. */ + while (i > 2 && IS_DIRECTORY_SEP (temp[i - 1])) + temp[--i] = 0; + pid = run_msdos_command (new_argv, pwd_var + 4, in, out, err, env); xfree (pwd_var); if (pid == -1) @@ -1583,11 +1608,13 @@ emacs_spawn (pid_t *newpid, int std_in, int std_out, int std_err, signal (SIGPROF, SIG_DFL); #endif +#ifdef subprocesses /* Stop blocking SIGCHLD in the child. */ unblock_child_signal (oldset); if (pty_flag) child_setup_tty (std_out); +#endif if (std_err < 0) std_err = std_out; diff --git a/src/fileio.c b/src/fileio.c index 7e3bebca9e6..b1f464cf988 100644 --- a/src/fileio.c +++ b/src/fileio.c @@ -2286,6 +2286,7 @@ permissions. */) off_t insize = st.st_size; ssize_t copied; +#ifndef MSDOS for (newsize = 0; newsize < insize; newsize += copied) { /* Copy at most COPY_MAX bytes at a time; this is min @@ -2300,6 +2301,7 @@ permissions. */) break; maybe_quit (); } +#endif /* MSDOS */ /* Fall back on read+write if copy_file_range failed, or if the input is empty and so could be a /proc file. read+write will diff --git a/src/msdos.c b/src/msdos.c index 5da01c9e7ca..a6deea710f4 100644 --- a/src/msdos.c +++ b/src/msdos.c @@ -1874,6 +1874,7 @@ initialize_msdos_display (struct terminal *term) term->redeem_scroll_bar_hook = 0; term->judge_scroll_bars_hook = 0; term->read_socket_hook = &tty_read_avail_input; /* from keyboard.c */ + term->defined_color_hook = &tty_defined_color; /* from xfaces.c */ } int @@ -3915,6 +3916,50 @@ readlinkat (int fd, char const *name, char *buffer, size_t buffer_size) return readlink (name, buffer, buffer_size); } + +int +openat (int fd, const char * path, int oflag, int mode) +{ + /* Rely on a hack: an open directory is modeled as file descriptor 0, + as in fstatat. FIXME: Add proper support for openat. */ + char fullname[MAXPATHLEN]; + + if (fd != AT_FDCWD) + { + if (strlen (dir_pathname) + strlen (path) + 1 >= MAXPATHLEN) + { + errno = ENAMETOOLONG; + return -1; + } + sprintf (fullname, "%s/%s", dir_pathname, path); + path = fullname; + } + + return open (path, oflag, mode); +} + +int +fchmodat (int fd, const char *path, mode_t mode, int flags) +{ + /* Rely on a hack: an open directory is modeled as file descriptor 0, + as in fstatat. FIXME: Add proper support for openat. */ + char fullname[MAXPATHLEN]; + + if (fd != AT_FDCWD) + { + if (strlen (dir_pathname) + strlen (path) + 1 >= MAXPATHLEN) + { + errno = ENAMETOOLONG; + return -1; + } + + sprintf (fullname, "%s/%s", dir_pathname, path); + path = fullname; + } + + return chmod (path, mode); +} + char * careadlinkat (int fd, char const *filename, char *buffer, size_t buffer_size, @@ -3942,6 +3987,63 @@ careadlinkat (int fd, char const *filename, return buffer; } +int +futimens (int fd, const struct timespec times[2]) +{ + struct tm *tm; + struct ftime ft; + time_t t; + + block_input (); + if (times[1].tv_sec == UTIME_NOW) + t = time (NULL); + else + t = times[1].tv_sec; + + tm = localtime (&t); + ft.ft_tsec = min (29, tm->tm_sec / 2); + ft.ft_min = tm->tm_min; + ft.ft_hour = tm->tm_hour; + ft.ft_day = tm->tm_mday; + ft.ft_month = tm->tm_mon + 1; + ft.ft_year = max (0, tm->tm_year - 80); + unblock_input (); + + return setftime (fd, &ft); +} + +int +utimensat (int dirfd, const char *pathname, + const struct timespec times[2], int flags) +{ + int fd, ret; + char fullname[MAXPATHLEN]; + + /* Rely on a hack: dirfd in its current usage in Emacs is always + AT_FDCWD. */ + + if (dirfd != AT_FDCWD) + { + if (strlen (dir_pathname) + strlen (pathname) + 1 >= MAXPATHLEN) + { + errno = ENAMETOOLONG; + return -1; + } + sprintf (fullname, "%s/%s", dir_pathname, pathname); + pathname = fullname; + } + + fd = open (pathname, O_WRONLY); + + if (fd < 0) + return -1; + + ret = futimens (fd, times); + close (fd); + + return ret; +} + /* Emulate faccessat(2). */ int faccessat (int dirfd, const char * path, int mode, int flags) diff --git a/src/msdos.h b/src/msdos.h index f7d3b0d7029..d58b60ef5df 100644 --- a/src/msdos.h +++ b/src/msdos.h @@ -86,6 +86,8 @@ typedef int GC; typedef int Pixmap; typedef int Display; typedef int Window; + +#define FRAME_X_DISPLAY(ignored) NULL #define PIX_TYPE unsigned long #define XDISPLAY diff --git a/src/process.c b/src/process.c index 6731f8808f5..75ba191fa10 100644 --- a/src/process.c +++ b/src/process.c @@ -40,7 +40,10 @@ along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */ #include <netinet/in.h> #include <arpa/inet.h> -#endif /* subprocesses */ +#else +#define PIPECONN_P(p) false +#define PIPECONN1_P(p) false +#endif #ifdef HAVE_SETRLIMIT # include <sys/resource.h> @@ -152,6 +155,7 @@ static bool kbd_is_on_hold; when exiting. */ bool inhibit_sentinels; +#ifdef subprocesses union u_sockaddr { struct sockaddr sa; @@ -164,8 +168,6 @@ union u_sockaddr #endif }; -#ifdef subprocesses - #ifndef SOCK_CLOEXEC # define SOCK_CLOEXEC 0 #endif @@ -8238,9 +8240,13 @@ If optional argument QUERY is `current', ignore OMP_NUM_THREADS. If QUERY is `all', also count processors not available. */) (Lisp_Object query) { +#ifndef MSDOS return make_uint (num_processors (EQ (query, Qall) ? NPROC_ALL : EQ (query, Qcurrent) ? NPROC_CURRENT : NPROC_CURRENT_OVERRIDABLE)); +#else + return make_fixnum (1); +#endif } #ifdef subprocesses @@ -8285,10 +8291,15 @@ open_channel_for_module (Lisp_Object process) { CHECK_PROCESS (process); CHECK_TYPE (PIPECONN_P (process), Qpipe_process_p, process); +#ifndef MSDOS int fd = dup (XPROCESS (process)->open_fd[SUBPROCESS_STDOUT]); if (fd == -1) report_file_error ("Cannot duplicate file descriptor", Qnil); return fd; +#else + /* PIPECONN_P returning true shouldn't be possible on MSDOS. */ + emacs_abort (); +#endif } diff --git a/src/thread.h b/src/thread.h index cf3ce922c46..b316e916d1d 100644 --- a/src/thread.h +++ b/src/thread.h @@ -26,6 +26,7 @@ along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */ #endif #ifdef MSDOS +#include <time.h> /* struct rpl_timespec */ #include <signal.h> /* sigset_t */ #endif |