2 iso9660 - An iso9660 CDI driver with Rockridge support
3 Copyright (C) 2008 Janosch Gräf <janosch.graef@gmx.net>
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as published by
7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
22 #include "cdi/cache.h"
24 #include "iso9660_cdi.h"
26 #include "volume_descriptor.h"
29 * Initializes a ISO9660 filesystem
30 * @param fs Filesystem to initialize
31 * @return If initialization was successful
33 int iso9660_fs_init(struct cdi_fs_filesystem
*fs
) {
34 debug("iso9660_fs_init(0x%x)\n",fs
);
35 struct iso9660_voldesc_prim
*voldesc
= malloc(sizeof(struct iso9660_voldesc_prim
));
36 if (iso9660_voldesc_load(fs
,ISO9660_VOLDESC_PRIM
,voldesc
)!=-1) {
37 struct iso9660_fs_res
*root_res
= iso9660_dirrec_load(&voldesc
->root_dir
,NULL
,voldesc
);
38 root_res
->cache
= cdi_cache_create(voldesc
->sector_size
,0,iso9660_sector_read_cache
,NULL
,fs
);
39 fs
->root_res
= (struct cdi_fs_res
*)root_res
;
47 * @param fs Filesystem to destroy
48 * @return If destroy was successful
50 int iso9660_fs_destroy(struct cdi_fs_filesystem
*fs
) {
51 fprintf(stderr
,"iso9660_fs_destroy(0x%x)\n",fs
);
52 struct iso9660_fs_res
*root_res
= (struct iso9660_fs_res
*)(fs
->root_res
);
53 free(root_res
->voldesc
);
54 cdi_cache_destroy(root_res
->cache
);
55 return iso9660_fs_res_destroy(root_res
);