File 5136d04.diff of Package openafs

From 5136d047b3137114826794fb8f3e0933ed9acba2 Mon Sep 17 00:00:00 2001
From: Cheyenne Wills <cwills@sinenomine.net>
Date: Thu, 26 Jun 2025 10:08:49 -0600
Subject: [PATCH] linux: Make iops mkdir return a struct dentry *

The Linux 6.15 commit:
'Change inode_operations.mkdir to return struct dentry *' (88d5baf69082)
changed the signature for the return value for mkdir member of the
inope_operations structure.

The new return value for mkdir needs to be as follows:

    NULL if the directory was created and no other dentry was used
    ERR_PTR() if an error occured
    non-NULL pointer to a different dentry was used.

OpenAFS does not use a different dentry, so returning NULL or ERR_PTR
is sufficient.

Introduce a new autoconf check to determine if the inode_ops.mkdir needs
to return a pointer to a dentry.

Update afs_linux_mkdir to use ERR_PTR() on the return value.

Reviewed-on: https://gerrit.openafs.org/16373
Reviewed-by: Mark Vitale <mvitale@sinenomine.net>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
(cherry picked from commit 0c0280ed1324252c487409f0db9a8e215575fef4)

Change-Id: I96af366fc70076980ba0ba10e4b30f1db0f65e78
---

diff --git a/src/afs/LINUX/osi_vnodeops.c b/src/afs/LINUX/osi_vnodeops.c
index a1615a9..7c6f735 100644
--- a/src/afs/LINUX/osi_vnodeops.c
+++ b/src/afs/LINUX/osi_vnodeops.c
@@ -2079,8 +2079,11 @@
     crfree(credp);
     return afs_convert_code(code);
 }
-
-#if defined(IOP_TAKES_MNT_IDMAP)
+#if defined(HAVE_LINUX_INODE_OPERATIONS_MKDIR_RETURN_DENTRY)
+static struct dentry *
+afs_linux_mkdir(struct mnt_idmap *idmap, struct inode *dip,
+		struct dentry *dp, umode_t mode)
+#elif defined(IOP_TAKES_MNT_IDMAP)
 static int
 afs_linux_mkdir(struct mnt_idmap *idmap, struct inode *dip,
 		struct dentry *dp, umode_t mode)
@@ -2131,7 +2134,12 @@
     AFS_GUNLOCK();
 
     crfree(credp);
+
+#if defined(HAVE_LINUX_INODE_OPERATIONS_MKDIR_RETURN_DENTRY)
+    return ERR_PTR(afs_convert_code(code));
+#else
     return afs_convert_code(code);
+#endif
 }
 
 static int
diff --git a/src/cf/linux-kernel-sig.m4 b/src/cf/linux-kernel-sig.m4
index 5301f35..c9b8fe8 100644
--- a/src/cf/linux-kernel-sig.m4
+++ b/src/cf/linux-kernel-sig.m4
@@ -41,4 +41,13 @@
 AS_IF([test AS_VAR_GET([ac_cv_linux_operation_inode_operations_create_mnt_idmap]) = yes],
       [AC_DEFINE([IOP_TAKES_MNT_IDMAP], 1,
                  [define if inodeops require struct mnt_idmap])])
+
+dnl Linux 6.15 changed the return value for inode_operations.mkdir to a struct dentry *
+AC_CHECK_LINUX_OPERATION([inode_operations], [mkdir], [return_dentry],
+                         [#include <linux/fs.h>],
+                         [struct dentry *],
+                         [struct mnt_idmap *idmap,
+                         struct inode *inode, struct dentry *dentry,
+                         umode_t umode])
+
 ])
\ No newline at end of file
openSUSE Build Service is sponsored by