Scan the mount list returning the _last_ device found for MOUNT. NULL is returned if MOUNT not found. The result is malloced. */
| 1236 | /* Scan the mount list returning the _last_ device found for MOUNT. |
| 1237 | NULL is returned if MOUNT not found. The result is malloced. */ |
| 1238 | static char * |
| 1239 | last_device_for_mount (char const *mount) |
| 1240 | { |
| 1241 | struct mount_entry const *le = NULL; |
| 1242 | |
| 1243 | for (struct mount_entry const *me = mount_list; me; me = me->me_next) |
| 1244 | { |
| 1245 | if (streq (me->me_mountdir, mount)) |
| 1246 | le = me; |
| 1247 | } |
| 1248 | |
| 1249 | if (le) |
| 1250 | { |
| 1251 | char *devname = le->me_devname; |
| 1252 | char *canon_dev = canonicalize_file_name (devname); |
| 1253 | if (canon_dev && IS_ABSOLUTE_FILE_NAME (canon_dev)) |
| 1254 | return canon_dev; |
| 1255 | free (canon_dev); |
| 1256 | return xstrdup (le->me_devname); |
| 1257 | } |
| 1258 | else |
| 1259 | return NULL; |
| 1260 | } |
| 1261 | |
| 1262 | /* If DEVICE corresponds to a mount point, show its usage |
| 1263 | and return true. Otherwise, return false. */ |