LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Hardware (https://www.linuxquestions.org/questions/linux-hardware-18/)
-   -   Making a folder look like a device? (https://www.linuxquestions.org/questions/linux-hardware-18/making-a-folder-look-like-a-device-318050/)

username-inuse 04-28-2005 08:36 AM

Making a folder look like a device?
 
Hey everyone!
I have a .iso image that I mounted as /mnt/cdrom/ . I would like to make it look like a REAL device. (i.e have a file in /dev/) I need this for a little project im working on.

I have researched :study: and googled the topic. I hope I dont appear like a :newbie: !

The command I used to mount the .ISO was...

Code:

mount -r ./Toppas.iso /mnt/cdaudio -t iso9660 -o loop
df returns...

Code:

Filesystem          1K-blocks      Used Available Use% Mounted on
/dev/hda2              9092176  7103648  1526660  83% /
/dev/root.old            16155      7864      8291  49% /initrd
/home/Modzilla/Toppas.iso
                        632516    632516        0 100% /mnt/cdaudio

If you dont understand what im trying to say, I would like to make a "virtual" cd drive.

Thanks in advance!

-Hopeless :newbie:

acid_kewpie 04-28-2005 08:40 AM

using a loopback mount like you have makes it avaiable... as you know... you've already achieved what you're asking for... what else do you expect to be able to do? it's not a device, therefore has no place in /dev/

username-inuse 04-28-2005 08:45 AM

Quote:

Originally posted by acid_kewpie
using a loopback mount like you have makes it avaiable... as you know... you've already achieved what you're asking for... what else do you expect to be able to do? it's not a device, therefore has no place in /dev/
I would like a program to see it as a CD. So it can read-write to it. Im sorry if I made it unclear... (Therefore have a entry in the /dev/folder)

rpz 04-28-2005 09:30 AM

/dev/loopX maybe?

username-inuse 04-28-2005 09:40 AM

Quote:

Originally posted by rpz
/dev/loopX maybe?
What about /dev/loopX??

**EDIT**

Also this program only takes /dev/cdaudio /dev/cdrom /dev/dvd/ and so on.

The reason for me doing this is becuase I am studying CD file systems, how linux utilizes them.

Id like to get it working, even if its just for five minutes like.

acid_kewpie 04-28-2005 02:17 PM

a system will see it as a device... you can't yet do dynamic disk writing to UDF filesystems if that's what you're getting at...

rpz 04-28-2005 02:50 PM

Quote:

Originally posted by username-inuse
[B]What about /dev/loopX??
For example, have you tried using /dev/loop0 (assuming it's the first loop device), instead of /dev/dvd?

username-inuse 04-28-2005 03:23 PM

Quote:

Originally posted by rpz
For example, have you tried using /dev/loop0 (assuming it's the first loop device), instead of /dev/dvd?
Oh, Ill have a go and post my results in a moment.

acid_kewpie 04-28-2005 04:47 PM

/dev/loop won't retain any direct association or knowledge about the pretend cdrom device... i really don't see what you're trying to achieve... you can't write direct to cdrw drives anyway (without some middleware which makes it indirect...)

username-inuse 04-30-2005 07:37 AM

Quote:

Originally posted by acid_kewpie
/dev/loop won't retain any direct association or knowledge about the pretend cdrom device... i really don't see what you're trying to achieve... you can't write direct to cdrw drives anyway (without some middleware which makes it indirect...)
I dont want to write to it, I need to read from it.

Electro 04-30-2005 05:04 PM

You already did when you specify "mount -r ./Toppas.iso /mnt/cdaudio -t iso9660 -o loop". What it does behind the scenes. First it sets up a loop device that is not used yet using the losetup utility. Usually it will be /dev/loopX. The X could 0, 1, 2, 3, 4, etc. Next it mounts it to /mnt/cdaudio. If its a DVD image, you can use mplayer or any player. Though you will have to specify the video_ts to read from. Yes, you can write to it if it has unused space. Also you can make a disk image that contains partitions and filesystems. Then set it up as a loop device.

If you want to know more, look at the kernel source code. It will tell you everything, but a knowledge of C programming langauge is require.

username-inuse 05-01-2005 05:23 AM

Quote:

Originally posted by Electro
You already did when you specify "mount -r ./Toppas.iso /mnt/cdaudio -t iso9660 -o loop". What it does behind the scenes. First it sets up a loop device that is not used yet using the losetup utility. Usually it will be /dev/loopX. The X could 0, 1, 2, 3, 4, etc. Next it mounts it to /mnt/cdaudio. If its a DVD image, you can use mplayer or any player. Though you will have to specify the video_ts to read from. Yes, you can write to it if it has unused space. Also you can make a disk image that contains partitions and filesystems. Then set it up as a loop device.

If you want to know more, look at the kernel source code. It will tell you everything, but a knowledge of C programming langauge is require.

I understand! I need it to appear as the actuall device though. For example having the image linked to /dev/cdrom permanently. I type mount /dev/cdrom /mnt/cdrom and it will automatically appear as the device. The program tries to re-mount the selected devices which takes the above command's effects away.


All times are GMT -5. The time now is 10:17 PM.