~ubuntu-branches/ubuntu/raring/usb-modeswitch/raring

« back to all changes in this revision

Viewing changes to usb_modeswitch_dispatcher.c

  • Committer: Package Import Robot
  • Author(s): Mathieu Trudel-Lapierre
  • Date: 2012-10-08 19:39:48 UTC
  • Revision ID: package-import@ubuntu.com-20121008193948-q7k63tjzzkgn7idx
Tags: 1.2.3+repack0-1ubuntu3
debian/patches/dispatcher-c-rewrite.patch: correct the "search" for
modprobe to properly figure out whether it's available from PATH.
(LP: #990337)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1215
1215
 */
1216
1216
void check_driver_bind (char* vid, char* pid)
1217
1217
{
1218
 
        char *default_loader = MODPROBE;
 
1218
        char *path = NULL;
 
1219
        char *token = NULL;
1219
1220
        char *loader = NULL, *id_file;
1220
1221
        char *vendor_spec, *product_spec;
1221
1222
        struct stat buf;
1223
1224
        pipeline *p;
1224
1225
        FILE *new_id_f;
1225
1226
 
1226
 
        x = lstat (default_loader, &buf);
1227
 
        if (x != 0)
1228
 
                modeswitch_log (" %s not found", default_loader);
1229
 
        else
1230
 
                loader = strdup(default_loader);
 
1227
        path = strdup(getenv("PATH"));
 
1228
        token = strtok(path, ":");
 
1229
        while (token != NULL) {
 
1230
                asprintf(&loader, "%s/%s", token, MODPROBE);
 
1231
                x = lstat (loader, &buf);
 
1232
                if (x == 0)
 
1233
                        break;
 
1234
                else {
 
1235
                        free(loader);
 
1236
                        loader = NULL;
 
1237
                }
 
1238
                token = strtok(NULL, ":");
 
1239
        }
 
1240
        token = NULL;
 
1241
        free(path);
 
1242
 
1231
1243
        modeswitch_log("Module loader is %s\n", loader);
1232
1244
 
1233
1245
        asprintf(&id_file, "%s/new_id", config.driver_id_path);
1311
1323
                }
1312
1324
        }
1313
1325
 
 
1326
        free (loader);
 
1327
 
1314
1328
        return;
1315
1329
}
1316
1330