🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.unix.programmer
Article #360

Re: How to determine device major number?

#360
From: Graham Wheeler
Date: Thu, 06 Aug 1992 13:17
15 lines
999 bytes
>sk@hpcupt3.cup.hp.com (S Kandasamy) writes:

>>Use stat(2) system call. The field st_rdev in the stat structure contains
>>both the major number and minor number.

With a little experimentation, I found the following encoding on SVR4:

minor_dev_num = s.st_rdev & 0xFF;
major_dev_num = s.st_rdev>>18;

-- 
Graham Wheeler                     | "That which is weak conquers the strong,
Software Systems Engineer/Student  | that which is soft conquers the hard."
Aztec Information Management/UCT   | 		Lao Tzu - Tao Te Ching Ch. 78
gram@aim1.aztec.co.za / gram@cs.uct.ac.za 
Technical Details
Message-ID: <gram.713107027@aim1>
Path: arc1-ca.pugleaf.net!sparky!uunet!psgrain!ee.und.ac.za!ucthpx!aim1!aim1!gram
References: <gram.712833707@aim1> <118380001@hpcupt3.cup.hp.com> <gram.713093200@aim1>

Show Full Headers
Complete Article Headers
Newsgroups: comp.unix.programmer
Path: arc1-ca.pugleaf.net!sparky!uunet!psgrain!ee.und.ac.za!ucthpx!aim1!aim1!gram
From: gram@aim1.aztec.co.za (Graham Wheeler)
Subject: Re: How to determine device major number?
Message-ID: <gram.713107027@aim1>
Organization: Aztec Information Management
References: <gram.712833707@aim1> <118380001@hpcupt3.cup.hp.com> <gram.713093200@aim1>
Date: Thu, 6 Aug 1992 13:17:07 GMT
Lines: 15