For example, a sample `df` command output is 

```
Filesystem    MB blocks      Free %Used    Iused %Iused Mounted on
/dev/hd4         512.00    322.96   37%     4842     7% /
/dev/hd2        4096.00    717.96   83%    68173    29% /usr
/dev/hd9var     1024.00    670.96   35%     6385     4% /var
/dev/hd3        5120.00      0.39  100%      158    10% /tmp

```

Now if I specify something like `/tmp/dummy.txt` I should be able to get `/dev/hd3` or just `hd3`.

**EDIT** : Thanks torek for the answer. But probing the `/proc` would become very tedious. Can anyone suggest me some system calls which can do the same internally?