How to get device name on which a file is located from its path in c?
<p>Let's say I have a file in Linux with this path:</p>
<pre><code>/path/to/file/test.mp3
</code></pre>
<p>I want to know the path to its device. For example I want to get something like:</p>
<pre><code>/dev/sdb1
</code></pre>
<p>How do I do this with the <em><strong>C programming language</strong></em>?</p>
<p>I know the terminal command to do it, but I need C functions that will do the job.</p>
<p><em><strong>EDIT:</strong></em>
I have read <a href="https://stackoverflow.com/questions/13403866/how-to-get-a-device-partition-name-of-a-file">this</a> question before asking mine. It doesn't concretly mention code in C, it's more related to bash than to the C language.</p>
<p>Thanks.</p>