diff options
| author | Xavier Del Campo Romero <xavi92@disroot.org> | 2025-07-07 13:22:53 +0200 |
|---|---|---|
| committer | Xavier Del Campo Romero <xavi92@disroot.org> | 2025-11-11 00:08:15 +0100 |
| commit | 7861a52adf92a083bb2aed4c35f98d8035dce032 (patch) | |
| tree | 28cd3c40e4c878f730f5df3c1d93bdf91af490c3 /src/fs/iso9660/private_include | |
| parent | 7fc48e9216ff809da5f8055a50b0be17628ef1df (diff) | |
| download | wnix-7861a52adf92a083bb2aed4c35f98d8035dce032.tar.gz | |
Setup project skeleton
Diffstat (limited to 'src/fs/iso9660/private_include')
| -rw-r--r-- | src/fs/iso9660/private_include/iso9660/ops.h | 39 | ||||
| -rw-r--r-- | src/fs/iso9660/private_include/iso9660/routines.h | 35 | ||||
| -rw-r--r-- | src/fs/iso9660/private_include/iso9660/types.h | 148 |
3 files changed, 222 insertions, 0 deletions
diff --git a/src/fs/iso9660/private_include/iso9660/ops.h b/src/fs/iso9660/private_include/iso9660/ops.h new file mode 100644 index 0000000..b85d025 --- /dev/null +++ b/src/fs/iso9660/private_include/iso9660/ops.h @@ -0,0 +1,39 @@ +/* + * wnix, a Unix-like operating system for WebAssembly applications. + * Copyright (C) 2025 Xavier Del Campo Romero + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + */ + +#ifndef ISO9660_OPS_H +#define ISO9660_OPS_H + +#include <fs/fs.h> +#include <fs/inode.h> + +int iso9660_mount(const struct fs_mount *m, struct fs_ret *r); +int iso9660_mkdir(const struct fs_mkdir *m, const struct fs_mp *mp, + const union inode_result *i, struct fs_ret *r); +int iso9660_open(const struct fs_open *o, const struct fs_mp *mp, + const union inode_result *i, struct fs_ret *r); +int iso9660_read(const struct fs_read *r, struct fs_ret *ret); +int iso9660_write(const struct fs_write *w, struct fs_ret *r); +int iso9660_stat(const struct fs_stat *s, const struct fs_mp *mp, + const union inode_result *inode, struct fs_ret *r); +int iso9660_close(struct fs_fd *fd); +int iso9660_eof(const struct fs_fd *fd); +int iso9660_search(const char *path, const struct fs_mp *prv, + union inode_result *inode, struct fs_ret *r); + +#endif diff --git a/src/fs/iso9660/private_include/iso9660/routines.h b/src/fs/iso9660/private_include/iso9660/routines.h new file mode 100644 index 0000000..467cce2 --- /dev/null +++ b/src/fs/iso9660/private_include/iso9660/routines.h @@ -0,0 +1,35 @@ +/* + * wnix, a Unix-like operating system for WebAssembly applications. + * Copyright (C) 2025 Xavier Del Campo Romero + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + */ + +#ifndef ISO9660_ROUTINES_H +#define ISO9660_ROUTINES_H + +#include <iso9660/types.h> +#include <stddef.h> +#include <stdint.h> +#include <time.h> + +int iso9660_check_header(const struct iso9660_magic *m); +uint16_t iso9660_lmsb16(const struct iso9660_lmsb16 *p); +uint32_t iso9660_lmsb32(const struct iso9660_lmsb32 *p); +int iso9660_totm(const struct iso9660_dt *dt, struct tm *tm); +int iso9660_totimespec(const struct iso9660_dt *dt, struct timespec *ts); +int iso9660_etotimespec(const struct iso9660_entry_dt *dt, struct timespec *ts); +struct tm iso9660_gmtime(const struct iso9660_entry_dt *dt); + +#endif diff --git a/src/fs/iso9660/private_include/iso9660/types.h b/src/fs/iso9660/private_include/iso9660/types.h new file mode 100644 index 0000000..55544fb --- /dev/null +++ b/src/fs/iso9660/private_include/iso9660/types.h @@ -0,0 +1,148 @@ +/* + * wnix, a Unix-like operating system for WebAssembly applications. + * Copyright (C) 2025 Xavier Del Campo Romero + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + */ + +#ifndef ISO9660_TYPES_H +#define ISO9660_TYPES_H + +#include <fs/fs.h> +#include <fs/inode.h> +#include <stdint.h> + +#define ISO9660_LE ((const union {int a; char c;}){.a = 1}.c) + +struct fs_mp_prv +{ + int dummy; +}; + +enum +{ + ISO9660_TYPE_BOOT_RECORD, + ISO9660_TYPE_PRIMARY_VD, + ISO9660_TYPE_SUPPLEMENTARY_VD, + ISO9660_TYPE_VOLUME_PARTITION, + ISO9660_TYPE_TERMINATOR = 0xff, +}; + +struct inode_prv +{ + long offset; +}; + +struct iso9660_magic +{ + uint8_t id[sizeof "CD001" - 1]; +}; + +struct iso9660_header +{ + uint8_t type; + struct iso9660_magic magic; + uint8_t version; +}; + +struct iso9660_lmsb16 +{ + uint8_t le[sizeof (uint16_t)], be[sizeof (uint16_t)]; +}; + +struct iso9660_lmsb32 +{ + uint8_t le[sizeof (uint32_t)], be[sizeof (uint32_t)]; +}; + +struct iso9660_dt +{ + char year[sizeof "9999" - 1], + month[sizeof "12" - 1], + day[sizeof "31" - 1], + hour[sizeof "23" - 1], + min[sizeof "59" - 1], + sec[sizeof "59" - 1], + hsec[sizeof "99" - 1]; + int8_t zone; +}; + +struct iso9660_lsb32 +{ + uint8_t data[sizeof (uint32_t)]; +}; + +struct iso9660_msb32 +{ + uint8_t data[sizeof (uint32_t)]; +}; + +struct iso9660_entry_dt +{ + uint8_t year, month, day, hour, min, sec, offset; +}; + +enum +{ + ISO9660_FLAGS_HIDDEN = 1, + ISO9660_FLAGS_DIR = 1 << 1, + ISO9660_FLAGS_ASSOC = 1 << 2, + ISO9660_FLAGS_HAS_FORMAT = 1 << 3, + ISO9660_FLAGS_HAS_UID_GID = 1 << 4, + ISO9660_FLAGS_NOT_FINAL = 1 << 7 +}; + +struct iso9660_entry +{ + uint8_t len, attr; + struct iso9660_lmsb32 extent_loc, data_len; + struct iso9660_entry_dt dt; + uint8_t flags; + uint8_t funit_sz, interleave_sz; + struct iso9660_lmsb16 seq_num; + uint8_t id_len; +}; + +struct iso9660_pvd +{ + uint8_t :8, sysid[32], vid[32], unused[8]; + struct iso9660_lmsb32 space_size; + uint8_t unused_2[32]; + struct iso9660_lmsb16 set_size, seq_num, block_size; + struct iso9660_lmsb32 pathtable_size; + struct iso9660_lsb32 lpath_loc, optlpath_loc; + struct iso9660_msb32 mpath_loc, optmpath_loc; + struct iso9660_entry root_dir; + uint8_t padding, set_id[128], pub_id[128], dprep_id[128], app_id[128], + copyright_id[37], abstract_id[37], bibl_id[37]; + struct iso9660_dt creat, mod, exp, eff; + uint8_t fs_version, :8, reserved[512 + 653]; +}; + + +struct iso9660_vd +{ + struct iso9660_header header; + + union + { + struct iso9660_pvd pvd; + } u; +}; + +enum {ISO9660_SECTOR_SZ = 2048}; + +extern const struct fs iso9660; + +#endif |
