diff options
author | Sergei Golubchik <serg@mariadb.org> | 2017-02-20 22:41:17 +0100 |
---|---|---|
committer | Sergei Golubchik <serg@mariadb.org> | 2017-02-27 12:35:10 +0100 |
commit | 6d50324558e79d6e90848059bf7cd918685b02ba (patch) | |
tree | c120ea5c18468c2947b0af18a4c79980e3f57f6f /mysys/mysys_priv.h | |
parent | f2d24ea68b9fde45d9a221f2c2a5d75fd10ef650 (diff) | |
download | mariadb-git-6d50324558e79d6e90848059bf7cd918685b02ba.tar.gz |
support MY_NOSYMLINKS in my_delete()
Diffstat (limited to 'mysys/mysys_priv.h')
-rw-r--r-- | mysys/mysys_priv.h | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/mysys/mysys_priv.h b/mysys/mysys_priv.h index f5d2f301837..4b489504c26 100644 --- a/mysys/mysys_priv.h +++ b/mysys/mysys_priv.h @@ -89,6 +89,34 @@ void sf_free(void *ptr); void my_error_unregister_all(void); +#if !defined(O_PATH) && defined(O_EXEC) /* FreeBSD */ +#define O_PATH O_EXEC +#endif + +#ifdef O_PATH +#define HAVE_OPEN_PARENT_DIR_NOSYMLINKS +const char *my_open_parent_dir_nosymlinks(const char *pathname, int *pdfd); +#define NOSYMLINK_FUNCTION_BODY(AT,NOAT) \ + int dfd, res; \ + const char *filename= my_open_parent_dir_nosymlinks(pathname, &dfd); \ + if (filename == NULL) return -1; \ + res= AT; \ + if (dfd >= 0) close(dfd); \ + return res; +#elif defined(HAVE_REALPATH) +#define NOSYMLINK_FUNCTION_BODY(AT,NOAT) \ + char buf[PATH_MAX+1]; \ + if (realpath(pathname, buf) == NULL) return -1; \ + if (strcmp(pathname, buf)) { errno= ENOTDIR; return -1; } \ + return NOAT; +#else +#define NOSYMLINK_FUNCTION_BODY(AT,NOAT) \ + return NOAT; +#endif + +#define CREATE_NOSYMLINK_FUNCTION(PROTO,AT,NOAT) \ +static int PROTO { NOSYMLINK_FUNCTION_BODY(AT,NOAT) } + #ifdef _WIN32 #include <sys/stat.h> /* my_winfile.c exports, should not be used outside mysys */ |