--- /dev/null
+#ifndef UAE_STRING_H
+#define UAE_STRING_H
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+#include "uae/types.h"
+#include <string.h>
+
+#ifdef _WIN32
+/* Make sure the real _tcs* functions are already declared before we
+ * re-define them below. */
+#include <tchar.h>
+#include <wchar.h>
+#include <stdlib.h>
+#endif
+
+#ifdef _WIN32
+/* Using the real _tcs* functions */
+#else
+#define _istdigit isdigit
+#define _istspace isspace
+#define _istupper isupper
+#define _sntprintf snprintf
+#define _stprintf sprintf
+#define _strtoui64 strtoll
+#define _tcscat strcat
+#define _tcschr strchr
+#define _tcscmp strcmp
+#define _tcscpy strcpy
+#define _tcscspn strcspn
+#define _tcsdup strdup
+#define _tcsftime strftime
+#define _tcsftime strftime
+#define _tcsicmp strcasecmp
+#define _tcslen strlen
+#define _tcsncat strncat
+#define _tcsncmp strncmp
+#define _tcsncpy strncpy
+#define _tcsnicmp strncasecmp
+#define _tcsrchr strrchr
+#define _tcsspn strspn
+#define _tcsstr strstr
+#define _tcstod strtod
+#define _tcstok strtok
+#define _tcstol strtol
+#define _totlower tolower
+#define _totupper toupper
+#define _tprintf printf
+#define _tstof atof
+#define _tstoi64 atoll
+#define _tstoi atoi
+#define _tstol atol
+#define _vsnprintf vsnprintf
+#define _vsntprintf vsnprintf
+#endif
+
+static inline size_t uae_tcslcpy(TCHAR *dst, const TCHAR *src, size_t size)
+{
+ if (size == 0) {
+ return 0;
+ }
+ size_t src_len = _tcslen(src);
+ size_t cpy_len = src_len;
+ if (cpy_len >= size) {
+ cpy_len = size - 1;
+ }
+ memcpy(dst, src, cpy_len * sizeof(TCHAR));
+ dst[cpy_len] = _T('\0');
+ return src_len;
+}
+
+static inline size_t uae_strlcpy(char *dst, const char *src, size_t size)
+{
+ if (size == 0) {
+ return 0;
+ }
+ size_t src_len = strlen(src);
+ size_t cpy_len = src_len;
+ if (cpy_len >= size) {
+ cpy_len = size - 1;
+ }
+ memcpy(dst, src, cpy_len);
+ dst[cpy_len] = '\0';
+ return src_len;
+}
+
+#endif /* UAE_STRING_H */
-
/*
-* UAE - The Un*x Amiga Emulator
-*
-* Linux isofs/UAE filesystem wrapper
-*
-* Copyright 2012 Toni Wilen
-*
-*/
+ * UAE - The Un*x Amiga Emulator
+ *
+ * Linux isofs/UAE filesystem wrapper
+ *
+ * Copyright 2012 Toni Wilen
+ *
+ */
#include "sysconfig.h"
#include "sysdeps.h"
#include "options.h"
#include "blkdev.h"
#include "isofs_api.h"
+#include "uae/string.h"
#include "zfile.h"
#include "isofs.h"
#define HASH_SIZE 65536
#define CD_BLOCK_SIZE 2048
-#define ISOFS_INVALID_MODE -1
+#define ISOFS_INVALID_MODE ((isofs_mode_t) -1)
#define ISOFS_I(x) (&x->ei)
#define ISOFS_SB(x) (&x->ei)
{
struct inode *next;
uae_u32 i_mode;
- uid_t i_uid;
- gid_t i_gid;
+ isofs_uid_t i_uid;
+ isofs_gid_t i_gid;
uae_u32 i_ino;
uae_u32 i_size;
uae_u32 i_blocks;
static void iput(struct inode *inode)
{
- struct super_block *sb = inode->i_sb;
-
if (!inode || inode->linked)
return;
+
+ struct super_block *sb = inode->i_sb;
+
#if 0
struct inode *in;
while (inode->i_sb->inode_cnt > MAX_CACHE_INODE_COUNT) {
return -ENOMEM;
out_noread:
- write_log (_T("ISOFS: unable to read i-node block %u\n"), block);
+ write_log (_T("ISOFS: unable to read i-node block %lu\n"), block);
xfree(tmpde);
return -EIO;
ret = isofs_read_level3_size(inode);
if (ret < 0)
goto fail;
+ // FIXME: this value is never used (?), because it is overwritten
+ // with ret = 0 further down.
ret = -EIO;
} else {
ei->i_next_section_block = 0;
/*
* return length of name field; 0: not found, -1: to be ignored
*/
-int get_rock_ridge_filename(struct iso_directory_record *de,
+static int get_rock_ridge_filename(struct iso_directory_record *de,
char *retname, struct inode *inode)
{
struct rock_state rs;
first_data_zone = isonum_733(rootp->extent) + isonum_711(rootp->ext_attr_length);
sbi->s_firstdatazone = first_data_zone;
- write_log (_T("ISOFS: Max size:%d Log zone size:%d\n"), sbi->s_max_size, 1UL << sbi->s_log_zone_size);
- write_log (_T("ISOFS: First datazone:%d\n"), sbi->s_firstdatazone);
+ write_log (_T("ISOFS: Max size:%ld Log zone size:%ld\n"), sbi->s_max_size, 1UL << sbi->s_log_zone_size);
+ write_log (_T("ISOFS: First datazone:%ld\n"), sbi->s_firstdatazone);
if(sbi->s_high_sierra)
write_log(_T("ISOFS: Disc in High Sierra format.\n"));
ch = getname(pri->system_id, 4);
write_log (_T("ISOFS: bread failed, dev=%d, iso_blknum=%d, block=%d\n"), s->unitnum, iso_blknum, block);
goto out_freebh;
out_bad_zone_size:
- write_log(_T("ISOFS: Bad logical zone size %d\n"), sbi->s_log_zone_size);
+ write_log(_T("ISOFS: Bad logical zone size %ld\n"), sbi->s_log_zone_size);
goto out_freebh;
out_bad_size:
write_log (_T("ISOFS: Logical zone size(%d) < hardware blocksize(%u)\n"), orig_zonesize, opt.blocksize);
dpnt = de->name;
/* Basic sanity check, whether name doesn't exceed dir entry */
if (de_len < dlen + sizeof(struct iso_directory_record)) {
- write_log (_T("iso9660: Corrupted directory entry in block %u of inode %u\n"), block, dir->i_ino);
+ write_log (_T("iso9660: Corrupted directory entry in block %lu of inode %u\n"), block, dir->i_ino);
return 0;
}
}
/* Acorn extensions written by Matthew Wilcox <willy@bofh.ai> 1998 */
-int get_acorn_filename(struct iso_directory_record *de, char *retname, struct inode *inode)
+static int get_acorn_filename(struct iso_directory_record *de, char *retname, struct inode *inode)
{
int std;
unsigned char *chr;
}
/* Basic sanity check, whether name doesn't exceed dir entry */
if (de_len < de->name_len[0] + sizeof(struct iso_directory_record)) {
- write_log (_T("iso9660: Corrupted directory entry in block %u of inode %u\n"), block, inode->i_ino);
+ write_log (_T("iso9660: Corrupted directory entry in block %lu of inode %u\n"), block, inode->i_ino);
return 0;
}
filp->f_pos += de_len;
if (len > 0) {
if (jname == NULL) {
- char t = p[len];
- p[len] = 0;
- au_copy (outname, 1000, p);
- p[len] = t;
+ if (p == NULL) {
+ write_log(_T("ISOFS: no name copied (p == NULL)\n"));
+ outname[0] = _T('\0');
+ }
+ else {
+ char t = p[len];
+ p[len] = 0;
+ au_copy (outname, MAX_DPATH, p);
+ p[len] = t;
+ }
} else {
- _tcscpy (outname, jname);
+ uae_tcslcpy (outname, jname, MAX_DPATH);
xfree (jname);
}
dinode = isofs_iget(inode->i_sb, bh_block, offset_saved, outname);
_stprintf (ii->devname, _T("CD%d"), sb->unitnum);
if (sys_command_info (sb->unitnum, &di, true)) {
totalblocks = di.cylinders * di.sectorspertrack * di.trackspercylinder;
- _tcscpy (ii->devname, di.label);
+ uae_tcslcpy (ii->devname, di.label, sizeof (ii->devname));
}
ii->unknown_media = sb->unknown_media;
if (sb->root) {
- _tcscpy (ii->volumename, sb->root->name);
+ uae_tcslcpy (ii->volumename, sb->root->name, sizeof(ii->volumename));
ii->blocks = sbi->s_max_size;
ii->totalblocks = totalblocks ? totalblocks : ii->blocks;
ii->creation = sb->root->i_ctime.tv_sec;
{
struct super_block *sb;
struct inode *inode;
- uae_u64 seek;
+ uae_s64 seek;
};
struct cd_openfile_s *isofs_openfile(void *sbp, uae_u64 uniq, int flags)