From 7a68bb3ea01d6962b8247888e6c2a6f1ff03cc74 Mon Sep 17 00:00:00 2001 From: Yura Pakhuchiy Date: Sun, 10 Jun 2007 14:28:56 +0300 Subject: [PATCH] Endian fixes for gnome-vfs module. Thanks to Anton for tip. --- include/ntfs/gnome-vfs-module.h | 2 +- libntfs/gnome-vfs-method.c | 12 +++++++----- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/include/ntfs/gnome-vfs-module.h b/include/ntfs/gnome-vfs-module.h index bd27f713..31671044 100644 --- a/include/ntfs/gnome-vfs-module.h +++ b/include/ntfs/gnome-vfs-module.h @@ -32,7 +32,7 @@ G_BEGIN_DECLS G_LOCK_EXTERN(libntfs); -#define libntfs_newn(objp, n) ((objp) = g_new(typeof(*(objp)), (n))) +#define libntfs_newn(objp, n) ((objp) = (typeof(objp))g_new(typeof(*(objp)), (n))) #define libntfs_new(objp) (libntfs_newn((objp), 1)) #define LIBNTFS_MEMZERO(objp) (memset((objp), 0, sizeof(*(objp)))) diff --git a/libntfs/gnome-vfs-method.c b/libntfs/gnome-vfs-method.c index 523fa3d9..723a3723 100644 --- a/libntfs/gnome-vfs-method.c +++ b/libntfs/gnome-vfs-method.c @@ -214,7 +214,7 @@ static GnomeVFSResult inode_open_by_pathname(ntfs_inode **inode_return, *pathname_next != G_DIR_SEPARATOR; pathname_next++) ; if (*pathname_next) { /* terminate current path element */ - *pathname_next++ = '\0'; + *pathname_next++ = 0; } while (*pathname_next == G_DIR_SEPARATOR) pathname_next++; @@ -224,7 +224,8 @@ static GnomeVFSResult inode_open_by_pathname(ntfs_inode **inode_return, libntfs_newn(pathname_parse_ucs2, strlen(pathname_parse_unescaped) + 1); for (i = 0; pathname_parse_unescaped[i]; i++) - pathname_parse_ucs2[i] = pathname_parse_unescaped[i]; + pathname_parse_ucs2[i] = cpu_to_le16( + pathname_parse_unescaped[i]); pathname_parse_ucs2[i] = 0; g_free(pathname_parse_unescaped); G_LOCK(libntfs); @@ -326,7 +327,8 @@ static gchar *libntfs_ntfscharo_utf8(const ntfschar *name, const int name_len) gstring = g_string_sized_new(name_len); for (i = 0; i < name_len; i++) - gstring = g_string_append_unichar(gstring, name[i]); + gstring = g_string_append_unichar(gstring, + le16_to_cpu(name[i])); return g_string_free(gstring, /* returns utf8-formatted string */ FALSE); /* free_segment */ } @@ -347,8 +349,8 @@ static int libntfs_gnomevfs_read_directory_filldir( g_return_val_if_fail(name_len >= 0, -1); g_return_val_if_fail(pos >= 0, -1); - /* system directory; FIXME: What is its proper identification? */ - if (name_len > 0 && name[0] == '$') + /* system directory */ + if (MREF(mref) != FILE_root && MREF(mref) < FILE_first_user) return 0; /* continue traversal */ file_info = gnome_vfs_file_info_new();