title: How to convert between a dev_t and major/minor device numbers?
body: <p>I'm trying to write a portable program that deals with ustar archives. For device files, these archives store the <em>major</em> and <em>minor device numbers.</em> However, the <code>struct stat</code> as laid out in POSIX only contains a single <code>st_rdev</code> member of type <code>dev_t</code> described with “Device ID (if file is character or block special).”</p>
  
  <p>How can I convert between a pair of major and minor device numbers and a single <code>st_rdev</code> member as returned by <code>stat()</code> in a portable manner?</p>