int stat(const char *name, void *st) { #if HAVE___XSTAT return __xstat(0, name, st); #else if (smbw_path(name)) { return smbw_stat(name, st); } return real_stat(name, st); #endif }
int lstat(char *name, void *st) { #if HAVE___LXSTAT return __lxstat(0, name, st); #else if (smbw_path(name)) { return smbw_stat(name, st); } return real_lstat(name, st); #endif }
int __lxstat(int vers, char *name, void *st) { double xx[32]; int ret; if (smbw_path(name)) { return smbw_stat(name, st); } ret = real_lstat(name, xx); xstat_convert(vers, st, xx); return ret; }
int lstat64(const char *name, struct stat64 *st64) { check_init("lstat64"); if (smbw_path((char *) name)) { struct SMBW_stat statbuf; int ret = smbw_stat((char *) name, &statbuf); stat64_convert(&statbuf, st64); return ret; } return (* smbw_libc.lstat64)((char *) name, st64); }
int stat(const char *name, struct stat *st) { check_init("stat"); if (smbw_path((char *) name)) { struct SMBW_stat statbuf; int ret = smbw_stat((char *) name, &statbuf); stat_convert(&statbuf, st); return ret; } return (* smbw_libc.stat)((char *) name, st); }
/***************************************************** a wrapper for readlink() - needed for correct errno setting *******************************************************/ int smbw_readlink(const char *fname, char *buf, size_t bufsize) { struct SMBW_stat st; int ret; SMBW_INIT(); ret = smbw_stat(fname, &st); if (ret != 0) { return -1; } /* it exists - say it isn't a link */ errno = EINVAL; return -1; }
/***************************************************** a wrapper for realink() - needed for correct errno setting *******************************************************/ int smbw_readlink(const char *path, char *buf, size_t bufsize) { struct stat st; int ret; ret = smbw_stat(path, &st); if (ret != 0) { DEBUG(4,("readlink(%s) failed\n", path)); return -1; } /* it exists - say it isn't a link */ DEBUG(4,("readlink(%s) not a link\n", path)); errno = EINVAL; return -1; }
/***************************************************** a wrapper for access() *******************************************************/ int smbw_access(const char *name, int mode) { struct stat st; DEBUG(4,("smbw_access(%s, 0x%x)\n", name, mode)); if (smbw_stat(name, &st)) return -1; if (((mode & R_OK) && !(st.st_mode & S_IRUSR)) || ((mode & W_OK) && !(st.st_mode & S_IWUSR)) || ((mode & X_OK) && !(st.st_mode & S_IXUSR))) { errno = EACCES; return -1; } return 0; }
/***************************************************** a wrapper for access() *******************************************************/ int smbw_access(const char *name, int mode) { struct SMBW_stat st; SMBW_INIT(); if (smbw_stat(name, &st)) return -1; if (((mode & R_OK) && !(st.s_mode & S_IRUSR)) || ((mode & W_OK) && !(st.s_mode & S_IWUSR)) || ((mode & X_OK) && !(st.s_mode & S_IXUSR))) { errno = EACCES; return -1; } return 0; }