3 |
* |
* |
4 |
* Copyright (C) 2005-2009 NTT DATA CORPORATION |
* Copyright (C) 2005-2009 NTT DATA CORPORATION |
5 |
* |
* |
6 |
* Version: 1.7.0-pre 2009/08/08 |
* Version: 1.7.0-pre 2009/08/24 |
7 |
* |
* |
8 |
* This file is applicable to both 2.4.30 and 2.6.11 and later. |
* This file is applicable to both 2.4.30 and 2.6.11 and later. |
9 |
* See README.ccs for ChangeLog. |
* See README.ccs for ChangeLog. |
80 |
|
|
81 |
if (buflen < 256) |
if (buflen < 256) |
82 |
goto out; |
goto out; |
83 |
|
|
84 |
*pos = '\0'; |
*pos = '\0'; |
85 |
for (;;) { |
for (;;) { |
86 |
struct dentry *parent; |
struct dentry *parent; |
158 |
struct dentry *dentry = path->dentry; |
struct dentry *dentry = path->dentry; |
159 |
if (!dentry) |
if (!dentry) |
160 |
return NULL; |
return NULL; |
161 |
retry: |
while (1) { |
162 |
buf_len <<= 1; |
buf_len <<= 1; |
163 |
kfree(buf); |
kfree(buf); |
164 |
buf = kmalloc(buf_len, GFP_KERNEL); |
buf = kmalloc(buf_len, GFP_KERNEL); |
165 |
if (!buf) |
if (!buf) |
166 |
goto done; |
break; |
167 |
/* Get better name for socket. */ |
/* Get better name for socket. */ |
168 |
if (dentry->d_sb && dentry->d_sb->s_magic == SOCKFS_MAGIC) { |
if (dentry->d_sb && dentry->d_sb->s_magic == SOCKFS_MAGIC) { |
169 |
struct inode *inode = dentry->d_inode; |
struct inode *inode = dentry->d_inode; |
170 |
struct socket *sock = inode ? SOCKET_I(inode) : NULL; |
struct socket *sock = inode ? SOCKET_I(inode) : NULL; |
171 |
struct sock *sk = sock ? sock->sk : NULL; |
struct sock *sk = sock ? sock->sk : NULL; |
172 |
if (sk) { |
if (sk) { |
173 |
snprintf(buf, buf_len - 1, |
snprintf(buf, buf_len - 1, "socket:[family=%u:" |
174 |
"socket:[family=%u:type=%u:protocol=%u]", |
"type=%u:protocol=%u]", sk->sk_family, |
175 |
sk->sk_family, sk->sk_type, sk->sk_protocol); |
sk->sk_type, sk->sk_protocol); |
176 |
} else { |
} else { |
177 |
snprintf(buf, buf_len - 1, "socket:[unknown]"); |
snprintf(buf, buf_len - 1, "socket:[unknown]"); |
178 |
|
} |
179 |
|
cp = ccs_encode(buf); |
180 |
|
break; |
181 |
} |
} |
|
cp = ccs_encode(buf); |
|
|
goto done; |
|
|
} |
|
182 |
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 22) |
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 22) |
183 |
/* For "socket:[\$]" and "pipe:[\$]". */ |
/* For "socket:[\$]" and "pipe:[\$]". */ |
184 |
if (dentry->d_op && dentry->d_op->d_dname) { |
if (dentry->d_op && dentry->d_op->d_dname) { |
185 |
cp = dentry->d_op->d_dname(dentry, buf, buf_len - 1); |
cp = dentry->d_op->d_dname(dentry, buf, buf_len - 1); |
186 |
|
if (IS_ERR(cp)) |
187 |
|
continue; |
188 |
|
cp = ccs_encode(cp); |
189 |
|
break; |
190 |
|
} |
191 |
|
#endif |
192 |
|
if (!path->mnt) { |
193 |
|
cp = NULL; |
194 |
|
break; |
195 |
|
} |
196 |
|
path_get(path); |
197 |
|
ccs_realpath_lock(); |
198 |
|
cp = ccs_get_absolute_path(path, buf, buf_len - 1); |
199 |
|
ccs_realpath_unlock(); |
200 |
|
path_put(path); |
201 |
if (IS_ERR(cp)) |
if (IS_ERR(cp)) |
202 |
goto retry; |
continue; |
203 |
cp = ccs_encode(cp); |
cp = ccs_encode(cp); |
204 |
goto done; |
break; |
|
} |
|
|
#endif |
|
|
if (!path->mnt) { |
|
|
kfree(buf); |
|
|
return NULL; |
|
205 |
} |
} |
|
path_get(path); |
|
|
ccs_realpath_lock(); |
|
|
cp = ccs_get_absolute_path(path, buf, buf_len - 1); |
|
|
ccs_realpath_unlock(); |
|
|
path_put(path); |
|
|
if (IS_ERR(cp)) |
|
|
goto retry; |
|
|
cp = ccs_encode(cp); |
|
|
done: |
|
206 |
kfree(buf); |
kfree(buf); |
207 |
if (!cp) |
if (!cp) |
208 |
ccs_warn_oom(__func__); |
ccs_warn_oom(__func__); |