[PATCH] Removed procfs support

From: Alessandro Di Marco
Date: Wed Jan 24 2007 - 12:45:40 EST


---
Makefile | 2 +-
gentable | 21 ++++---
procfs.c | 202 --------------------------------------------------------------
procfs.h | 33 ----------
sin.c | 10 ---
5 files changed, 14 insertions(+), 254 deletions(-)

diff --git a/Makefile b/Makefile
index 8b80de6..62b1c43 100644
--- a/Makefile
+++ b/Makefile
@@ -3,7 +3,7 @@ MODLPATH = kernel/drivers/char
#DEBUG="-D SIN_DEBUG"

MODL = sinmod
-OBJS = sin.o procfs.o sysfs.o table.o input_enumerator.o acpi_enumerator.o
+OBJS = sin.o sysfs.o table.o input_enumerator.o acpi_enumerator.o

SRCS := $(patsubst %.o,%.c,$(OBJS))
HDRS := $(patsubst %.o,%.h,$(OBJS))
diff --git a/gentable b/gentable
index 49af1f4..a8fe292 100755
--- a/gentable
+++ b/gentable
@@ -24,8 +24,8 @@ if (( $# == 0 )); then
exit
fi

-if [ ! -d "/proc/sin" ]; then
- echo "/proc/sin not found, has sinmod been loaded?"
+if [ ! -d "/sys/class/misc/sin" ]; then
+ echo "/sys/class/misc/sin not found, has sinmod been loaded?"
exit
fi

@@ -38,7 +38,7 @@ least one device and must not specify duplicates.
EOF

echo -e "Specify the the input devices you want to monitor from the list below:\n"
-cat /proc/sin/input
+cat /sys/class/misc/sin/input

echo
input "Please digit the corresponding numbers separated by spaces" devs
@@ -57,7 +57,7 @@ suitable handler that will be used as originator.
EOF

echo -e "Specify the acpi handler you want to use from the list below:\n"
-cat /proc/sin/acpi
+cat /sys/class/misc/sin/acpi

echo
input "Please enter the number corresponding to the handler" handle
@@ -83,6 +83,8 @@ finished, just press enter.

EOF

+declare -i i
+
for (( i = 0; ; i++ )); do
input "Rule ${i}?" rule

@@ -95,6 +97,7 @@ done

if (( ${i} == 0 )); then
rules[0]="60 1 2"
+ i=${i}+1
fi

cat <<EOF
@@ -111,6 +114,8 @@ if [ -z "${resume}" ]; then
resume="2 1"
fi

+declare -i j=${i}-1
+
cat <<EOF

Often an SIN event results in suspending or hibernating the system, hibernate,
@@ -120,10 +125,10 @@ consequence, no event will ever be generated and the system will remain in the
state associated with the next-to-last rule (e.g. blanked screen, wireless
powered off, etc.). The next option allows you to request a special event,
restarting the rule-list evaluation from an arbitrary position. Possible value
-ranges are described below, where N is the rule-list size:
+ranges are described below:

- [0, N - 1] => jump to the given rule
- N => go to sleep and wait for user interaction
+ [0, ${j}] => jump to the given rule
+ ${i} => go to sleep and wait for user interaction

EOF

@@ -144,7 +149,7 @@ cat <<EOF
All done. Now you can try your newly generated table as follows:

# modprobe sinmod
-# echo $1 >/proc/sin/table
+# echo $1 >/sys/class/misc/sin/table

An "Invalid argument" error indicates a mismatch in the table file, usually due
to specifying an invalid acpi or input device. In that case, restart from
diff --git a/procfs.c b/procfs.c
deleted file mode 100644
index 7f42dde..0000000
--- a/procfs.c
+++ /dev/null
@@ -1,202 +0,0 @@
-/*
- * Copyright (C) 2007 Alessandro Di Marco
- */
-
-/*
- * This file is part of SIN.
- *
- * SIN is free software; you can redistribute it and/or modify it under the
- * terms of the GNU General Public License as published by the Free Software
- * Foundation; version 2 of the License.
- *
- * SIN is distributed in the hope that it will be useful, but WITHOUT ANY
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
- * details.
- *
- * You should have received a copy of the GNU General Public License along
- * with SIN; if not, write to the Free Software Foundation, Inc., 51 Franklin
- * St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include <linux/module.h>
-#include <linux/proc_fs.h>
-#include <linux/uaccess.h>
-
-#include "sin.h"
-#include "table.h"
-#include "procfs.h"
-#include "acpi_enumerator.h"
-#include "input_enumerator.h"
-
-static struct procfs_bs ibs, abs;
-static struct proc_dir_entry *rootdir;
-
-static int read_proc(char *page, char **start,
- off_t off, int count, int *eof, void *data)
-{
- struct procfs_bs *bs = data;
- int left = bs->size - off;
-
- if (count > left) {
- count = left;
- }
-
- memcpy(page + off, bs->page, count);
-
- if (count == left) {
- *eof = 1;
- }
-
- return off + count;
-}
-
-static int read_table_proc(char *page, char **start,
- off_t off, int count, int *eof, void *data)
-{
- char *buf;
- size_t size;
-
- int left;
- int err = -ENOMEM;
-
- size = pull_table(&buf);
- if (!buf) {
- goto out;
- }
-
- if (size > PAGE_SIZE) {
- size = PAGE_SIZE;
- }
-
- left = size - off;
- if (left < 0) {
- err = -ESPIPE;
- goto out;
- }
-
- if (count > left) {
- count = left;
- }
-
- memcpy(page + off, buf, count);
-
- if (count == left) {
- page[size] = '\0';
- *eof = 1;
- }
-
- return off + count;
-
-out:
- return err;
-}
-
-static int write_table_proc(struct file *file, const __user char *ubuf,
- unsigned long count, void *data)
-{
- char *buf;
- int err;
-
- buf = kmalloc(count, GFP_KERNEL);
- if (!buf) {
- err = -ENOMEM;
- goto out;
- }
-
- if (copy_from_user(buf, ubuf, count + 1)) {
- err = -EFAULT;
- goto cleanout;
- }
-
- buf[count] = '\0';
-
- err = push_table(buf, count);
-
-cleanout:
- kfree(buf);
-out:
- return err;
-}
-
-static int fake_write_proc(struct file *file, const __user char *ubuf,
- unsigned long count, void *data)
-{
- void (*func)(void) = data;
-
- func();
- return count;
-}
-
-int start_procfs(void)
-{
- struct proc_dir_entry *inputd, *acpid, *table, *interact;
- int err = -ENOMEM;
-
- ibs.size = get_devices_desc(&ibs.page);
- abs.size = get_handlers_desc(&abs.page);
-
- rootdir = proc_mkdir(MODULE_NAME, NULL);
- if (!rootdir) {
- goto out;
- }
-
- rootdir->owner = THIS_MODULE;
-
- inputd = create_proc_read_entry("input", 0444,
- rootdir, read_proc, &ibs);
- if (!inputd) {
- goto cleanout1;
- }
-
- inputd->owner = THIS_MODULE;
-
- acpid = create_proc_read_entry("acpi", 0444,
- rootdir, read_proc, &abs);
- if (!acpid) {
- goto cleanout2;
- }
-
- acpid->owner = THIS_MODULE;
-
- table = create_proc_entry("table", 0644, rootdir);
- if (!table) {
- goto cleanout3;
- }
-
- table->data = NULL;
- table->read_proc = read_table_proc;
- table->write_proc = write_table_proc;
- table->owner = THIS_MODULE;
-
- interact = create_proc_entry("interact", 0200, rootdir);
- if (!interact) {
- goto cleanout4;
- }
-
- interact->data = (void *) simulate_event;
- interact->write_proc = fake_write_proc;
- interact->owner = THIS_MODULE;
-
- return 0;
-
-cleanout4:
- remove_proc_entry("table", rootdir);
-cleanout3:
- remove_proc_entry("acpi", rootdir);
-cleanout2:
- remove_proc_entry("input", rootdir);
-cleanout1:
- remove_proc_entry(MODULE_NAME, NULL);
-out:
- return err;
-}
-
-void stop_procfs(void)
-{
- remove_proc_entry("interact", rootdir);
- remove_proc_entry("table", rootdir);
- remove_proc_entry("acpi", rootdir);
- remove_proc_entry("input", rootdir);
- remove_proc_entry(MODULE_NAME, NULL);
-}
diff --git a/procfs.h b/procfs.h
deleted file mode 100644
index ea164be..0000000
--- a/procfs.h
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Copyright (C) 2007 Alessandro Di Marco
- */
-
-/*
- * This file is part of SIN.
- *
- * SIN is free software; you can redistribute it and/or modify it under the
- * terms of the GNU General Public License as published by the Free Software
- * Foundation; version 2 of the License.
- *
- * SIN is distributed in the hope that it will be useful, but WITHOUT ANY
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
- * details.
- *
- * You should have received a copy of the GNU General Public License along
- * with SIN; if not, write to the Free Software Foundation, Inc., 51 Franklin
- * St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#ifndef PROCFS_H
-#define PROCFS_H
-
-struct procfs_bs {
- char *page;
- int size;
-};
-
-extern int start_procfs(void);
-extern void stop_procfs(void);
-
-#endif /* PROCFS_H */
diff --git a/sin.c b/sin.c
index bf06999..7b96c61 100644
--- a/sin.c
+++ b/sin.c
@@ -30,7 +30,6 @@

#include "sin.h"
#include "table.h"
-#include "procfs.h"
#include "sysfs.h"
#include "acpi_enumerator.h"
#include "input_enumerator.h"
@@ -275,18 +274,10 @@ static int __devinit sin_probe(struct platform_device *dev)
goto cleanout3;
}

- err = start_procfs();
- if (err < 0) {
- printk(KERN_ERR "SIN: procfs initialization failed\n");
- goto cleanout4;
- }
-
printk(KERN_DEBUG "System Inactivity Notifier 1.5 - (c) Alessandro Di Marco <dmr@xxxxxx>\n");

return 0;

-cleanout4:
- stop_sysfs();
cleanout3:
free_acpi_enum();
cleanout2:
@@ -299,7 +290,6 @@ out:

static int __devexit sin_remove(struct platform_device *dev)
{
- stop_procfs();
stop_sysfs();
free_acpi_enum();
free_input_enum();
--
1.4.4.4


--=-=-=


--
Advertising is a valuable economic factor because it is the cheapest way of
selling goods, particularly if the goods are worthless. - Sinclair Lewis

--=-=-=--
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/