示例#1
0
/**
 * dump_file
 */
static int dump_file(ntfs_volume *vol, ntfs_inode *ino)
{
	char buffer[1024];
	ntfs_attr_search_ctx *ctx;
	ATTR_RECORD *rec;
	int i;
	runlist *runs;

	utils_inode_get_name(ino, buffer, sizeof(buffer));

	ntfs_log_info("Dump: %s\n", buffer);

	ctx = ntfs_attr_get_search_ctx(ino, NULL);

	while ((rec = find_attribute(AT_UNUSED, ctx))) {
		ntfs_log_info("    0x%02x - ", rec->type);
		if (rec->non_resident) {
			ntfs_log_info("non-resident\n");
			runs = ntfs_mapping_pairs_decompress(vol, rec, NULL);
			if (runs) {
				ntfs_log_info("             VCN     LCN     Length\n");
				for (i = 0; runs[i].length > 0; i++) {
					ntfs_log_info("        %8lld %8lld %8lld\n",
							(long long)runs[i].vcn,
							(long long)runs[i].lcn,
							(long long)
							runs[i].length);
				}
				free(runs);
			}
		} else {
			ntfs_log_info("resident\n");
		}
	}

	ntfs_attr_put_search_ctx(ctx);
	return 0;
}
示例#2
0
文件: fs_func.c 项目: mmanley/Antares
status_t
fs_get_vnode_name(fs_volume *_vol, fs_vnode *_vnode, char *buffer,
	size_t bufferSize)
{
	nspace *ns = (nspace*)_vol->private_volume;
	vnode *node = (vnode*)_vnode->private_node;
	ntfs_inode *ni = NULL;
	status_t result = B_NO_ERROR;

	char path[MAX_PATH];
	char *name;

	LOCK_VOL(ns);

	ni = ntfs_inode_open(ns->ntvol, node->vnid);
	if (ni == NULL) {
		result = ENOENT;
		goto exit;
	}

	if (utils_inode_get_name(ni, path, MAX_PATH) == 0) {
		result = EINVAL;
		goto exit;
	}

	name = strrchr(path, '/');
	name++;

	strlcpy(buffer, name, bufferSize);

exit:
	if (ni)
		ntfs_inode_close(ni);

	UNLOCK_VOL(ns);

	return result;
}
示例#3
0
文件: fs_func.c 项目: mmanley/Antares
status_t
fs_read_vnode(fs_volume *_vol, ino_t vnid, fs_vnode *_node, int *_type,
	uint32 *_flags, bool reenter)
{
	nspace *ns = (nspace*)_vol->private_volume;
	vnode *newNode = NULL;
	ntfs_inode *ni = NULL;
	status_t result = B_NO_ERROR;

	if (!reenter)
		LOCK_VOL(ns);

	ERRPRINT("fs_read_vnode - ENTER\n");

	_node->private_node = NULL;
	_node->ops = &gNTFSVnodeOps;
	_flags = 0;

	newNode = (vnode*)ntfs_calloc(sizeof(vnode));
	if (newNode != NULL) {
		char *name = NULL;

		ni = ntfs_inode_open(ns->ntvol, vnid);
		if (ni == NULL) {
			result = ENOENT;
			goto exit;
		}

		// get the node type
		result = get_node_type(ni, _type);
		if (result != B_OK)
			goto exit;

		newNode->vnid = vnid;
		newNode->parent_vnid = ntfs_get_parent_ref(ni);

		if (ni->mrec->flags & MFT_RECORD_IS_DIRECTORY)
			set_mime(newNode, ".***");
		else {
			name = (char*)malloc(MAX_PATH);
			if (name != NULL) {
				if (utils_inode_get_name(ni, name,MAX_PATH) == 1)
					set_mime(newNode, name);
				free(name);
			}
		}

		_node->private_node = newNode;
	} else
		result = ENOMEM;

exit:
	if (ni != NULL)
		ntfs_inode_close(ni);

	if (result != B_OK && newNode != NULL)
		free(newNode);

	ERRPRINT("fs_read_vnode - EXIT, result is %s\n", strerror(result));

	if (!reenter)
		UNLOCK_VOL(ns);

	return result;
}