Initial original import from: fuse-2.4.2-2.fc4
[captive.git] / src / libcaptive / storage / cdrom.c
1 /* $Id$
2  * "\Device\CdRom%d" storage emulation driver for reactos of libcaptive
3  * Copyright (C) 2002 Jan Kratochvil <project-captive@jankratochvil.net>
4  * 
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; exactly version 2 of June 1991 is required
8  * 
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  * 
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
17  */
18
19
20 #include "config.h"
21
22 #include "captive/storage.h"    /* self */
23 #include "media.h"
24 #include <glib/gmessages.h>
25 #include "captive/unicode.h"
26 #include "reactos/ddk/status.h" /* for NT_SUCCESS() */
27 #include "captive/options.h"
28
29
30 /**
31  * captive_cdrom_init:
32  *
33  * Creates system device "\Device\CdRom%d" providing readonly access
34  * to the given #captive_image_iochannel as emulation of CD-ROM driver.
35  *
36  * libcaptive currently supports just one drive and thus "\Device\CdRom0"
37  * is always created. It is forbidden to call this function twice.
38  *
39  * Returns: %TRUE if the initialization was successful.
40  */
41 gboolean captive_cdrom_init(void)
42 {
43 static struct captive_DriverObject cdrom_captive_DriverObject;
44 NTSTATUS err;
45
46         g_return_val_if_fail(captive_image_iochannel!=NULL,FALSE);
47
48         cdrom_captive_DriverObject.DiskGeometry.BytesPerSector=2048;
49         cdrom_captive_DriverObject.DiskGeometry.MediaType=RemovableMedia;
50         cdrom_captive_DriverObject.DeviceName_utf8="\\Device\\CdRom0";
51         cdrom_captive_DriverObject.DeviceType=FILE_DEVICE_CD_ROM;
52         cdrom_captive_DriverObject.DeviceCharacteristics=FILE_REMOVABLE_MEDIA|FILE_READ_ONLY_DEVICE;
53         err=captive_media_DriverEntry(
54                         &cdrom_captive_DriverObject,    /* DriverEntry_DriverObject */
55                         captive_utf8_to_UnicodeString_alloca("\\captive\\storage\\cdrom"));     /* DriverEntry_RegistryPath; ignored */
56         g_return_val_if_fail(NT_SUCCESS(err),FALSE);
57
58         return TRUE;
59 }