Commit 01af3bd5 authored by kollo's avatar kollo

fixed bug with TOUCH in Android (Johns Issue 2017-10-17)

Due to missing futimens and futimes functions on Android, TOUCH can still not work. (Tried to use /proc filesystem, but it appears no be read only. Later platforms are maybe better of, but I want to stay with the Android 2.3 compatibility.
parent af874a17
......@@ -12,3 +12,4 @@ Release notes for Version 1.25 (Sept 2016 -- 2017)
- improved memory handling in 64bit versions
- new parameter list types for CALL
- new functions CALLD() and CALL$()
- fixed Bug in XLOAD and TOUCH (Android)
......@@ -66,9 +66,15 @@
/* Define to 1 if you have the `execvpe' function. */
#undef HAVE_EXECVPE
/* Define to 1 if you have the `futimes' function. */
#undef HAVE_FUTIMES
/* Define to 1 if you have the `futimens' function. */
#undef HAVE_FUTIMENS
/* Define to 1 if you have the `utimensat' function. */
#undef HAVE_UTIMENSAT
/* Define to 1 if you have the `getcwd' function. */
#undef HAVE_GETCWD
......
......@@ -7423,7 +7423,7 @@ $as_echo "#define HAVE_UTIME_NULL 1" >>confdefs.h
fi
rm -f conftest.data
for ac_func in nanosleep inotify_init memfrob utime execvp execvpe futimens
for ac_func in nanosleep inotify_init memfrob utime execvp execvpe futimes futimens utimensat
do :
as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
......
......@@ -538,7 +538,7 @@ AC_FUNC_REALLOC
AC_TYPE_SIGNAL
AC_FUNC_STAT
AC_FUNC_UTIME_NULL
AC_CHECK_FUNCS([nanosleep inotify_init memfrob utime execvp execvpe futimens])
AC_CHECK_FUNCS([nanosleep inotify_init memfrob utime execvp execvpe futimes futimens utimensat])
AC_CHECK_FUNCS([alarm atexit bzero dup2 getcwd gethostbyname gettimeofday])
AC_CHECK_FUNCS([inet_ntoa localtime_r memmove memset mkdir munmap rmdir select])
AC_CHECK_FUNCS([socket strchr strdup strerror strstr backtrace])
......
......@@ -127,31 +127,45 @@ static int init_sockaddr(struct sockaddr_in *name,const char *hostname, unsigned
static int make_socket(unsigned short int port);
static int make_UDP_socket(unsigned short int port);
/* get the current cursor position */
/*futimens does not exist on Android NDK.
This does not work either for NDK r7c:*/
//#if defined ANDROID
//#include <sys/syscall.h>
//int utimensat(int dirfd, const char *pathname,
// const struct timespec times[2], int flags) {
// return syscall(__NR_utimensat, dirfd, pathname, times, flags);
//}
//#endif
#ifndef HAVE_FUTIMENS
#ifndef HAVE_UTIMENSAT
/* Bei ANdroid gibt es beide nicht. */
#ifndef HAVE_FUTIMES
#ifndef HAVE_UTIME
#define futimens(a,b) (0); /* not supported */
#pragma message ("TOUCH/futimes not supportet. Feature disabled." )
#else
/* Here we can try to use utime with proc file system, but we can easily get a permission denied error. */
int futimens(int fd, void * dummy) {
char pn[64];
sprintf(pn,"/proc/%d/fd/%d",getpid(),fd);
return(utime(pn,NULL));
}
#endif
#else
#define futimens(a,b) futimes(a,NULL)
#endif
#ifndef UTIME_NOW
#define UTIME_NOW ((1l << 30) - 1l)
#define UTIME_OMIT ((1l << 30) - 2l)
#ifndef ANDROID
#ifndef ATARI
#ifndef __APPLE__
#ifndef WINDOWS
struct timespec {
time_t tv_sec; /* seconds */
long tv_nsec; /* nanoseconds */
};
#endif
#endif
#endif
#else
#define futimens(a,b) utimensat(a, NULL, b, 0);
#endif
#endif
#if defined ANDROID
extern int lin,col;
/* get the current cursor position */
void getcrsrowcol(int *_row, int *_col) {
*_row=lin+1;
......@@ -1864,14 +1878,8 @@ void touch(PARAMETER *plist,int e) {
if(plist->integer>0) {
FILEINFO fff=get_fileptr(plist->integer);
if(fff.typ==0) {xberror(24,"");return;} /* File nicht geoeffnet */
int fp=fileno(fff.dptr);
struct timespec ts[2];
ts[0].tv_nsec=UTIME_NOW;
ts[1].tv_nsec=UTIME_NOW;
#ifndef ATARI
int ret=futimens(fp, ts);
int ret=futimens(fileno(fff.dptr), NULL);
if(ret==-1) io_error(errno,"touch");
#endif
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment