File: info.inc

package info (click to toggle)
alsa-driver 1.0.13-5etch1
  • links: PTS
  • area: main
  • in suites: etch
  • size: 20,108 kB
  • ctags: 50,477
  • sloc: ansic: 319,881; sh: 32,930; makefile: 2,015; python: 1,527; perl: 1,316; xml: 896; awk: 66
file content (92 lines) | stat: -rw-r--r-- 2,001 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#define __NO_VERSION__
#include <linux/config.h>
#include <linux/version.h>

#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 4, 0)
#include <sound/driver.h>
#include <sound/core.h>
#include <sound/info.h>
#include <sound/version.h>
#include <linux/proc_fs.h>

static int snd_info_card_readlink(struct dentry *dentry,
				  char *buffer, int buflen)
{
        char *s = PDE(dentry->d_inode)->data;
	int len;
	
	if (s == NULL)
		return -EIO;
	len = strlen(s);
	if (len > buflen)
		len = buflen;
	if (copy_to_user(buffer, s, len))
		return -EFAULT;
	return len;
}

static struct dentry *snd_info_card_followlink(struct dentry *dentry,
					       struct dentry *base,
					       unsigned int follow)
{
	char *s = PDE(dentry->d_inode)->data;
	return lookup_dentry(s, base, follow);
}

static struct file_operations snd_info_card_link_operations =
{
	NULL
};

struct inode_operations snd_info_card_link_inode_operations =
{
	.default_file_ops =	&snd_info_card_link_operations,
	.readlink =		snd_info_card_readlink,
	.follow_link =		snd_info_card_followlink,
};

static struct proc_dir_entry *proc_symlink(const char *name,
					   struct proc_dir_entry *parent,
					   const char *dest)
{
	char *s = kstrdup(dest, GFP_KERNEL);
	struct proc_dir_entry *p;

	if (s == NULL)
		return NULL;
	p = create_proc_entry(name, S_IFLNK | S_IRUGO | S_IWUGO | S_IXUGO, parent);
 	if (p == NULL) {
		kfree(s);
 		return NULL;
	}
	p->data = s;
	p->ops = &snd_info_card_link_inode_operations;
	return p;
}

static void snd_info_fill_inode(struct inode *inode, int fill)
{
	if (fill)
		MOD_INC_USE_COUNT;
	else
		MOD_DEC_USE_COUNT;
}

static inline void snd_info_entry_prepare(struct proc_dir_entry *de)
{
	de->fill_inode = snd_info_fill_inode;
}

void snd_remove_proc_entry(struct proc_dir_entry *parent,
			   struct proc_dir_entry *de)
{
	if (parent && de) {
		if (S_ISLNK(de->mode) && de->data) {
			kfree(de->data);
			de->data = 0;
		}
		proc_unregister(parent, de->low_ino);
	}
}

#endif /* LINUX_VERSION_CODE < 2.4.0 */