diff options
| author | Stefan Kangas | 2021-12-12 06:31:07 +0100 |
|---|---|---|
| committer | Stefan Kangas | 2021-12-12 06:31:07 +0100 |
| commit | 2d116c432d2a561fac69916d78b7a70dd6144ac7 (patch) | |
| tree | dd948eabc6fba59704c2a66ea7d97624c86e2228 /src/msdos.c | |
| parent | 4b29468dbef63f2befd7f67663a11cd5a3009b79 (diff) | |
| parent | 8a0734329a4faf0b45627763af74222bdd0ec143 (diff) | |
| download | emacs-2d116c432d2a561fac69916d78b7a70dd6144ac7.tar.gz emacs-2d116c432d2a561fac69916d78b7a70dd6144ac7.zip | |
Merge from origin/emacs-28
8a0734329a Avoid undefined behavior in 'send-process-region' (Bug#523...
30dd5c9acc Update to Org 9.5.1-25-g9ca3bc
a374849926 Fix the DJGPP port
Diffstat (limited to 'src/msdos.c')
| -rw-r--r-- | src/msdos.c | 102 |
1 files changed, 102 insertions, 0 deletions
diff --git a/src/msdos.c b/src/msdos.c index bf058c8aff9..2272aba6fde 100644 --- a/src/msdos.c +++ b/src/msdos.c | |||
| @@ -1874,6 +1874,7 @@ initialize_msdos_display (struct terminal *term) | |||
| 1874 | term->redeem_scroll_bar_hook = 0; | 1874 | term->redeem_scroll_bar_hook = 0; |
| 1875 | term->judge_scroll_bars_hook = 0; | 1875 | term->judge_scroll_bars_hook = 0; |
| 1876 | term->read_socket_hook = &tty_read_avail_input; /* from keyboard.c */ | 1876 | term->read_socket_hook = &tty_read_avail_input; /* from keyboard.c */ |
| 1877 | term->defined_color_hook = &tty_defined_color; /* from xfaces.c */ | ||
| 1877 | } | 1878 | } |
| 1878 | 1879 | ||
| 1879 | int | 1880 | int |
| @@ -3915,6 +3916,50 @@ readlinkat (int fd, char const *name, char *buffer, size_t buffer_size) | |||
| 3915 | return readlink (name, buffer, buffer_size); | 3916 | return readlink (name, buffer, buffer_size); |
| 3916 | } | 3917 | } |
| 3917 | 3918 | ||
| 3919 | |||
| 3920 | int | ||
| 3921 | openat (int fd, const char * path, int oflag, int mode) | ||
| 3922 | { | ||
| 3923 | /* Rely on a hack: an open directory is modeled as file descriptor 0, | ||
| 3924 | as in fstatat. FIXME: Add proper support for openat. */ | ||
| 3925 | char fullname[MAXPATHLEN]; | ||
| 3926 | |||
| 3927 | if (fd != AT_FDCWD) | ||
| 3928 | { | ||
| 3929 | if (strlen (dir_pathname) + strlen (path) + 1 >= MAXPATHLEN) | ||
| 3930 | { | ||
| 3931 | errno = ENAMETOOLONG; | ||
| 3932 | return -1; | ||
| 3933 | } | ||
| 3934 | sprintf (fullname, "%s/%s", dir_pathname, path); | ||
| 3935 | path = fullname; | ||
| 3936 | } | ||
| 3937 | |||
| 3938 | return open (path, oflag, mode); | ||
| 3939 | } | ||
| 3940 | |||
| 3941 | int | ||
| 3942 | fchmodat (int fd, const char *path, mode_t mode, int flags) | ||
| 3943 | { | ||
| 3944 | /* Rely on a hack: an open directory is modeled as file descriptor 0, | ||
| 3945 | as in fstatat. FIXME: Add proper support for openat. */ | ||
| 3946 | char fullname[MAXPATHLEN]; | ||
| 3947 | |||
| 3948 | if (fd != AT_FDCWD) | ||
| 3949 | { | ||
| 3950 | if (strlen (dir_pathname) + strlen (path) + 1 >= MAXPATHLEN) | ||
| 3951 | { | ||
| 3952 | errno = ENAMETOOLONG; | ||
| 3953 | return -1; | ||
| 3954 | } | ||
| 3955 | |||
| 3956 | sprintf (fullname, "%s/%s", dir_pathname, path); | ||
| 3957 | path = fullname; | ||
| 3958 | } | ||
| 3959 | |||
| 3960 | return chmod (path, mode); | ||
| 3961 | } | ||
| 3962 | |||
| 3918 | char * | 3963 | char * |
| 3919 | careadlinkat (int fd, char const *filename, | 3964 | careadlinkat (int fd, char const *filename, |
| 3920 | char *buffer, size_t buffer_size, | 3965 | char *buffer, size_t buffer_size, |
| @@ -3942,6 +3987,63 @@ careadlinkat (int fd, char const *filename, | |||
| 3942 | return buffer; | 3987 | return buffer; |
| 3943 | } | 3988 | } |
| 3944 | 3989 | ||
| 3990 | int | ||
| 3991 | futimens (int fd, const struct timespec times[2]) | ||
| 3992 | { | ||
| 3993 | struct tm *tm; | ||
| 3994 | struct ftime ft; | ||
| 3995 | time_t t; | ||
| 3996 | |||
| 3997 | block_input (); | ||
| 3998 | if (times[1].tv_sec == UTIME_NOW) | ||
| 3999 | t = time (NULL); | ||
| 4000 | else | ||
| 4001 | t = times[1].tv_sec; | ||
| 4002 | |||
| 4003 | tm = localtime (&t); | ||
| 4004 | ft.ft_tsec = min (29, tm->tm_sec / 2); | ||
| 4005 | ft.ft_min = tm->tm_min; | ||
| 4006 | ft.ft_hour = tm->tm_hour; | ||
| 4007 | ft.ft_day = tm->tm_mday; | ||
| 4008 | ft.ft_month = tm->tm_mon + 1; | ||
| 4009 | ft.ft_year = max (0, tm->tm_year - 80); | ||
| 4010 | unblock_input (); | ||
| 4011 | |||
| 4012 | return setftime (fd, &ft); | ||
| 4013 | } | ||
| 4014 | |||
| 4015 | int | ||
| 4016 | utimensat (int dirfd, const char *pathname, | ||
| 4017 | const struct timespec times[2], int flags) | ||
| 4018 | { | ||
| 4019 | int fd, ret; | ||
| 4020 | char fullname[MAXPATHLEN]; | ||
| 4021 | |||
| 4022 | /* Rely on a hack: dirfd in its current usage in Emacs is always | ||
| 4023 | AT_FDCWD. */ | ||
| 4024 | |||
| 4025 | if (dirfd != AT_FDCWD) | ||
| 4026 | { | ||
| 4027 | if (strlen (dir_pathname) + strlen (pathname) + 1 >= MAXPATHLEN) | ||
| 4028 | { | ||
| 4029 | errno = ENAMETOOLONG; | ||
| 4030 | return -1; | ||
| 4031 | } | ||
| 4032 | sprintf (fullname, "%s/%s", dir_pathname, pathname); | ||
| 4033 | pathname = fullname; | ||
| 4034 | } | ||
| 4035 | |||
| 4036 | fd = open (pathname, O_WRONLY); | ||
| 4037 | |||
| 4038 | if (fd < 0) | ||
| 4039 | return -1; | ||
| 4040 | |||
| 4041 | ret = futimens (fd, times); | ||
| 4042 | close (fd); | ||
| 4043 | |||
| 4044 | return ret; | ||
| 4045 | } | ||
| 4046 | |||
| 3945 | /* Emulate faccessat(2). */ | 4047 | /* Emulate faccessat(2). */ |
| 3946 | int | 4048 | int |
| 3947 | faccessat (int dirfd, const char * path, int mode, int flags) | 4049 | faccessat (int dirfd, const char * path, int mode, int flags) |