aboutsummaryrefslogtreecommitdiffstats
path: root/sysutils/eject/files/patch-eject.c
blob: 18990fe3a9e4f2356f6c8624a9ffc70d565a3ccd (plain) (blame)
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
--- eject.c.orig    Tue Jul 19 13:43:37 2005
+++ eject.c Tue Jul 19 14:14:24 2005
@@ -122,7 +122,7 @@
 }
 
 /*
- *  check device is exists.
+ *  check whether device exists.
  */
 
 int
@@ -133,8 +133,14 @@
     int sts;
     struct stat sb;
 
-    if (asprintf(device, "/dev/%sc", name) == -1)
-   return sts;
+    if (strncmp("/dev/", name, strlen("/dev/")) == 0) {
+       if (asprintf(device, "%s", name) == -1)
+       return sts;
+    }
+    else { 
+       if (asprintf(device, "/dev/%s", name) == -1)
+       return sts;
+    }
     if (vflag || nflag) {
    printf("%s: using device %s\n", program, device);
     }
@@ -174,11 +180,16 @@
     /* get proper mount information into the list */
     len = strlen(name);
     for (n = 0; n < mnts; n++) {
-   p = rindex(mntbuf[n].f_mntfromname, '/');
-   if (p == NULL) {
-       continue;
+   if (strncmp("/dev/", name, strlen("/dev/")) == 0) 
+       p = mntbuf[n].f_mntfromname;
+   else {
+       p = rindex(mntbuf[n].f_mntfromname, '/');
+       if (p == NULL)
+           continue;
+       ++p;
    }
-   for (i = 0, ++p, q = name; *p != '\0' && *q != '\0'; ++i, ++p, ++q) {
+
+   for (i = 0, p, q = name; *p != '\0' && *q != '\0'; ++i, ++p, ++q) {
        if (*p != *q) {
        break;
        }