chiark / gitweb /
[PATCH] enabled debugging.
[elogind.git] / udev.c
1 /*
2  * udev.c
3  *
4  * Userspace devfs
5  *
6  * Copyright (C) 2003 Greg Kroah-Hartman <greg@kroah.com>
7  *
8  *
9  *      This program is free software; you can redistribute it and/or modify it
10  *      under the terms of the GNU General Public License as published by the
11  *      Free Software Foundation version 2 of the License.
12  * 
13  *      This program is distributed in the hope that it will be useful, but
14  *      WITHOUT ANY WARRANTY; without even the implied warranty of
15  *      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16  *      General Public License for more details.
17  * 
18  *      You should have received a copy of the GNU General Public License along
19  *      with this program; if not, write to the Free Software Foundation, Inc.,
20  *      675 Mass Ave, Cambridge, MA 02139, USA.
21  *
22  */
23
24 #include <stdlib.h>
25 #include <string.h>
26 #include "udev.h"
27 #include "udev_version.h"
28
29
30 static char *get_action(void)
31 {
32         char *action;
33
34         action = getenv("ACTION");
35         return action;
36 }
37
38
39 /* yeah this should be dynamically allocated... */
40 static char device[255];
41
42 static char *get_device(void)
43 {
44         char *temp;
45
46         temp = getenv("DEVPATH");
47         if (temp == NULL)
48                 return NULL;
49         strcpy(device, SYSFS_ROOT);
50         strcat(device, temp);
51
52         return device;
53 }
54
55
56 int main(int argc, char *argv[])
57 {
58         char *subsystem;
59         char *action;
60         char *dev;
61         
62         if (argc != 2) {
63                 dbg ("unknown number of arguments");
64                 return 1;
65         }
66
67         subsystem = argv[1];
68
69         action = get_action();
70         if (!action) {
71                 dbg ("no action?");
72                 return 1;
73         }
74
75         dev = get_device();
76         if (!dev) {
77                 dbg ("no device?");
78                 return 1;
79         }
80
81         return 0;
82 }
83