hrev44735 adds 2 changesets to branch 'master' old head: 12a7abb6fab98e7f21d5b5bee418bd7b172d6e10 new head: 1d910b5e2b7c39148f496bb6e6a3fa2134c957f2 ---------------------------------------------------------------------------- 82fc1a8: NTFS: Fix - Tracker faults when 'Show volumes on desktop' mode enabled. +alpha 4 1d910b5: NTFS: More fixes for #8332 * Generate name for unnamed volumes +alpha 4 [ threedeyes <3dEyes@xxxxxxxxx> ] ---------------------------------------------------------------------------- 2 files changed, 47 insertions(+), 29 deletions(-) .../kernel/file_systems/ntfs/fake_attributes.c | 41 +++++++++----------- src/add-ons/kernel/file_systems/ntfs/fs_func.c | 35 +++++++++++++---- ############################################################################ Commit: 82fc1a8f3cffc2f2d3c251278984c30a907a81f9 URL: http://cgit.haiku-os.org/haiku/commit/?id=82fc1a8 Author: threedeyes <3dEyes@xxxxxxxxx> Date: Fri Nov 2 12:34:39 2012 UTC NTFS: Fix - Tracker faults when 'Show volumes on desktop' mode enabled. +alpha 4 ---------------------------------------------------------------------------- diff --git a/src/add-ons/kernel/file_systems/ntfs/fake_attributes.c b/src/add-ons/kernel/file_systems/ntfs/fake_attributes.c index be02952..39a3019 100644 --- a/src/add-ons/kernel/file_systems/ntfs/fake_attributes.c +++ b/src/add-ons/kernel/file_systems/ntfs/fake_attributes.c @@ -28,6 +28,7 @@ int32 kFreeTypeCookie = 0x87654321; char *kFailBackMime = {"application/octet-stream"}; char *kDirectoryMime = {"application/x-vnd.Be-directory"}; +char *kAttrTypeName = {"BEOS:TYPE"}; status_t set_mime(vnode *node, const char *filename) @@ -35,7 +36,7 @@ status_t set_mime(vnode *node, const char *filename) struct ext_mime *p; int32 namelen; int32 ext_len; - node->mime = kFailBackMime; + node->mime = NULL; if (filename == NULL) { @@ -56,7 +57,10 @@ status_t set_mime(vnode *node, const char *filename) if (!strcasecmp(filename + namelen - ext_len, p->extension)) break; } - node->mime = p->mime; + if(p->mime==NULL) + node->mime = kFailBackMime; + else + node->mime = p->mime; return B_NO_ERROR; } @@ -189,8 +193,8 @@ fake_read_attrib_dir(fs_volume *_vol, fs_vnode *_node, void *_cookie, entry->d_ino = node->vnid; entry->d_dev = ns->id; - entry->d_reclen = sizeof(struct dirent) + 10; - strcpy(entry->d_name, "BEOS:TYPE"); + entry->d_reclen = sizeof(struct dirent) + strlen(kAttrTypeName); + strcpy(entry->d_name, kAttrTypeName); } *cookie = kCloseTypeCookie; @@ -207,24 +211,19 @@ fake_create_attrib(fs_volume *_vol, fs_vnode *_node, const char* name, uint32 type, int openMode, void** _cookie) { nspace *ns = (nspace *)_vol->private_volume; - int result = B_NO_ERROR; - + LOCK_VOL(ns); TRACE("fake_create_attrib - ENTER (name = [%s])\n",name); - if (strcmp(name, "BEOS:TYPE") != 0) - goto exit; - - *_cookie = &kSetTypeCookie; + if (strcmp(name, kAttrTypeName) == 0) + *_cookie = &kSetTypeCookie; -exit: - - TRACE("fake_create_attrib - EXIT, result is %s\n", strerror(result)); + TRACE("fake_create_attrib - EXIT\n"); UNLOCK_VOL(ns); - return result; + return B_NO_ERROR; } status_t @@ -232,18 +231,16 @@ fake_open_attrib(fs_volume *_vol, fs_vnode *_node, const char *name, int openMode, void **_cookie) { nspace *ns = (nspace *)_vol->private_volume; - int result = B_NO_ERROR; - + status_t result = B_NO_ERROR; + LOCK_VOL(ns); TRACE("fake_open_attrib - ENTER (name = [%s])\n",name); - if (strcmp(name, "BEOS:TYPE") != 0) - goto exit; - - *_cookie = &kSetTypeCookie; - -exit: + if (strcmp(name, kAttrTypeName) == 0) + *_cookie = &kSetTypeCookie; + else + result = ENOENT; TRACE("fake_open_attrib - EXIT, result is %s\n", strerror(result)); ############################################################################ Revision: hrev44735 Commit: 1d910b5e2b7c39148f496bb6e6a3fa2134c957f2 URL: http://cgit.haiku-os.org/haiku/commit/?id=1d910b5 Author: threedeyes <3dEyes@xxxxxxxxx> Date: Fri Nov 2 12:52:00 2012 UTC Ticket: https://dev.haiku-os.org/ticket/8332 NTFS: More fixes for #8332 * Generate name for unnamed volumes +alpha 4 ---------------------------------------------------------------------------- diff --git a/src/add-ons/kernel/file_systems/ntfs/fs_func.c b/src/add-ons/kernel/file_systems/ntfs/fs_func.c index 8218828..da58cbd 100644 --- a/src/add-ons/kernel/file_systems/ntfs/fs_func.c +++ b/src/add-ons/kernel/file_systems/ntfs/fs_func.c @@ -36,6 +36,7 @@ #include <driver_settings.h> #include <KernelExport.h> +#include <disk_device_manager.h> #include "attributes.h" #include "fake_attributes.h" @@ -43,11 +44,11 @@ #include "ntfs.h" #include "volume_util.h" -static const char* kNTFSUntitled = {"NTFS Untitled"}; +static const char* kNTFSUnnamed = {"NTFS Unnamed"}; typedef struct identify_cookie { NTFS_BOOT_SECTOR boot; - char label[256]; + char label[MAX_PATH]; } identify_cookie; @@ -257,10 +258,11 @@ fs_identify_partition(int fd, partition_data *partition, void **_cookie) return -1; } - strcpy(cookie->label, kNTFSUntitled); + cookie->label[0]='\0'; + memcpy(&cookie->boot, &boot, 512); - // try get path for device - if (ioctl(fd, B_GET_PATH_FOR_DEVICE, devpath)) { + // get path for device + if (ioctl(fd, B_GET_PATH_FOR_DEVICE, devpath) != 0) { // try mount ntVolume = utils_mount_volume(devpath, MS_RDONLY | MS_RECOVER); if (ntVolume != NULL) { @@ -270,7 +272,26 @@ fs_identify_partition(int fd, partition_data *partition, void **_cookie) } } - memcpy(&cookie->boot, &boot, 512); + // generate a more or less descriptive name for unnamed volume + if (cookie->label[0]=='\0') { + double size; + off_t diskSize = sle64_to_cpu(boot.number_of_sectors) + * le16_to_cpu(boot.bpb.bytes_per_sector); + off_t divisor = 1ULL << 40; + char unit = 'T'; + if (diskSize < divisor) { + divisor = 1UL << 30; + unit = 'G'; + if (diskSize < divisor) { + divisor = 1UL << 20; + unit = 'M'; + } + } + + size = (double)((10 * diskSize + divisor - 1) / divisor); + snprintf(cookie->label, MAX_PATH - 1, "%g %cB NTFS File System", + size / 10, unit); + } *_cookie = cookie; @@ -468,7 +489,7 @@ fs_rfsstat(fs_volume *_vol, struct fs_info *fss) break; } if (i < 0) - strcpy(fss->volume_name, kNTFSUntitled); + strcpy(fss->volume_name, kNTFSUnnamed); else fss->volume_name[i + 1] = 0;