#include "lib/util/time_basic.h"
#include "source3/smbd/dir.h"
+#if defined(HAVE_LINUX_MAGIC_H)
+#include <linux/magic.h>
+#endif
+
extern const struct generic_mapping file_generic_mapping;
struct deferred_open_record {
fsp,
how);
if (new_fd == -1) {
+#if defined(HAVE_FSTATFS) && defined(HAVE_LINUX_MAGIC_H)
+ if (S_ISDIR(fsp->fsp_name->st.st_ex_mode) &&
+ (errno == ENOENT)) {
+ struct statfs sbuf = {};
+ int ret = fstatfs(old_fd, &sbuf);
+ if (ret == -1) {
+ int saved_errno = errno;
+ DBG_ERR("fstatfs failed: %s\n",
+ strerror(errno));
+ errno = saved_errno;
+ } else if (sbuf.f_type == AUTOFS_SUPER_MAGIC) {
+ /*
+ * When reopening an as-yet
+ * unmounted autofs mount
+ * point we get ENOENT. We
+ * have to retry pathbased.
+ */
+ goto namebased_open;
+ }
+ }
+#endif
status = map_nt_error_from_unix(errno);
fd_close(fsp);
return status;
return NT_STATUS_OK;
}
+namebased_open:
/*
* Close the existing pathref fd and set the fsp flag
* is_pathref to false so we get a "normal" fd this time.
conf.CHECK_HEADERS('netdb.h')
conf.CHECK_HEADERS('linux/falloc.h linux/ioctl.h')
+ conf.CHECK_HEADERS('linux/magic.h')
conf.CHECK_FUNCS('getcwd fchown chmod fchmod mknod mknodat')
conf.CHECK_FUNCS('strtol strchr strupr chflags fchflags')
if conf.CHECK_FUNCS('dirfd'):
conf.DEFINE('HAVE_DIRFD_DECL', 1)
+ conf.CHECK_CODE('struct statfs fsd; int r = fstatfs(AT_FDCWD, &fsd);',
+ 'HAVE_FSTATFS',
+ msg='Checking for fstatfs',
+ headers='sys/statfs.h fcntl.h')
conf.CHECK_CODE('struct statfs fsd; fsid_t fsid = fsd.f_fsid; return statfs(".", &fsd);',
'HAVE_STATFS_F_FSID',
msg="vfs_fileid checking for statfs() and struct statfs.f_fsid",