~juanje/udev/udev-acls-android

« back to all changes in this revision

Viewing changes to udev/udev-rules.c

  • Committer: Bazaar Package Importer
  • Author(s): Scott James Remnant
  • Date: 2009-12-02 01:40:55 UTC
  • Revision ID: james.westby@ubuntu.com-20091202014055-g5f7k5z3db7njmlj
Tags: 148~-1
* Update to GIT HEAD:
  - Ignore_device option removed.
  - BUS, SYSFS and ID are now deprecated and result in a warning.
  - IDE device support removed from default rules.
  - New input_id helper, previous uses of the ID_CLASS property on
    input devices should now use the new ID_INPUT_* properties.  This
    is a big part of the Halsectomy of X.org

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
#include <stddef.h>
20
20
#include <limits.h>
21
21
#include <stdlib.h>
 
22
#include <stdbool.h>
22
23
#include <string.h>
23
24
#include <stdio.h>
24
25
#include <fcntl.h>
144
145
        TK_M_RESULT,                    /* val */
145
146
        TK_M_MAX,
146
147
 
147
 
        TK_A_IGNORE_DEVICE,
148
148
        TK_A_STRING_ESCAPE_NONE,
149
149
        TK_A_STRING_ESCAPE_REPLACE,
150
150
        TK_A_INOTIFY_WATCH,             /* int */
275
275
                [TK_M_RESULT] =                 "M RESULT",
276
276
                [TK_M_MAX] =                    "M MAX",
277
277
 
278
 
                [TK_A_IGNORE_DEVICE] =          "A IGNORE_DEVICE",
279
278
                [TK_A_STRING_ESCAPE_NONE] =     "A STRING_ESCAPE_NONE",
280
279
                [TK_A_STRING_ESCAPE_REPLACE] =  "A STRING_ESCAPE_REPLACE",
281
280
                [TK_A_INOTIFY_WATCH] =          "A INOTIFY_WATCH",
357
356
                dbg(rules->udev, "%s %s '%s' '%s'(%s)\n",
358
357
                    token_str(type), operation_str(op), attr, value, string_glob_str(glob));
359
358
                break;
360
 
        case TK_A_IGNORE_DEVICE:
361
359
        case TK_A_STRING_ESCAPE_NONE:
362
360
        case TK_A_STRING_ESCAPE_REPLACE:
363
361
        case TK_A_IGNORE_REMOVE:
1030
1028
                if (data != NULL)
1031
1029
                        token->key.mode = *(mode_t *)data;
1032
1030
                break;
1033
 
        case TK_A_IGNORE_DEVICE:
1034
1031
        case TK_A_STRING_ESCAPE_NONE:
1035
1032
        case TK_A_STRING_ESCAPE_REPLACE:
1036
1033
        case TK_A_IGNORE_REMOVE:
1160
1157
        char *linepos;
1161
1158
        char *attr;
1162
1159
        struct rule_tmp rule_tmp;
 
1160
        bool bus_warn = false;
 
1161
        bool sysfs_warn = false;
 
1162
        bool id_warn = false;
1163
1163
 
1164
1164
        memset(&rule_tmp, 0x00, sizeof(struct rule_tmp));
1165
1165
        rule_tmp.rules = rules;
1244
1244
                        continue;
1245
1245
                }
1246
1246
 
1247
 
                if (strcmp(key, "KERNELS") == 0 ||
1248
 
                    strcmp(key, "ID") == 0) {
1249
 
                        if (op > OP_MATCH_MAX) {
1250
 
                                err(rules->udev, "invalid KERNELS operation\n");
1251
 
                                goto invalid;
1252
 
                        }
1253
 
                        rule_add_key(&rule_tmp, TK_M_KERNELS, op, value, NULL);
1254
 
                        continue;
1255
 
                }
