Path: utzoo!attcan!uunet!cs.utexas.edu!sun-barr!newstop!sun!pepper!cmcmanis From: cmcmanis%pepper@Sun.COM (Chuck McManis) Newsgroups: comp.sys.amiga.tech Subject: Re: Anybody know how to do this stuff? Message-ID: <129046@sun.Eng.Sun.COM> Date: 11 Dec 89 07:28:14 GMT References: <13920020@hpfelg.HP.COM> <13920027@hpfelg.HP.COM> Sender: news@sun.Eng.Sun.COM Reply-To: cmcmanis@sun.UUCP (Chuck McManis) Organization: Sun Microsystems, Mountain View Lines: 61 In article <13920027@hpfelg.HP.COM> koren@hpfelg.HP.COM (Steve Koren) writes: >Another "how do you do it" question: > >I want to find out, for any given device name, whether that is a currently >mounted file system device. Moreover, I want to do this without bringing >up the requester. In short, I need a routine like this: > > int IsMounted(char *Device_Name) {} The simple way : #include APTR OldWindow; ULONG l, mounted; struct Process *pr; OldWindow = pr->pr_WindowPtr; pr->pr_WindowPtr = -1; /* Turn off requesters */ l = Lock(Volume_Name, ACCESS_READ); /* Check for volume mounted */ mounted = (l != 0); if (mounted) UnLock(l); pr->pr_WindowPtr = OldWindow; return(mounted); >First of all, I would expect that there would be an easy way to do it; >ie, something like the above function call. If there is no programatic >interface to this, I will probably forget it until one appears. Does >anyone know? I can't find it documented anyplace, but it seems like a >logical thing to have. The above code will do what you want, however ... >I tried to write such a function using ARP's AddDADevs() call, but I had >problems with that. They have a flag called DLX_UNMOUNTED which you can >examine, but it is only valid for "volume" names, not device (like df0:) >or "dir names" (like c:). It tells me that df0: is always mounted, even if >it contains no disk, and it tells me that c: is never mounted, even though >it is assigned someplace. In short, it doesn't do me any good. You don't seem to grok what Volume's are. They are basic unit of Disk, not the device like df0:. If I have a volume on a floppy, I don't care what disk drive it is in. DF0: is a device which is either present or not present. That and the geometry of the disks it will read aree the only interesting tidbits about it. You can figure out if a volume is currently inserted into DF0: but generally this is useless info. Assigns, like C:, are something else entirely. Their function is to name a file or directory unambiguously. They provide a "universal" name for different directories. The information provided within the assignment includes the volume that they point are actually on so it is fairly trivial to check to see if they are available. But again, they are never "mounted", they simply exist to say "If you need this named group of files, this context independent name will point to them." Is that any clearer? --Chuck McManis uucp: {anywhere}!sun!cmcmanis BIX: cmcmanis ARPAnet: cmcmanis@Eng.Sun.COM These opinions are my own and no one elses, but you knew that didn't you. "If it didn't have bones in it, it wouldn't be crunchy now would it?!"