self.c (1a384eaac265b57961c9696d9177f82eb84319e9) | self.c (fceef393a538134f03b778c5d2519e670269342f) |
---|---|
1#include <linux/sched.h> 2#include <linux/slab.h> 3#include <linux/pid_namespace.h> 4#include "internal.h" 5 6/* 7 * /proc/self: 8 */ --- 5 unchanged lines hidden (view full) --- 14 char tmp[PROC_NUMBUF]; 15 if (!tgid) 16 return -ENOENT; 17 sprintf(tmp, "%d", tgid); 18 return readlink_copy(buffer, buflen, tmp); 19} 20 21static const char *proc_self_get_link(struct dentry *dentry, | 1#include <linux/sched.h> 2#include <linux/slab.h> 3#include <linux/pid_namespace.h> 4#include "internal.h" 5 6/* 7 * /proc/self: 8 */ --- 5 unchanged lines hidden (view full) --- 14 char tmp[PROC_NUMBUF]; 15 if (!tgid) 16 return -ENOENT; 17 sprintf(tmp, "%d", tgid); 18 return readlink_copy(buffer, buflen, tmp); 19} 20 21static const char *proc_self_get_link(struct dentry *dentry, |
22 struct inode *inode, void **cookie) | 22 struct inode *inode, 23 struct delayed_call *done) |
23{ 24 struct pid_namespace *ns = inode->i_sb->s_fs_info; 25 pid_t tgid = task_tgid_nr_ns(current, ns); 26 char *name; 27 28 if (!tgid) 29 return ERR_PTR(-ENOENT); 30 /* 11 for max length of signed int in decimal + NULL term */ 31 name = kmalloc(12, dentry ? GFP_KERNEL : GFP_ATOMIC); 32 if (unlikely(!name)) 33 return dentry ? ERR_PTR(-ENOMEM) : ERR_PTR(-ECHILD); 34 sprintf(name, "%d", tgid); | 24{ 25 struct pid_namespace *ns = inode->i_sb->s_fs_info; 26 pid_t tgid = task_tgid_nr_ns(current, ns); 27 char *name; 28 29 if (!tgid) 30 return ERR_PTR(-ENOENT); 31 /* 11 for max length of signed int in decimal + NULL term */ 32 name = kmalloc(12, dentry ? GFP_KERNEL : GFP_ATOMIC); 33 if (unlikely(!name)) 34 return dentry ? ERR_PTR(-ENOMEM) : ERR_PTR(-ECHILD); 35 sprintf(name, "%d", tgid); |
35 return *cookie = name; | 36 set_delayed_call(done, kfree_link, name); 37 return name; |
36} 37 38static const struct inode_operations proc_self_inode_operations = { 39 .readlink = proc_self_readlink, 40 .get_link = proc_self_get_link, | 38} 39 40static const struct inode_operations proc_self_inode_operations = { 41 .readlink = proc_self_readlink, 42 .get_link = proc_self_get_link, |
41 .put_link = kfree_put_link, | |
42}; 43 44static unsigned self_inum; 45 46int proc_setup_self(struct super_block *s) 47{ 48 struct inode *root_inode = d_inode(s->s_root); 49 struct pid_namespace *ns = s->s_fs_info; --- 34 unchanged lines hidden --- | 43}; 44 45static unsigned self_inum; 46 47int proc_setup_self(struct super_block *s) 48{ 49 struct inode *root_inode = d_inode(s->s_root); 50 struct pid_namespace *ns = s->s_fs_info; --- 34 unchanged lines hidden --- |