title: Find file descriptor of directory associated with filename
body: <p>I am trying to write a function that allows users to change file timestamps with nanosecond precision. After some <a href="https://stackoverflow.com/questions/72905567/how-to-change-file-timestamp-including-nanoseconds">research</a>, I found the function <a href="https://man7.org/linux/man-pages/man2/utimensat.2.html" rel="nofollow noreferrer">utimensat()</a> which allows me to do this. However the problem is that the function takes an argument <code>int dirfd</code> which is a file descriptor of the directory the file resides in.</p>
  <p>Using a filename would it be possible to somehow find the file descriptor of the directory a file is in?</p>
  <p>For example if a file <code>test.txt</code> is located in <code>/home/user/files/test.txt</code>, how could I get the file descriptor of the directory <code>test.txt</code> is in? aka the <code>files</code> directory.</p>