|
Home > Archive > Unix Programming > February 2007 > Determining if a device is mounted - and is CDROM
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Determining if a device is mounted - and is CDROM
|
|
| arindam.mukerjee@gmail.com 2007-02-12, 7:29 pm |
| I am writing an installer application using C++, on Solaris and it
involves changing CDs to complete an installation. Now, while the
standard use case is of installation from a set of CDs, it is also
possible that instead of CDs, the source of the files might be an NFS
mounted drive. I need to find out a way to determine if the source
directory is on a CDROM device, or on an NFS mounted drive. Next, if
it is on a CDROM device, I want to eject it. For this, I guess I could
either use system("eject ..."); or some ioctl call on the particular
CDROM device file descriptor. But I am quite unclear in my mind as to
how this problem can be generally solved. Any pointers would be of
great help.
Cheers,
Arindam
| |
| Logan Shaw 2007-02-13, 1:30 am |
| arindam.mukerjee@gmail.com wrote:
> I am writing an installer application using C++, on Solaris and it
> involves changing CDs to complete an installation. Now, while the
> standard use case is of installation from a set of CDs, it is also
> possible that instead of CDs, the source of the files might be an NFS
> mounted drive.
.... or a local drive, or any filesystem really. You could place an
arbitrary restriction on it, but it doesn't make your programming
job any easier, and it just makes things harder for your users.
> I need to find out a way to determine if the source
> directory is on a CDROM device, or on an NFS mounted drive.
You might want to approach this differently. If it is on CD-ROM,
there is no need at all for the user to specify a source directory.
You can find it automatically. Simply give your CD-ROM a volume name
you can recognize, and the volume will show up as a directory under
/cdrom. For example, if you name the CD-ROM "arindam-disc1", then
the volume manager will automatically mount it at /cdrom/arindam-disc1
a short time after it is inserted. If you look for that path, you
will find it without having to ask the user to specify the path.
> Next, if
> it is on a CDROM device, I want to eject it.
If you have called the CD-ROM "arindam-disc1", then it would be
mounted under /cdrom/arindam-disc1, and what's more, you can
run "eject /cdrom/arindam-disc1" to eject it. (There is no need
to trace back and get the device name; the "eject" command handles
it for you.)
(You must make sure you close every open file on the CD-ROM first,
but that is another matter. And as long as I'm addressing side
issues, some Solaris users turn off the volume manager and then the
CD-ROM is not automatically mounted. For those users, you'll have
to let them manage the CD drive, since that is what they have
obviously decided they want!)
Now, if the installer is in some other location (not on removable
media but on a local filesystem or on NFS), then it's a different
story. In that case, you will need to ask the user to specify
the directory. But, you will not need to eject it, of course.
You have a little freedom in choosing how you want to write your
program. You could ask the user whether they want to install from
removable media (CD-ROM) or from a directory on a regular filesystem.
Or, you could be clever and poll for the CD-ROM in the background
and use it automatically if it is detected. Another possibility
is a mixture: ask the user what they want to do, but before
presenting the question, check for the presence of the CD-ROM
volume you need, and let the user know if it is recognized.
- Logan
| |
| Maxim Yegorushkin 2007-02-13, 7:23 am |
| On Feb 12, 8:34 pm, arindam.muker...@gmail.com wrote:
> I am writing an installer application using C++, on Solaris and it
> involves changing CDs to complete an installation. Now, while the
> standard use case is of installation from a set of CDs, it is also
> possible that instead of CDs, the source of the files might be an NFS
> mounted drive. I need to find out a way to determine if the source
> directory is on a CDROM device, or on an NFS mounted drive. Next, if
> it is on a CDROM device, I want to eject it. For this, I guess I could
> either use system("eject ..."); or some ioctl call on the particular
> CDROM device file descriptor. But I am quite unclear in my mind as to
> how this problem can be generally solved. Any pointers would be of
> great help.
I would look at anaconda sources for inspiration. http://
en.wikipedia.org/wiki/Anaconda_installer
|
|
|
|
|