diff --git a/cffi-fcntl.lisp b/cffi-fcntl.lisp
index 419d3ed..2ccf79a 100644
--- a/cffi-fcntl.lisp
+++ b/cffi-fcntl.lisp
@@ -34,3 +34,19 @@
(if (= 0 (logand flags +o-creat+))
(c-open/2 pathname flags)
(c-open/3 pathname flags mode)))
+
+(defcfun ("openat" c-openat/3) :int
+ (dirfd :int)
+ (pathname :string)
+ (flags :int))
+
+(defcfun ("openat" c-openat/4) :int
+ (dirfd :int)
+ (pathname :string)
+ (flags :int)
+ (mode mode-t))
+
+(defun openat (dirfd pathname flags &optional mode)
+ (if (= 0 (logand flags +o-creat+))
+ (c-openat/3 dirfd pathname flags)
+ (c-openat/4 dirfd pathname flags mode)))
diff --git a/package.lisp b/package.lisp
index a909229..45b5f82 100644
--- a/package.lisp
+++ b/package.lisp
@@ -16,6 +16,7 @@
#:fcntl-getfl
#:fcntl-setfl
#:open
+ #:openat
#:+o-rdonly+
#:+o-wronly+
#:+o-rdwr+