locks.c (7d7a48b76012eeee25871e1d69104dec4b6d740f) locks.c (99dc829256bb8cfcb1f58b7f118893fdbf608e60)
1/*
2 * linux/fs/locks.c
3 *
4 * Provide support for fcntl()'s F_GETLK, F_SETLK, and F_SETLKW calls.
5 * Doug Evans (dje@spiff.uucp), August 07, 1992
6 *
7 * Deadlock detection added.
8 * FIXME: one thing isn't handled yet:

--- 2095 unchanged lines hidden (view full) ---

2104
2105EXPORT_SYMBOL_GPL(vfs_cancel_lock);
2106
2107#ifdef CONFIG_PROC_FS
2108#include <linux/proc_fs.h>
2109#include <linux/seq_file.h>
2110
2111static void lock_get_status(struct seq_file *f, struct file_lock *fl,
1/*
2 * linux/fs/locks.c
3 *
4 * Provide support for fcntl()'s F_GETLK, F_SETLK, and F_SETLKW calls.
5 * Doug Evans (dje@spiff.uucp), August 07, 1992
6 *
7 * Deadlock detection added.
8 * FIXME: one thing isn't handled yet:

--- 2095 unchanged lines hidden (view full) ---

2104
2105EXPORT_SYMBOL_GPL(vfs_cancel_lock);
2106
2107#ifdef CONFIG_PROC_FS
2108#include <linux/proc_fs.h>
2109#include <linux/seq_file.h>
2110
2111static void lock_get_status(struct seq_file *f, struct file_lock *fl,
2112 int id, char *pfx)
2112 loff_t id, char *pfx)
2113{
2114 struct inode *inode = NULL;
2115 unsigned int fl_pid;
2116
2117 if (fl->fl_nspid)
2118 fl_pid = pid_vnr(fl->fl_nspid);
2119 else
2120 fl_pid = fl->fl_pid;
2121
2122 if (fl->fl_file != NULL)
2123 inode = fl->fl_file->f_path.dentry->d_inode;
2124
2113{
2114 struct inode *inode = NULL;
2115 unsigned int fl_pid;
2116
2117 if (fl->fl_nspid)
2118 fl_pid = pid_vnr(fl->fl_nspid);
2119 else
2120 fl_pid = fl->fl_pid;
2121
2122 if (fl->fl_file != NULL)
2123 inode = fl->fl_file->f_path.dentry->d_inode;
2124
2125 seq_printf(f, "%d:%s ", id, pfx);
2125 seq_printf(f, "%lld:%s ", id, pfx);
2126 if (IS_POSIX(fl)) {
2127 seq_printf(f, "%6s %s ",
2128 (fl->fl_flags & FL_ACCESS) ? "ACCESS" : "POSIX ",
2129 (inode == NULL) ? "*NOINODE*" :
2130 mandatory_lock(inode) ? "MANDATORY" : "ADVISORY ");
2131 } else if (IS_FLOCK(fl)) {
2132 if (fl->fl_type & LOCK_MAND) {
2133 seq_printf(f, "FLOCK MSNFS ");

--- 46 unchanged lines hidden (view full) ---

2180}
2181
2182static int locks_show(struct seq_file *f, void *v)
2183{
2184 struct file_lock *fl, *bfl;
2185
2186 fl = list_entry(v, struct file_lock, fl_link);
2187
2126 if (IS_POSIX(fl)) {
2127 seq_printf(f, "%6s %s ",
2128 (fl->fl_flags & FL_ACCESS) ? "ACCESS" : "POSIX ",
2129 (inode == NULL) ? "*NOINODE*" :
2130 mandatory_lock(inode) ? "MANDATORY" : "ADVISORY ");
2131 } else if (IS_FLOCK(fl)) {
2132 if (fl->fl_type & LOCK_MAND) {
2133 seq_printf(f, "FLOCK MSNFS ");

--- 46 unchanged lines hidden (view full) ---

2180}
2181
2182static int locks_show(struct seq_file *f, void *v)
2183{
2184 struct file_lock *fl, *bfl;
2185
2186 fl = list_entry(v, struct file_lock, fl_link);
2187
2188 lock_get_status(f, fl, (long)f->private, "");
2188 lock_get_status(f, fl, *((loff_t *)f->private), "");
2189
2190 list_for_each_entry(bfl, &fl->fl_block, fl_block)
2189
2190 list_for_each_entry(bfl, &fl->fl_block, fl_block)
2191 lock_get_status(f, bfl, (long)f->private, " ->");
2191 lock_get_status(f, bfl, *((loff_t *)f->private), " ->");
2192
2192
2193 f->private++;
2194 return 0;
2195}
2196
2197static void *locks_start(struct seq_file *f, loff_t *pos)
2198{
2193 return 0;
2194}
2195
2196static void *locks_start(struct seq_file *f, loff_t *pos)
2197{
2198 loff_t *p = f->private;
2199
2199 lock_flocks();
2200 lock_flocks();
2200 f->private = (void *)1;
2201 *p = (*pos + 1);
2201 return seq_list_start(&file_lock_list, *pos);
2202}
2203
2204static void *locks_next(struct seq_file *f, void *v, loff_t *pos)
2205{
2202 return seq_list_start(&file_lock_list, *pos);
2203}
2204
2205static void *locks_next(struct seq_file *f, void *v, loff_t *pos)
2206{
2207 loff_t *p = f->private;
2208 ++*p;
2206 return seq_list_next(v, &file_lock_list, pos);
2207}
2208
2209static void locks_stop(struct seq_file *f, void *v)
2210{
2211 unlock_flocks();
2212}
2213
2214static const struct seq_operations locks_seq_operations = {
2215 .start = locks_start,
2216 .next = locks_next,
2217 .stop = locks_stop,
2218 .show = locks_show,
2219};
2220
2221static int locks_open(struct inode *inode, struct file *filp)
2222{
2209 return seq_list_next(v, &file_lock_list, pos);
2210}
2211
2212static void locks_stop(struct seq_file *f, void *v)
2213{
2214 unlock_flocks();
2215}
2216
2217static const struct seq_operations locks_seq_operations = {
2218 .start = locks_start,
2219 .next = locks_next,
2220 .stop = locks_stop,
2221 .show = locks_show,
2222};
2223
2224static int locks_open(struct inode *inode, struct file *filp)
2225{
2223 return seq_open(filp, &locks_seq_operations);
2226 return seq_open_private(filp, &locks_seq_operations, sizeof(loff_t));
2224}
2225
2226static const struct file_operations proc_locks_operations = {
2227 .open = locks_open,
2228 .read = seq_read,
2229 .llseek = seq_lseek,
2227}
2228
2229static const struct file_operations proc_locks_operations = {
2230 .open = locks_open,
2231 .read = seq_read,
2232 .llseek = seq_lseek,
2230 .release = seq_release,
2233 .release = seq_release_private,
2231};
2232
2233static int __init proc_locks_init(void)
2234{
2235 proc_create("locks", 0, NULL, &proc_locks_operations);
2236 return 0;
2237}
2238module_init(proc_locks_init);

--- 89 unchanged lines hidden ---
2234};
2235
2236static int __init proc_locks_init(void)
2237{
2238 proc_create("locks", 0, NULL, &proc_locks_operations);
2239 return 0;
2240}
2241module_init(proc_locks_init);

--- 89 unchanged lines hidden ---