1256
 
 
1257
 
                if (strcmp(key, "SUBSYSTEMS") == 0 ||
1258
 
                    strcmp(key, "BUS") == 0) {
 
1247
                if (strcmp(key, "KERNELS") == 0) {
 
1248
                        if (op > OP_MATCH_MAX) {
 
1249
                                err(rules->udev, "invalid KERNELS operation\n");
 
1250
                                goto invalid;
 
1251
                        }
 
1252
                        rule_add_key(&rule_tmp, TK_M_KERNELS, op, value, NULL);
 
1253
                        continue;
 
1254
                }
 
1255
 
 
1256
                if (strcmp(key, "ID") == 0) {
 
1257
                        if (!id_warn) {
 
1258
                                id_warn = true;
 
1259
                                err(rules->udev, "ID= will be removed in a future udev version, "
 
1260
                                    "please use KERNEL= to match the event device, or KERNELS= "
 
1261
                                    "to match a parent device, in %s:%u\n", filename, lineno);
 
1262
                        }
 
1263
                        if (op > OP_MATCH_MAX) {
 
1264
                                err(rules->udev, "invalid KERNELS operation\n");
 
1265
                                goto invalid;
 
1266
                        }
 
1267
                        rule_add_key(&rule_tmp, TK_M_KERNELS, op, value, NULL);
 
1268
                        continue;
 
1269
                }
 
1270
 
 
1271
                if (strcmp(key, "SUBSYSTEMS") == 0) {
 
1272
                        if (op > OP_MATCH_MAX) {
 
1273
                                err(rules->udev, "invalid SUBSYSTEMS operation\n");
 
1274
                                goto invalid;
 
1275
                        }
 
1276
                        rule_add_key(&rule_tmp, TK_M_SUBSYSTEMS, op, value, NULL);
 
1277
                        continue;
 
1278
                }
 
1279
 
 
1280
                if (strcmp(key, "BUS") == 0) {
 
1281
                        if (!bus_warn) {
 
1282
                                bus_warn = true;
 
1283
                                err(rules->udev, "BUS= will be removed in a future udev version, "
 
1284
                                    "please use SUBSYSTEM= to match the event device, or SUBSYSTEMS= "
 
1285
                                    "to match a parent device, in %s:%u\n", filename, lineno);
 
1286
                        }
1259
1287
                        if (op > OP_MATCH_MAX) {
1260
1288
                                err(rules->udev, "invalid SUBSYSTEMS operation\n");
1261
1289
                                goto invalid;
1273
1301
                        continue;
1274
1302
                }
1275
1303
 
1276
 
                if (strncmp(key, "ATTRS{", sizeof("ATTRS{")-1) == 0 ||
1277
 
                    strncmp(key, "SYSFS{", sizeof("SYSFS{")-1) == 0) {
 
1304
                if (strncmp(key, "ATTRS{", sizeof("ATTRS{")-1) == 0) {
1278
1305
                        if (op > OP_MATCH_MAX) {
1279
1306
                                err(rules->udev, "invalid ATTRS operation\n");
1280
1307
                                goto invalid;
1294
1321
                        continue;
1295
1322
                }
1296
1323
 
 
1324
                if (strncmp(key, "SYSFS{", sizeof("SYSFS{")-1) == 0) {
 
1325
                        if (!sysfs_warn) {
 
1326
                                sysfs_warn = true;
 
1327
                                err(rules->udev, "SYSFS{}= will be removed in a future udev version, "
 
1328
                                    "please use ATTR{}= to match the event device, or ATTRS{}= "
 
1329
                                    "to match a parent device, in %s:%u\n", filename, lineno);
 
1330
                        }
 
1331
                        if (op > OP_MATCH_MAX) {
 
1332
                                err(rules->udev, "invalid ATTRS operation\n");
 
1333
                                goto invalid;
 
1334
                        }
 
1335
                        attr = get_key_attribute(rules->udev, key + sizeof("ATTRS")-1);
 
1336
                        if (attr == NULL) {
 
1337
                                err(rules->udev, "error parsing ATTRS attribute\n");
 
1338
                                goto invalid;
 
1339
                        }
 
1340
                        rule_add_key(&rule_tmp, TK_M_ATTRS, op, value, attr);
 
1341
                        continue;
 
1342
                }
 
1343
 
1297
1344
                if (strncmp(key, "ENV{", sizeof("ENV{")-1) == 0) {
1298
1345
                        attr = get_key_attribute(rules->udev, key + sizeof("ENV")-1);
1299
1346
                        if (attr == NULL) {
1496
1543
                if (strcmp(key, "OPTIONS") == 0) {
1497
1544
                        const char *pos;
1498
1545
 
1499
 
                        if (strstr(value, "ignore_device") != NULL) {
1500
 
                                dbg(rules->udev, "device should be ignored\n");
1501
 
                                rule_add_key(&rule_tmp, TK_A_IGNORE_DEVICE, 0, NULL, NULL);
1502
 
                        }
1503
1546
                        if (strstr(value, "ignore_remove") != NULL) {
1504
1547
                                dbg(rules->udev, "remove event should be ignored\n");
1505
1548
                                rule_add_key(&rule_tmp, TK_A_IGNORE_REMOVE, 0, NULL, NULL);
2259
2302
                        if (match_key(rules, cur, event->program_result) != 0)
2260
2303
                                goto nomatch;
2261
2304
                        break;
2262
 
 
2263
 
                case TK_A_IGNORE_DEVICE:
2264
 
                        event->ignore_device = 1;
2265
 
                        return 0;
2266
 
                        break;
2267
2305
                case TK_A_STRING_ESCAPE_NONE:
2268
2306
                        esc = ESCAPE_NONE;
2269
2307
                        break;