Problem statement -
You have to find (print) the capabilities of a process from inside the kernel.
Since you are inside Linux Kernel you cannot use user space utilities(shell commands) to get capabilities, neither do you have user space library calls capget(), and capset(). Invoking system calls capset() and capget() [sys_capget, and sys_capget - notice that the system calls and the user space counterpart have the same name] from inside the kernel may seem convoluted.

Solution -
use the following code.

/*Remember - we are inside kernel*/
/*If pid=0 find capability of the current process*/

int print_capabilities(int pid=0){

kernel_cap_t pE, pI, pP; //effective inheritable, and permitted
int ret=0;
__u64 *cap=NULL;
__u64 one=1;
int pid=0;//send 0 as pid to lxc_uio_cap_get_target_pid() to get capabilities of current process.

char *capabilities[]={
"CAP_CHOWN ",
"CAP_DAC_OVERRIDE ",
"CAP_DAC_READ_SEARCH ",
"CAP_FOWNER ",
"CAP_FSETID ",
"CAP_KILL ",
"CAP_SETGID ",
"CAP_SETUID ",
"CAP_SETPCAP ",
"CAP_LINUX_IMMUTABLE ",
"CAP_NET_BIND_SERVICE",
"CAP_NET_BROADCAST ",
"CAP_NET_ADMIN ",
"CAP_NET_RAW ",
"CAP_IPC_LOCK ",
"CAP_IPC_OWNER ",
"CAP_SYS_MODULE ",
"CAP_SYS_RAWIO ",
"CAP_SYS_CHROOT ",
"CAP_SYS_PTRACE ",
"CAP_SYS_PACCT ",
"CAP_SYS_ADMIN ",
"CAP_SYS_BOOT ",
"CAP_SYS_NICE ",
"CAP_SYS_RESOURCE ",
"CAP_SYS_TIME ",
"CAP_SYS_TTY_CONFIG ",
"CAP_MKNOD ",
"CAP_LEASE ",
"CAP_AUDIT_WRITE ",
"CAP_AUDIT_CONTROL ",
"CAP_SETFCAP ",
"CAP_MAC_OVERRIDE ",
"CAP_MAC_ADMIN ",
"CAP_SYSLOG ",
"CAP_WAKE_ALARM ",
"CAP_BLOCK_SUSPEND ",
"CAP_AUDIT_READ "
};

ret=lxc_uio_cap_get_target_pid(pid, &pE, &pI, &pP);
if(ret!=0){
//error
printk(KERN_ALERT"[lxc-uio] Error getting capabilities\n");
return ret;
}

printk(KERN_ALERT"Effective Capabilities\n");
for(ret=0;ret<=37;ret++){
cap=(void *)&pE.cap[0];
printk(KERN_ALERT"[sahil] %s [%d]\n",capabilities[ret],(*cap & (one<>ret);
}

printk(KERN_ALERT"Permitted Capabilities\n");
for(ret=0;ret<=37;ret++){
cap=(void *)&pP.cap[0];
printk(KERN_ALERT"[sahil] %s [%d]\n",capabilities[ret],(*cap & (one<>ret);
}int


printk(KERN_ALERT"Inheritable Capabilities\n");
for(ret=0;ret<=37;ret++){
cap=(void *)&pI.cap[0];
printk(KERN_ALERT"[sahil] %s [%d]\n",capabilities[ret],(*cap & (one<>ret);
}

return 0;
}


static inline int lxc_uio_cap_get_target_pid(pid_t pid, kernel_cap_t *pEp,
kernel_cap_t *pIp, kernel_cap_t *pPp)
{
/* copied from capability.c since there the function was declared as static */
int ret;

if (pid && (pid != task_pid_vnr(current))) {
struct task_struct *target;

rcu_read_lock();

target = find_task_by_vpid(pid);
if (!target)
ret = -ESRCH;
else
ret = security_capget(target, pEp, pIp, pPp);

rcu_read_unlock();
} else
ret = security_capget(current, pEp, pIp, pPp);

return ret;
}


My system -
Ubuntu 16.04.1
Linux 4.7.3 kernel