Skip to content

Commit b738402

Browse files
committed
update: adding msvc support
1 parent d8c223b commit b738402

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+1210
-585
lines changed

src/Makefile.am

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ nobase_pkginclude_HEADERS = \
122122
libltfs/arch/arch_info.h \
123123
libltfs/arch/time_internal.h \
124124
libltfs/arch/errormap.h \
125+
libltfs/arch/ltfs_arch_ops.h \
125126
tape_drivers/ibm_tape.h \
126127
tape_drivers/spc_op_codes.h \
127128
tape_drivers/ssc_op_codes.h \

src/iosched/unified.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1742,7 +1742,7 @@ ssize_t _unified_insert_new_request(const char *buf, off_t offset, size_t count,
17421742
{
17431743
int ret;
17441744
struct dentry_priv *dpr = d->iosched_priv;
1745-
struct write_request *new_req;
1745+
struct write_request *new_req = NULL;
17461746
size_t copy_count;
17471747

17481748
if (! (*cache)) {
@@ -1764,7 +1764,7 @@ ssize_t _unified_insert_new_request(const char *buf, off_t offset, size_t count,
17641764
memcpy(cache_manager_get_object_data(*cache), buf, copy_count);
17651765

17661766
/* Store new write request */
1767-
new_req = calloc(1, sizeof(struct write_request));
1767+
new_req = (struct write_request*)calloc(1, sizeof(struct write_request));
17681768
if (! new_req) {
17691769
ltfsmsg(LTFS_ERR, 13018E);
17701770
_unified_cache_free(*cache, 0, priv);
@@ -2307,7 +2307,7 @@ int unified_set_profiler(char *work_dir, bool enable, void *iosched_handle)
23072307
{
23082308
int rc = 0;
23092309
char *path;
2310-
FILE *p;
2310+
FILE * p = NULL;
23112311
struct timer_info timerinfo;
23122312
struct unified_data *priv = iosched_handle;
23132313

@@ -2325,7 +2325,7 @@ int unified_set_profiler(char *work_dir, bool enable, void *iosched_handle)
23252325
return -LTFS_NO_MEMORY;
23262326
}
23272327

2328-
p = fopen(path, PROFILER_FILE_MODE);
2328+
arch_fopen(path, PROFILER_FILE_MODE,p);
23292329

23302330
free(path);
23312331

src/kmi/flatfile.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,12 @@
5151
#include <errno.h>
5252
#include "libltfs/kmi_ops.h"
5353
#include "libltfs/ltfs_fuse_version.h"
54-
#include <fuse.h>
55-
#include "key_format_ltfs.h"
5654

55+
#include "key_format_ltfs.h"
56+
#include <fuse.h>
5757
#ifdef mingw_PLATFORM
58-
#include "libltfs/arch/win/win_util.h"
58+
#include "arch/win/win_util.h"
59+
5960
#endif
6061

6162
struct kmi_flatfile_options_data {

src/kmi/key_format_ltfs.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
*/
4949

5050
#ifdef mingw_PLATFORM
51-
#include "libltfs/arch/win/win_util.h"
51+
#include "arch/win/win_util.h"
5252
#endif
5353
#include "libltfs/ltfs.h"
5454
#include "libltfs/base64.h"

src/kmi/simple.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,11 @@
4949

5050
#include "libltfs/kmi_ops.h"
5151
#include "libltfs/ltfs_fuse_version.h"
52-
#include <fuse.h>
5352
#include "key_format_ltfs.h"
54-
53+
#include <fuse.h>
5554
#ifdef mingw_PLATFORM
56-
#include "libltfs/arch/win/win_util.h"
55+
#include "arch/win/win_util.h"
56+
5757
#endif
5858

5959
struct kmi_simple_options_data {
@@ -193,20 +193,20 @@ int simple_parse_opts(void *opt_args)
193193
+ strlen((char *) key[i].dk) + strlen(":") + strlen((char *) key[i].dki) + 1;
194194

195195
if (priv.dk_list)
196-
priv.dk_list = realloc(priv.dk_list, dk_list_len);
196+
priv.dk_list = (unsigned char*)realloc(priv.dk_list, dk_list_len);
197197
else
198-
priv.dk_list = calloc(dk_list_len, sizeof(unsigned char));
198+
priv.dk_list = (unsigned char*)calloc(dk_list_len, sizeof(unsigned char));
199199
if (priv.dk_list == NULL) {
200200
ltfsmsg(LTFS_ERR, 10001E, __FUNCTION__);
201201
return -LTFS_NO_MEMORY;
202202
}
203203
*(priv.dk_list + original_dk_list_len) = '\0';
204204

205205
if (original_dk_list_len)
206-
strcat((char *) priv.dk_list, "/");
207-
strcat((char *) priv.dk_list, (char *) key[i].dk);
208-
strcat((char *) priv.dk_list, ":");
209-
strcat((char *) priv.dk_list, (char *) key[i].dki);
206+
arch_strcat((char *) priv.dk_list, dk_list_len, "/");
207+
arch_strcat((char *) priv.dk_list, dk_list_len,(char *) key[i].dk);
208+
arch_strcat((char *) priv.dk_list, dk_list_len, ":");
209+
arch_strcat((char *) priv.dk_list, dk_list_len,(char *) key[i].dki);
210210
}
211211

212212
return 0;

src/libltfs/arch/errormap.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
*/
4949

5050
#ifdef mingw_PLATFORM
51-
#include "libltfs/arch/win/win_util.h"
51+
#include "arch/win/win_util.h"
5252
#endif
5353

5454
#ifdef __FreeBSD__

src/libltfs/arch/filename_handling.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
bool _replace_invalid_chars(char * file_name, bool * dosdev);
5656
char * _generate_target_file_name(const char *prefix, const char *extension, int suffix, bool dosdev);
5757
int _utf8_strlen(const char *s);
58-
int _utf8_strncpy(char *t, const char *s, int n);
58+
int _utf8_strcpy(char *t, const char *s, int n);
5959
#endif
6060

6161
/**
@@ -73,11 +73,11 @@ void update_platform_safe_name(struct dentry* dentry, bool handle_invalid_char,
7373
char source_file_name[LTFS_FILENAME_MAX*4+1];
7474
char *source_file_name_prefix, *source_file_name_extension;
7575
char *target_file_name;
76-
struct dentry *d;
76+
struct dentry* d = NULL;
7777
int ret;
7878

7979
dentry->platform_safe_name = NULL;
80-
strcpy(source_file_name, dentry->name.name);
80+
arch_strcpy_auto(source_file_name, dentry->name.name);
8181

8282
if (_replace_invalid_chars(source_file_name, &dosdev)) {
8383
if (! handle_invalid_char)
@@ -130,7 +130,7 @@ void update_platform_safe_name(struct dentry* dentry, bool handle_invalid_char,
130130
}
131131
}
132132
#else
133-
dentry->platform_safe_name = strdup(dentry->name.name);
133+
dentry->platform_safe_name = arch_strdup(dentry->name.name);
134134
#endif
135135
}
136136

@@ -208,7 +208,7 @@ char * _generate_target_file_name(const char *prefix, const char *extension, int
208208
target = NULL;
209209

210210
if (suffix) {
211-
sprintf( suffix_string, "~%d", suffix );
211+
arch_sprintf_auto( suffix_string, "~%d", suffix );
212212

213213
prefix_length = prefix ? _utf8_strlen(prefix) : 0;
214214
extension_length = extension ? _utf8_strlen(extension) : 0;
@@ -218,15 +218,15 @@ char * _generate_target_file_name(const char *prefix, const char *extension, int
218218
/* Need to trim source file name to add suffix */
219219
if (! dosdev && prefix_length > suffix_length) {
220220
/* Prefix is to be trimmed. */
221-
_utf8_strncpy(trimmed_name, prefix, prefix_length - suffix_length);
221+
_utf8_strcpy(trimmed_name, prefix, prefix_length - suffix_length);
222222
if (extension)
223223
ret = asprintf(&target, "%s%s.%s", trimmed_name, suffix_string, extension);
224224
else
225225
ret = asprintf(&target, "%s%s", trimmed_name, suffix_string);
226226

227227
} else if (extension_length > suffix_length) {
228228
/* Extension is to be trimmed. */
229-
_utf8_strncpy(trimmed_name, extension, extension_length - suffix_length);
229+
_utf8_strcpy(trimmed_name, extension, extension_length - suffix_length);
230230
ret = asprintf(&target, "%s%s.%s", prefix, suffix_string, trimmed_name);
231231
} else {
232232
/* Unable to generate target file name. NULL is to be returned. */
@@ -241,7 +241,7 @@ char * _generate_target_file_name(const char *prefix, const char *extension, int
241241
if (extension)
242242
ret = asprintf(&target, "%s.%s", prefix, extension);
243243
else {
244-
target = strdup(prefix);
244+
target = arch_strdup(prefix);
245245
ret = target ? strlen(target) : -1;
246246
}
247247
}
@@ -273,7 +273,7 @@ int _utf8_strlen(const char *s)
273273
* @param s Source string to be copied.
274274
* @param n Maximum length to be copied.
275275
*/
276-
int _utf8_strncpy(char *t, const char *s, int n)
276+
int _utf8_strcpy(char *t, const char *s, int n)
277277
{
278278
int ret = 0;
279279

0 commit comments

Comments
 (0)