Replaced all occurrences of ntfs_mbstoucs with a compatibility wrapper function (ntfs_mbstoucs_libntfscompat).
The interface and semantics of ntfs_mbstoucs differ between libntfs and libntfs-3g, so this compatibility wrapper tries to address the differences.edge.strict_endians
parent
f03d683fa0
commit
b538215ddb
|
@ -2072,7 +2072,7 @@ static int add_attr_file_name(MFT_RECORD *m, const MFT_REF parent_dir,
|
|||
}
|
||||
fn->file_name_type = file_name_type;
|
||||
uname = fn->file_name;
|
||||
i = ntfs_mbstoucs(file_name, &uname, i);
|
||||
i = ntfs_mbstoucs_libntfscompat(file_name, &uname, i);
|
||||
if (i < 1) {
|
||||
free(fn);
|
||||
return -EINVAL;
|
||||
|
@ -2198,7 +2198,7 @@ static int add_attr_vol_name(MFT_RECORD *m, const char *vol_name,
|
|||
int i;
|
||||
|
||||
if (vol_name) {
|
||||
uname_len = ntfs_mbstoucs(vol_name, &uname, 0);
|
||||
uname_len = ntfs_mbstoucs_libntfscompat(vol_name, &uname, 0);
|
||||
if (uname_len < 0)
|
||||
return -errno;
|
||||
if (uname_len > 0xff) {
|
||||
|
@ -3149,7 +3149,7 @@ static int create_hardlink_res(MFT_RECORD *m_parent, const MFT_REF ref_parent,
|
|||
}
|
||||
fn->file_name_type = file_name_type;
|
||||
uname = fn->file_name;
|
||||
i = ntfs_mbstoucs(file_name, &uname, i);
|
||||
i = ntfs_mbstoucs_libntfscompat(file_name, &uname, i);
|
||||
if (i < 1) {
|
||||
free(fn);
|
||||
return -EINVAL;
|
||||
|
@ -3261,7 +3261,7 @@ static int create_hardlink(INDEX_BLOCK *idx, const MFT_REF ref_parent,
|
|||
}
|
||||
fn->file_name_type = file_name_type;
|
||||
uname = fn->file_name;
|
||||
i = ntfs_mbstoucs(file_name, &uname, i);
|
||||
i = ntfs_mbstoucs_libntfscompat(file_name, &uname, i);
|
||||
if (i < 1) {
|
||||
free(fn);
|
||||
return -EINVAL;
|
||||
|
|
|
@ -46,6 +46,7 @@
|
|||
|
||||
#include "ntfscat.h"
|
||||
/* #include "version.h" */
|
||||
#include "utils.h"
|
||||
|
||||
static const char *EXEC_NAME = "ntfscat";
|
||||
static struct options opts;
|
||||
|
@ -229,7 +230,7 @@ static int parse_options(int argc, char **argv)
|
|||
break;
|
||||
|
||||
case 'n':
|
||||
opts.attr_name_len = ntfs_mbstoucs(optarg,
|
||||
opts.attr_name_len = ntfs_mbstoucs_libntfscompat(optarg,
|
||||
&opts.attr_name, 0);
|
||||
if (opts.attr_name_len < 0) {
|
||||
ntfs_log_perror("Invalid attribute name '%s'", optarg);
|
||||
|
|
|
@ -316,7 +316,7 @@ static int change_label(ntfs_volume *vol, unsigned long mnt_flags, char *label,
|
|||
goto err_out;
|
||||
}
|
||||
}
|
||||
label_len = ntfs_mbstoucs(label, &new_label, 0);
|
||||
label_len = ntfs_mbstoucs_libntfscompat(label, &new_label, 0);
|
||||
if (label_len == -1) {
|
||||
ntfs_log_perror("Unable to convert label string to Unicode");
|
||||
goto err_out;
|
||||
|
|
|
@ -105,4 +105,28 @@ static __inline__ const char *ntfs_libntfs_version(void) {
|
|||
return "ntfs-3g unknown version (TODO: find or create a way to extract ntfs-3g version from library)";
|
||||
}
|
||||
|
||||
/**
|
||||
* linux-ntfs's ntfs_mbstoucs has different semantics, so we emulate it with
|
||||
* ntfs-3g's.
|
||||
*/
|
||||
static __inline__ int ntfs_mbstoucs_libntfscompat(const char *ins,
|
||||
ntfschar **outs, int outs_len)
|
||||
{
|
||||
ntfschar *tmpstr;
|
||||
int tmpstr_len;
|
||||
|
||||
if(*outs != NULL) {
|
||||
tmpstr_len = ntfs_mbstoucs(ins, &tmpstr);
|
||||
if(tmpstr_len >= 0) {
|
||||
/* The extra character is the null terminator. */
|
||||
memcpy(*outs, ins,
|
||||
sizeof(ntfschar)*(MIN(outs_len, tmpstr_len)+1));
|
||||
free(tmpstr);
|
||||
}
|
||||
return tmpstr_len;
|
||||
}
|
||||
else
|
||||
return ntfs_mbstoucs(ins, outs);
|
||||
}
|
||||
|
||||
#endif /* _NTFS_UTILS_H_ */
|
||||
|
|
Loading…
Reference in New Issue