@@ -78,7 +78,7 @@ void pidfs_remove_pid(struct pid *pid)
}
/* Find a struct pid based on the inode number. */
-static __maybe_unused struct pid *pidfs_ino_get_pid(u64 ino)
+static struct pid *pidfs_ino_get_pid(u64 ino)
{
ino_t pid_ino = pidfs_ino(ino);
u32 gen = pidfs_gen(ino);
@@ -475,49 +475,37 @@ static const struct dentry_operations pidfs_dentry_operations = {
.d_prune = stashed_dentry_prune,
};
-#define PIDFD_FID_LEN 3
-
-struct pidfd_fid {
- u64 ino;
- s32 pid;
-} __packed;
-
-static int pidfs_encode_fh(struct inode *inode, u32 *fh, int *max_len,
+static int pidfs_encode_fh(struct inode *inode, __u32 *fh, int *max_len,
struct inode *parent)
{
struct pid *pid = inode->i_private;
- struct pidfd_fid *fid = (struct pidfd_fid *)fh;
- if (*max_len < PIDFD_FID_LEN) {
- *max_len = PIDFD_FID_LEN;
+ if (*max_len < 2) {
+ *max_len = 2;
return FILEID_INVALID;
}
- fid->ino = pid->ino;
- fid->pid = pid_nr(pid);
- *max_len = PIDFD_FID_LEN;
+ *max_len = 2;
+ *(u64 *)fh = pid->ino;
return FILEID_INO64_GEN;
}
static struct dentry *pidfs_fh_to_dentry(struct super_block *sb,
- struct fid *gen_fid,
+ struct fid *fid,
int fh_len, int fh_type)
{
int ret;
struct path path;
- struct pidfd_fid *fid = (struct pidfd_fid *)gen_fid;
struct pid *pid;
+ u64 pid_ino;
- if (fh_type != FILEID_INO64_GEN || fh_len < PIDFD_FID_LEN)
+ if (fh_type != FILEID_INO64_GEN || fh_len < 2)
return NULL;
- scoped_guard(rcu) {
- pid = find_pid_ns(fid->pid, &init_pid_ns);
- if (!pid || pid->ino != fid->ino || pid_vnr(pid) == 0)
- return NULL;
-
- pid = get_pid(pid);
- }
+ pid_ino = *(u64 *)fid;
+ pid = pidfs_ino_get_pid(pid_ino);
+ if (!pid)
+ return NULL;
ret = path_from_stashed(&pid->stashed, pidfs_mnt, pid, &path);
if (ret < 0)