cleanup, header inclusion should be revisited.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@40617 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
1cc2cf286c
commit
b62dd5abd5
@ -10,24 +10,27 @@
|
||||
|
||||
#define MIME_STRING_TYPE 'MIMS'
|
||||
|
||||
#include <SupportDefs.h>
|
||||
#include <KernelExport.h>
|
||||
#include <SupportDefs.h>
|
||||
#include <TypeConstants.h>
|
||||
|
||||
#include <dirent.h>
|
||||
#include <fs_attr.h>
|
||||
#include <string.h>
|
||||
#include <malloc.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "ntfs.h"
|
||||
#include "attributes.h"
|
||||
#include "mime_table.h"
|
||||
#include "ntfs.h"
|
||||
|
||||
//TODO: notify*()
|
||||
|
||||
|
||||
int32 kBeOSTypeCookie = 0x1234;
|
||||
|
||||
status_t set_mime(vnode *node, const char *filename)
|
||||
|
||||
status_t
|
||||
set_mime(vnode *node, const char *filename)
|
||||
{
|
||||
struct ext_mime *p;
|
||||
int32 namelen, ext_len;
|
||||
@ -38,7 +41,7 @@ status_t set_mime(vnode *node, const char *filename)
|
||||
|
||||
namelen = strlen(filename);
|
||||
|
||||
for (p=mimes;p->extension;p++) {
|
||||
for (p = mimes; p->extension; p++) {
|
||||
ext_len = strlen(p->extension);
|
||||
|
||||
if (namelen <= ext_len)
|
||||
@ -87,7 +90,7 @@ fs_open_attrib_dir(fs_volume *_vol, fs_vnode *_node, void **_cookie)
|
||||
cookie = (attrdircookie*)ntfs_calloc(sizeof(attrdircookie));
|
||||
if (cookie == NULL) {
|
||||
result = ENOMEM;
|
||||
goto exit;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
cookie->inode = ni;
|
||||
@ -110,14 +113,14 @@ exit:
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
fs_close_attrib_dir(fs_volume *_vol, fs_vnode *_node, void *_cookie)
|
||||
{
|
||||
|
||||
|
||||
return B_NO_ERROR;
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
fs_free_attrib_dir_cookie(fs_volume *_vol, fs_vnode *_node, void *_cookie)
|
||||
{
|
||||
@ -137,6 +140,7 @@ fs_free_attrib_dir_cookie(fs_volume *_vol, fs_vnode *_node, void *_cookie)
|
||||
return B_NO_ERROR;
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
fs_rewind_attrib_dir(fs_volume *_vol, fs_vnode *_node, void *_cookie)
|
||||
{
|
||||
@ -167,7 +171,8 @@ fs_rewind_attrib_dir(fs_volume *_vol, fs_vnode *_node, void *_cookie)
|
||||
|
||||
|
||||
status_t
|
||||
fs_read_attrib_dir(fs_volume *_vol, fs_vnode *_node, void *_cookie, struct dirent *entry, size_t bufsize, uint32 *num)
|
||||
fs_read_attrib_dir(fs_volume *_vol, fs_vnode *_node, void *_cookie,
|
||||
struct dirent *entry, size_t bufsize, uint32 *num)
|
||||
{
|
||||
nspace *ns = (nspace *)_vol->private_volume;
|
||||
vnode *node = (vnode *)_node->private_node;
|
||||
@ -210,14 +215,13 @@ fs_read_attrib_dir(fs_volume *_vol, fs_vnode *_node, void *_cookie, struct diren
|
||||
if (result && errno != ENOENT) {
|
||||
result = errno;
|
||||
goto exit;
|
||||
} else {
|
||||
} else
|
||||
result = B_OK;
|
||||
}
|
||||
|
||||
|
||||
exit:
|
||||
|
||||
ERRPRINT("%s - EXIT, result is %s, *num %d\n", __FUNCTION__, strerror(result), *num);
|
||||
ERRPRINT("%s - EXIT, result is %s, *num %d\n", __FUNCTION__,
|
||||
strerror(result), *num);
|
||||
|
||||
UNLOCK_VOL(ns);
|
||||
|
||||
@ -231,8 +235,8 @@ exit:
|
||||
|
||||
|
||||
status_t
|
||||
fs_create_attrib(fs_volume *_vol, fs_vnode *_node, const char* name, uint32 type, int openMode,
|
||||
void** _cookie)
|
||||
fs_create_attrib(fs_volume *_vol, fs_vnode *_node, const char* name,
|
||||
uint32 type, int openMode, void** _cookie)
|
||||
{
|
||||
nspace *ns = (nspace*)_vol->private_volume;
|
||||
vnode *node = (vnode*)_node->private_node;
|
||||
@ -270,25 +274,29 @@ fs_create_attrib(fs_volume *_vol, fs_vnode *_node, const char* name, uint32 type
|
||||
ulen = ntfs_mbstoucs(name, &uname);
|
||||
if (ulen < 0) {
|
||||
result = EILSEQ;
|
||||
ERRPRINT("%s - mb alloc: %s\n", __FUNCTION__, strerror(result));
|
||||
ERRPRINT("%s - mb alloc: %s\n", __FUNCTION__, strerror(result));
|
||||
goto exit;
|
||||
}
|
||||
|
||||
na = ntfs_attr_open(ni, AT_DATA, uname, ulen);
|
||||
if (na) {
|
||||
result = EEXIST;
|
||||
ERRPRINT("%s - ntfs_attr_open: %s\n", __FUNCTION__, strerror(result));
|
||||
ERRPRINT("%s - ntfs_attr_open: %s\n", __FUNCTION__,
|
||||
strerror(result));
|
||||
goto exit;
|
||||
}
|
||||
if (ntfs_non_resident_attr_record_add(ni, AT_DATA, uname, ulen, 0, 32, 0) < 0) {
|
||||
if (ntfs_non_resident_attr_record_add(ni, AT_DATA, uname, ulen, 0, 32,
|
||||
0) < 0) {
|
||||
result = errno;
|
||||
ERRPRINT("%s - ntfs_non_resident_attr_record_add: %s\n", __FUNCTION__, strerror(result));
|
||||
ERRPRINT("%s - ntfs_non_resident_attr_record_add: %s\n",
|
||||
__FUNCTION__, strerror(result));
|
||||
goto exit;
|
||||
}
|
||||
na = ntfs_attr_open(ni, AT_DATA, uname, ulen);
|
||||
if (!na) {
|
||||
result = errno;
|
||||
ERRPRINT("%s - ntfs_attr_open: %s\n", __FUNCTION__, strerror(result));
|
||||
ERRPRINT("%s - ntfs_attr_open: %s\n", __FUNCTION__,
|
||||
strerror(result));
|
||||
goto exit;
|
||||
}
|
||||
}
|
||||
@ -325,7 +333,8 @@ exit:
|
||||
|
||||
|
||||
status_t
|
||||
fs_open_attrib(fs_volume *_vol, fs_vnode *_node, const char *name, int openMode, void **_cookie)
|
||||
fs_open_attrib(fs_volume *_vol, fs_vnode *_node, const char *name,
|
||||
int openMode, void **_cookie)
|
||||
{
|
||||
nspace *ns = (nspace*)_vol->private_volume;
|
||||
vnode *node = (vnode*)_node->private_node;
|
||||
@ -436,7 +445,8 @@ fs_free_attrib_cookie(fs_volume *_vol, fs_vnode *_node, void *_cookie)
|
||||
|
||||
|
||||
status_t
|
||||
fs_read_attrib_stat(fs_volume *_vol, fs_vnode *_node, void *_cookie,struct stat *stat)
|
||||
fs_read_attrib_stat(fs_volume *_vol, fs_vnode *_node, void *_cookie,
|
||||
struct stat *stat)
|
||||
{
|
||||
nspace *ns = (nspace *)_vol->private_volume;
|
||||
//vnode *node = (vnode *)_node->private_node;
|
||||
@ -450,7 +460,7 @@ fs_read_attrib_stat(fs_volume *_vol, fs_vnode *_node, void *_cookie,struct stat
|
||||
|
||||
//ERRPRINT("%s - ENTER\n", __FUNCTION__);
|
||||
|
||||
stat->st_type = B_RAW_TYPE;
|
||||
stat->st_type = B_XATTR_TYPE;
|
||||
stat->st_size = na ? na->data_size : 0;
|
||||
|
||||
//exit:
|
||||
@ -462,14 +472,15 @@ fs_read_attrib_stat(fs_volume *_vol, fs_vnode *_node, void *_cookie,struct stat
|
||||
|
||||
|
||||
status_t
|
||||
fs_read_attrib(fs_volume *_vol, fs_vnode *_node, void *_cookie, off_t pos, void *buffer, size_t *len)
|
||||
fs_read_attrib(fs_volume *_vol, fs_vnode *_node, void *_cookie, off_t pos,
|
||||
void *buffer, size_t *len)
|
||||
{
|
||||
nspace *ns = (nspace *)_vol->private_volume;
|
||||
//vnode *node = (vnode *)_node->private_node;
|
||||
attrcookie *cookie = (attrcookie *)_cookie;
|
||||
ntfs_inode *ni = cookie->inode;
|
||||
ntfs_attr *na = cookie->stream;
|
||||
size_t size = *len;
|
||||
size_t size = *len;
|
||||
int total = 0;
|
||||
status_t result = B_NO_ERROR;
|
||||
|
||||
@ -523,7 +534,8 @@ exit:
|
||||
|
||||
|
||||
status_t
|
||||
fs_write_attrib(fs_volume *_vol, fs_vnode *_node, void *_cookie,off_t pos, const void *buffer, size_t *_length)
|
||||
fs_write_attrib(fs_volume *_vol, fs_vnode *_node, void *_cookie,off_t pos,
|
||||
const void *buffer, size_t *_length)
|
||||
{
|
||||
nspace *ns = (nspace *)_vol->private_volume;
|
||||
//vnode *node = (vnode *)_node->private_node;
|
||||
@ -566,8 +578,8 @@ fs_write_attrib(fs_volume *_vol, fs_vnode *_node, void *_cookie,off_t pos, const
|
||||
while (size) {
|
||||
off_t bytesWritten = ntfs_attr_pwrite(na, pos, size, buffer);
|
||||
if (bytesWritten < (s64)size)
|
||||
ERRPRINT("%s - ntfs_attr_pwrite returned less bytes than requested.\n",
|
||||
__FUNCTION__);
|
||||
ERRPRINT("%s - ntfs_attr_pwrite returned less bytes than "
|
||||
"requested.\n", __FUNCTION__);
|
||||
if (bytesWritten <= 0) {
|
||||
ERRPRINT(("%s - ntfs_attr_pwrite()<=0\n", __FUNCTION__));
|
||||
*_length = 0;
|
||||
@ -597,3 +609,4 @@ exit:
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -6,25 +6,36 @@
|
||||
* handles mime type information for ntfs
|
||||
* gets/sets mime information in vnode
|
||||
*/
|
||||
|
||||
#ifndef _fs_ATTR_H_
|
||||
#define _fs_ATTR_H_
|
||||
#ifndef NTFS_ATTRIBUTES_H
|
||||
#define NTFS_ATTRIBUTES_H
|
||||
|
||||
|
||||
#include <fs_attr.h>
|
||||
|
||||
#include "ntfs.h"
|
||||
|
||||
|
||||
status_t set_mime(vnode *node, const char *filename);
|
||||
|
||||
status_t fs_create_attrib(fs_volume *_vol, fs_vnode *_node, const char* name, uint32 type, int openMode, void** _cookie);
|
||||
status_t fs_create_attrib(fs_volume *_vol, fs_vnode *_node, const char* name,
|
||||
uint32 type, int openMode, void** _cookie);
|
||||
status_t fs_open_attrib_dir(fs_volume *_vol, fs_vnode *_node, void **_cookie);
|
||||
status_t fs_close_attrib_dir(fs_volume *_vol, fs_vnode *_node, void *_cookie);
|
||||
status_t fs_free_attrib_dir_cookie(fs_volume *_vol, fs_vnode *_node, void *_cookie);
|
||||
status_t fs_free_attrib_dir_cookie(fs_volume *_vol, fs_vnode *_node,
|
||||
void *_cookie);
|
||||
status_t fs_rewind_attrib_dir(fs_volume *_vol, fs_vnode *_node, void *_cookie);
|
||||
status_t fs_read_attrib_dir(fs_volume *_vol, fs_vnode *_node, void *_cookie, struct dirent *buf, size_t bufsize, uint32 *num);
|
||||
status_t fs_open_attrib(fs_volume *_vol, fs_vnode *_node, const char *name, int openMode, void **_cookie);
|
||||
status_t fs_read_attrib_dir(fs_volume *_vol, fs_vnode *_node, void *_cookie,
|
||||
struct dirent *buf, size_t bufsize, uint32 *num);
|
||||
status_t fs_open_attrib(fs_volume *_vol, fs_vnode *_node, const char *name,
|
||||
int openMode, void **_cookie);
|
||||
status_t fs_close_attrib(fs_volume *_vol, fs_vnode *_node, void *cookie);
|
||||
status_t fs_free_attrib_cookie(fs_volume *_vol, fs_vnode *_node, void *cookie);
|
||||
status_t fs_read_attrib_stat(fs_volume *_vol, fs_vnode *_node, void *cookie, struct stat *stat);
|
||||
status_t fs_read_attrib(fs_volume *_vol, fs_vnode *_node, void *cookie, off_t pos,void *buffer, size_t *_length);
|
||||
status_t fs_write_attrib(fs_volume *_vol, fs_vnode *_node, void *cookie, off_t pos, const void *buffer, size_t *_length);
|
||||
status_t fs_read_attrib_stat(fs_volume *_vol, fs_vnode *_node, void *cookie,
|
||||
struct stat *stat);
|
||||
status_t fs_read_attrib(fs_volume *_vol, fs_vnode *_node, void *cookie,
|
||||
off_t pos, void *buffer, size_t *_length);
|
||||
status_t fs_write_attrib(fs_volume *_vol, fs_vnode *_node, void *cookie,
|
||||
off_t pos, const void *buffer, size_t *_length);
|
||||
|
||||
#endif
|
||||
#endif // NTFS_ATTRIBUTES_H
|
||||
|
||||
|
@ -20,26 +20,28 @@
|
||||
* Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
#include <ctype.h>
|
||||
#include <stdio.h>
|
||||
#include <dirent.h>
|
||||
#include <sys/stat.h>
|
||||
#include <KernelExport.h>
|
||||
#include <time.h>
|
||||
#include <malloc.h>
|
||||
#include <driver_settings.h>
|
||||
|
||||
#include "ntfs.h"
|
||||
#include "fs_func.h"
|
||||
|
||||
#include <ctype.h>
|
||||
#include <dirent.h>
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <malloc.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sys/stat.h>
|
||||
#include <time.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <driver_settings.h>
|
||||
#include <KernelExport.h>
|
||||
|
||||
#include "attributes.h"
|
||||
#include "lock.h"
|
||||
#include "ntfs.h"
|
||||
#include "volume_util.h"
|
||||
#include "fs_func.h"
|
||||
|
||||
|
||||
typedef struct identify_cookie {
|
||||
@ -62,14 +64,14 @@ get_node_type(ntfs_inode* ni, int* _type)
|
||||
*_type = S_IFREG;
|
||||
|
||||
if (ni->flags & FILE_ATTR_SYSTEM) {
|
||||
na = ntfs_attr_open(ni, AT_DATA, NULL,0);
|
||||
if (!na) {
|
||||
na = ntfs_attr_open(ni, AT_DATA, NULL, 0);
|
||||
if (!na)
|
||||
return ENOENT;
|
||||
}
|
||||
|
||||
// Check whether it's Interix symbolic link
|
||||
if (na->data_size <= sizeof(INTX_FILE_TYPES) +
|
||||
sizeof(ntfschar) * PATH_MAX &&
|
||||
na->data_size > sizeof(INTX_FILE_TYPES)) {
|
||||
sizeof(ntfschar) * PATH_MAX &&
|
||||
na->data_size > sizeof(INTX_FILE_TYPES)) {
|
||||
INTX_FILE *intx_file;
|
||||
|
||||
intx_file = ntfs_malloc(na->data_size);
|
||||
@ -94,8 +96,10 @@ get_node_type(ntfs_inode* ni, int* _type)
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
fs_ntfs_update_times(fs_volume *vol, ntfs_inode *ni, ntfs_time_update_flags mask)
|
||||
fs_ntfs_update_times(fs_volume *vol, ntfs_inode *ni,
|
||||
ntfs_time_update_flags mask)
|
||||
{
|
||||
nspace *ns = (nspace*)vol->private_volume;
|
||||
|
||||
@ -105,6 +109,7 @@ fs_ntfs_update_times(fs_volume *vol, ntfs_inode *ni, ntfs_time_update_flags mask
|
||||
ntfs_inode_update_times(ni, mask);
|
||||
}
|
||||
|
||||
|
||||
float
|
||||
fs_identify_partition(int fd, partition_data *partition, void **_cookie)
|
||||
{
|
||||
@ -116,9 +121,8 @@ fs_identify_partition(int fd, partition_data *partition, void **_cookie)
|
||||
|
||||
// read in the boot sector
|
||||
ERRPRINT("fs_identify_partition: read in the boot sector\n");
|
||||
if (read_pos(fd, 0, (void*)&boot, 512) != 512) {
|
||||
if (read_pos(fd, 0, (void*)&boot, 512) != 512)
|
||||
return -1;
|
||||
}
|
||||
|
||||
// check boot signature
|
||||
if ((buf[0x1fe] != 0x55 || buf[0x1ff] != 0xaa) && buf[0x15] == 0xf8)
|
||||
@ -308,7 +312,7 @@ fs_rfsstat(fs_volume *_vol, struct fs_info *fss)
|
||||
strncpy(fss->device_name, ns->devicePath, sizeof(fss->device_name));
|
||||
strncpy(fss->volume_name, ns->ntvol->vol_name, sizeof(fss->volume_name));
|
||||
|
||||
for (i = strlen(fss->volume_name) - 1; i >=0 ; i--) {
|
||||
for (i = strlen(fss->volume_name) - 1; i >= 0 ; i--) {
|
||||
if (fss->volume_name[i] != ' ')
|
||||
break;
|
||||
}
|
||||
@ -504,7 +508,7 @@ fs_read_vnode(fs_volume *_vol, ino_t vnid, fs_vnode *_node, int *_type,
|
||||
else {
|
||||
name = (char*)malloc(MAX_PATH);
|
||||
if (name != NULL) {
|
||||
if (utils_inode_get_name(ni, name,MAX_PATH) == 1)
|
||||
if (utils_inode_get_name(ni, name, MAX_PATH) == 1)
|
||||
set_mime(newNode, name);
|
||||
free(name);
|
||||
}
|
||||
@ -590,7 +594,7 @@ fs_rstat(fs_volume *_vol, fs_vnode *_node, struct stat *stbuf)
|
||||
|
||||
ERRPRINT("fs_rstat - ENTER:\n");
|
||||
|
||||
if (ns == NULL || node == NULL ||stbuf == NULL) {
|
||||
if (ns == NULL || node == NULL || stbuf == NULL) {
|
||||
result = ENOENT;
|
||||
goto exit;
|
||||
}
|
||||
@ -626,9 +630,9 @@ fs_rstat(fs_volume *_vol, fs_vnode *_node, struct stat *stbuf)
|
||||
stbuf->st_size = na->data_size;
|
||||
stbuf->st_blocks = na->allocated_size >> 9;
|
||||
// Check whether it's Interix symbolic link
|
||||
if (na->data_size <= sizeof(INTX_FILE_TYPES) +
|
||||
sizeof(ntfschar) * PATH_MAX &&
|
||||
na->data_size > sizeof(INTX_FILE_TYPES)) {
|
||||
if (na->data_size <= sizeof(INTX_FILE_TYPES)
|
||||
+ sizeof(ntfschar) * PATH_MAX
|
||||
&& na->data_size > sizeof(INTX_FILE_TYPES)) {
|
||||
INTX_FILE *intx_file;
|
||||
|
||||
intx_file = ntfs_malloc(na->data_size);
|
||||
@ -653,9 +657,8 @@ fs_rstat(fs_volume *_vol, fs_vnode *_node, struct stat *stbuf)
|
||||
stbuf->st_mode |= 0666;
|
||||
}
|
||||
|
||||
if (ns->flags & B_FS_IS_READONLY) {
|
||||
if (ns->flags & B_FS_IS_READONLY)
|
||||
stbuf->st_mode &= ~(S_IWUSR | S_IWGRP | S_IWOTH);
|
||||
}
|
||||
|
||||
stbuf->st_uid = 0;
|
||||
stbuf->st_gid = 0;
|
||||
@ -697,9 +700,9 @@ fs_wstat(fs_volume *_vol, fs_vnode *_node, const struct stat *st, uint32 mask)
|
||||
if (mask & B_STAT_SIZE) {
|
||||
ERRPRINT("fs_wstat: setting file size to %Lx\n", st->st_size);
|
||||
|
||||
if (ni->mrec->flags & MFT_RECORD_IS_DIRECTORY) {
|
||||
if (ni->mrec->flags & MFT_RECORD_IS_DIRECTORY)
|
||||
result = EISDIR;
|
||||
} else {
|
||||
else {
|
||||
ntfs_attr *na = ntfs_attr_open(ni, AT_DATA, NULL, 0);
|
||||
if (!na) {
|
||||
result = EINVAL;
|
||||
@ -766,7 +769,7 @@ fs_fsync(fs_volume *_vol, fs_vnode *_node)
|
||||
|
||||
ERRPRINT("fs_fsync: ENTER\n");
|
||||
|
||||
if (ns ==NULL || node== NULL) {
|
||||
if (ns == NULL || node == NULL) {
|
||||
result = ENOENT;
|
||||
goto exit;
|
||||
}
|
||||
@ -870,7 +873,7 @@ fs_create(fs_volume *_vol, fs_vnode *_dir, const char *name, int omode,
|
||||
|
||||
LOCK_VOL(ns);
|
||||
|
||||
ERRPRINT("fs_create - ENTER: name=%s\n",name);
|
||||
ERRPRINT("fs_create - ENTER: name=%s\n", name);
|
||||
|
||||
if (_vol == NULL || _dir == NULL) {
|
||||
result = EINVAL;
|
||||
@ -902,9 +905,9 @@ fs_create(fs_volume *_vol, fs_vnode *_dir, const char *name, int omode,
|
||||
|
||||
cookie = (filecookie*)ntfs_calloc(sizeof(filecookie));
|
||||
|
||||
if (cookie != NULL) {
|
||||
if (cookie != NULL)
|
||||
cookie->omode = omode;
|
||||
} else {
|
||||
else {
|
||||
result = ENOMEM;
|
||||
goto exit;
|
||||
}
|
||||
@ -953,9 +956,9 @@ fs_create(fs_volume *_vol, fs_vnode *_dir, const char *name, int omode,
|
||||
free(uname);
|
||||
|
||||
exit:
|
||||
if (result >= B_OK) {
|
||||
if (result >= B_OK)
|
||||
*_cookie = cookie;
|
||||
} else
|
||||
else
|
||||
free(cookie);
|
||||
|
||||
if (na)
|
||||
@ -1073,7 +1076,7 @@ fs_write(fs_volume *_vol, fs_vnode *_dir, void *_cookie, off_t offset,
|
||||
|
||||
LOCK_VOL(ns);
|
||||
|
||||
ERRPRINT("fs_write - ENTER, offset=%d, len=%d\n", (int)offset, (int)(*len));
|
||||
ERRPRINT("fs_write - ENTER, offset=%lld, len=%ld\n", offset, *len);
|
||||
|
||||
ni = ntfs_inode_open(ns->ntvol, node->vnid);
|
||||
if (ni == NULL) {
|
||||
@ -1117,8 +1120,10 @@ fs_write(fs_volume *_vol, fs_vnode *_dir, void *_cookie, off_t offset,
|
||||
|
||||
while (size) {
|
||||
off_t bytesWritten = ntfs_attr_pwrite(na, offset, size, buf);
|
||||
if (bytesWritten < (s64)size)
|
||||
ERRPRINT("fs_write - ntfs_attr_pwrite returned less bytes than requested.\n");
|
||||
if (bytesWritten < (s64)size) {
|
||||
ERRPRINT("fs_write - ntfs_attr_pwrite returned less bytes than "
|
||||
"requested.\n");
|
||||
}
|
||||
if (bytesWritten <= 0) {
|
||||
ERRPRINT(("fs_write - ntfs_attr_pwrite()<=0\n"));
|
||||
*len = 0;
|
||||
@ -1326,7 +1331,8 @@ fs_create_symlink(fs_volume *_vol, fs_vnode *_dir, const char *name,
|
||||
goto exit;
|
||||
}
|
||||
|
||||
sym = ntfs_create_symlink(bi, securid, uname, unameLength, utarget, utargetLength);
|
||||
sym = ntfs_create_symlink(bi, securid, uname, unameLength, utarget,
|
||||
utargetLength);
|
||||
if (sym == NULL) {
|
||||
result = EINVAL;
|
||||
goto exit;
|
||||
@ -1396,7 +1402,7 @@ fs_mkdir(fs_volume *_vol, fs_vnode *_dir, const char *name, int perms)
|
||||
|
||||
LOCK_VOL(ns);
|
||||
|
||||
ERRPRINT("fs_mkdir - ENTER: name=%s\n",name);
|
||||
ERRPRINT("fs_mkdir - ENTER: name=%s\n", name);
|
||||
|
||||
if (_vol == NULL || _dir == NULL || name == NULL) {
|
||||
result = EINVAL;
|
||||
@ -1587,7 +1593,7 @@ fs_rename(fs_volume *_vol, fs_vnode *_odir, const char *oldname,
|
||||
// renaming
|
||||
|
||||
nvnid = MREF(ntfs_inode_lookup_by_name(odi, unewname, unewnameLength));
|
||||
if (nvnid != (u64) -1)
|
||||
if (nvnid != (u64)-1)
|
||||
get_vnode(_vol, nvnid, (void**)&nnode);
|
||||
|
||||
if (nnode != NULL) {
|
||||
@ -1602,7 +1608,7 @@ fs_rename(fs_volume *_vol, fs_vnode *_odir, const char *oldname,
|
||||
goto exit;
|
||||
}
|
||||
|
||||
if (ntfs_link(oi, odi, unewname, unewnameLength)) {
|
||||
if (ntfs_link(oi, odi, unewname, unewnameLength)) {
|
||||
ntfs_inode_close(oi);
|
||||
result = EINVAL;
|
||||
goto exit;
|
||||
@ -1621,8 +1627,8 @@ fs_rename(fs_volume *_vol, fs_vnode *_odir, const char *oldname,
|
||||
goto exit;
|
||||
}
|
||||
|
||||
notify_entry_moved(ns->id, MREF(odi->mft_no), oldname, MREF(odi->mft_no),
|
||||
newname, onode->vnid);
|
||||
notify_entry_moved(ns->id, MREF(odi->mft_no), oldname,
|
||||
MREF(odi->mft_no), newname, onode->vnid);
|
||||
put_vnode(_vol, onode->vnid);
|
||||
|
||||
if (utils_inode_get_name(oi, path, MAX_PATH) == 0) {
|
||||
@ -1680,7 +1686,7 @@ do_unlink(fs_volume *_vol, vnode *dir, const char *name, bool isdir)
|
||||
|
||||
vnid = MREF(ntfs_inode_lookup_by_name(bi, uname, unameLength));
|
||||
|
||||
if ( vnid == (u64) -1 || vnid == FILE_root) {
|
||||
if ( vnid == (u64)-1 || vnid == FILE_root) {
|
||||
result = EINVAL;
|
||||
goto exit1;
|
||||
}
|
||||
@ -1757,19 +1763,14 @@ fs_rmdir(fs_volume *_vol, fs_vnode *_dir, const char *name)
|
||||
|
||||
LOCK_VOL(ns);
|
||||
|
||||
ERRPRINT("fs_rmdir - ENTER: name %s\n", name==NULL?"NULL":name);
|
||||
ERRPRINT("fs_rmdir - ENTER: name %s\n", name == NULL ? "NULL" : name);
|
||||
|
||||
if (ns == NULL || dir == NULL || name == NULL) {
|
||||
result = EINVAL;
|
||||
goto exit1;
|
||||
}
|
||||
|
||||
if (strcmp(name, ".") == 0) {
|
||||
result = EPERM;
|
||||
goto exit1;
|
||||
}
|
||||
|
||||
if (strcmp(name, "..") == 0) {
|
||||
if (strcmp(name, ".") == 0 || strcmp(name, "..") == 0) {
|
||||
result = EPERM;
|
||||
goto exit1;
|
||||
}
|
||||
@ -1802,19 +1803,14 @@ fs_unlink(fs_volume *_vol, fs_vnode *_dir, const char *name)
|
||||
|
||||
LOCK_VOL(ns);
|
||||
|
||||
ERRPRINT("fs_unlink - ENTER: name %s\n", name==NULL?"NULL":name);
|
||||
ERRPRINT("fs_unlink - ENTER: name %s\n", name == NULL ? "NULL" : name);
|
||||
|
||||
if (ns == NULL || dir == NULL || name == NULL) {
|
||||
result = EINVAL;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
if (strcmp(name, ".") == 0) {
|
||||
result = EPERM;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
if (strcmp(name, "..") == 0) {
|
||||
if (strcmp(name, ".") == 0 || strcmp(name, "..") == 0) {
|
||||
result = EPERM;
|
||||
goto exit;
|
||||
}
|
||||
|
@ -22,37 +22,39 @@
|
||||
#ifndef NTFS_FS_FUNC_H
|
||||
#define NTFS_FS_FUNC_H
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
#include <ctype.h>
|
||||
#include <dirent.h>
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <malloc.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
#include <ctype.h>
|
||||
#include <stdio.h>
|
||||
#include <dirent.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/stat.h>
|
||||
#include <KernelExport.h>
|
||||
#include <time.h>
|
||||
#include <malloc.h>
|
||||
|
||||
#include "ntfs.h"
|
||||
#include "attributes.h"
|
||||
#include "lock.h"
|
||||
#include "ntfs.h"
|
||||
#include "volume_util.h"
|
||||
|
||||
#define FS_DIR_MODE S_IFDIR | S_IRUSR | S_IRGRP | S_IROTH | S_IWUSR | \
|
||||
|
||||
#define FS_DIR_MODE S_IFDIR | S_IRUSR | S_IRGRP | S_IROTH | S_IWUSR | \
|
||||
S_IWGRP | S_IWOTH
|
||||
#define FS_FILE_MODE S_IFREG | S_IRUSR | S_IRGRP | S_IROTH | S_IWUSR | \
|
||||
#define FS_FILE_MODE S_IFREG | S_IRUSR | S_IRGRP | S_IROTH | S_IWUSR | \
|
||||
S_IWGRP | S_IWOTH
|
||||
#define FS_SLNK_MODE S_IFLNK | S_IRUSR | S_IRGRP | S_IROTH | S_IWUSR | \
|
||||
#define FS_SLNK_MODE S_IFLNK | S_IRUSR | S_IRGRP | S_IROTH | S_IWUSR | \
|
||||
S_IWGRP | S_IWOTH
|
||||
|
||||
|
||||
extern fs_vnode_ops gNTFSVnodeOps;
|
||||
extern fs_volume_ops gNTFSVolumeOps;
|
||||
|
||||
void fs_ntfs_update_times(fs_volume *vol, ntfs_inode *ni, ntfs_time_update_flags mask);
|
||||
void fs_ntfs_update_times(fs_volume *vol, ntfs_inode *ni,
|
||||
ntfs_time_update_flags mask);
|
||||
|
||||
float fs_identify_partition(int fd, partition_data *partition,
|
||||
void **_cookie);
|
||||
@ -77,7 +79,7 @@ status_t fs_sync(fs_volume *_vol);
|
||||
status_t fs_read_vnode(fs_volume *_vol, ino_t vnid, fs_vnode *_node,
|
||||
int *_type, uint32 *_flags, bool reenter);
|
||||
status_t fs_write_vnode(fs_volume *volume, fs_vnode *vnode, bool reenter);
|
||||
status_t fs_remove_vnode(fs_volume *volume, fs_vnode *vnode, bool reenter);
|
||||
status_t fs_remove_vnode(fs_volume *volume, fs_vnode *vnode, bool reenter);
|
||||
status_t fs_access(fs_volume *volume, fs_vnode *vnode, int mode);
|
||||
status_t fs_rstat(fs_volume *volume, fs_vnode *vnode, struct stat *st);
|
||||
status_t fs_wstat(fs_volume *volume, fs_vnode *vnode, const struct stat *st,
|
||||
@ -102,8 +104,9 @@ status_t fs_free_dircookie(fs_volume *volume, fs_vnode *vnode, void *cookie);
|
||||
status_t fs_readlink(fs_volume *volume, fs_vnode *link, char *buf,
|
||||
size_t *bufsize);
|
||||
status_t fs_fsync(fs_volume *_vol, fs_vnode *_node);
|
||||
status_t fs_rename(fs_volume *volume, fs_vnode *fromDir, const char *fromName,
|
||||
status_t fs_rename(fs_volume *volume, fs_vnode *fromDir, const char *fromName,
|
||||
fs_vnode *toDir, const char *toName);
|
||||
status_t fs_unlink(fs_volume *volume, fs_vnode *dir, const char *name);
|
||||
status_t fs_unlink(fs_volume *volume, fs_vnode *dir, const char *name);
|
||||
|
||||
#endif // NTFS_FS_FUNC_H
|
||||
|
||||
|
@ -16,23 +16,24 @@
|
||||
* distribution in the file COPYING); if not, write to the Free Software
|
||||
* Foundation,Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#ifndef _NTFS_H
|
||||
#define _NTFS_H
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <fs_interface.h>
|
||||
#include <kernel/lock.h>
|
||||
#include <fs_info.h>
|
||||
#include <fs_cache.h>
|
||||
|
||||
#include <fs_attr.h>
|
||||
#include <fs_cache.h>
|
||||
#include <fs_info.h>
|
||||
#include <fs_interface.h>
|
||||
#include <fs_info.h>
|
||||
#include <fs_index.h>
|
||||
#include <fs_query.h>
|
||||
#include <fs_volume.h>
|
||||
#include <lock.h>
|
||||
#include <NodeMonitor.h>
|
||||
#include <util/kernel_cpp.h>
|
||||
|
||||
@ -78,29 +79,25 @@ typedef enum {
|
||||
} ntfs_state_bits;
|
||||
|
||||
|
||||
typedef struct vnode
|
||||
{
|
||||
typedef struct vnode {
|
||||
u64 vnid;
|
||||
u64 parent_vnid;
|
||||
char *mime;
|
||||
} vnode;
|
||||
|
||||
typedef struct filecookie
|
||||
{
|
||||
typedef struct filecookie {
|
||||
int omode;
|
||||
off_t last_size;
|
||||
off_t last_size;
|
||||
} filecookie;
|
||||
|
||||
typedef struct attrcookie
|
||||
{
|
||||
typedef struct attrcookie {
|
||||
int omode;
|
||||
ntfs_inode *inode;
|
||||
ntfs_attr *stream;
|
||||
// MFT ref for EA ?
|
||||
} attrcookie;
|
||||
|
||||
typedef struct attrdircookie
|
||||
{
|
||||
typedef struct attrdircookie {
|
||||
ntfs_inode *inode;
|
||||
ntfs_attr_search_ctx *ctx;
|
||||
} attrdircookie;
|
||||
@ -109,8 +106,7 @@ typedef struct attrdircookie
|
||||
|
||||
|
||||
|
||||
typedef struct nspace
|
||||
{
|
||||
typedef struct nspace {
|
||||
ntfs_volume *ntvol;
|
||||
char devicePath[MAX_PATH];
|
||||
dev_t id;
|
||||
@ -137,3 +133,4 @@ typedef struct nspace
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -18,24 +18,20 @@
|
||||
* Foundation,Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
#include "ntfsdir.h"
|
||||
|
||||
#include <ctype.h>
|
||||
#include <dirent.h>
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <malloc.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
#include <ctype.h>
|
||||
#include <stdio.h>
|
||||
#include <dirent.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/stat.h>
|
||||
#include <KernelExport.h>
|
||||
#include <time.h>
|
||||
#include <malloc.h>
|
||||
|
||||
#include "ntfs.h"
|
||||
#include "attributes.h"
|
||||
#include "lock.h"
|
||||
#include "ntfsdir.h"
|
||||
|
||||
|
||||
//callback function for readdir()
|
||||
|
@ -17,13 +17,14 @@
|
||||
* distribution in the file COPYING); if not, write to the Free Software
|
||||
* Foundation,Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#ifndef _NTFSDIR_H
|
||||
#define _NTFSDIR_H
|
||||
#ifndef NTFSDIR_H
|
||||
#define NTFSDIR_H
|
||||
|
||||
|
||||
typedef struct dircookie
|
||||
{
|
||||
#include "ntfs.h"
|
||||
|
||||
|
||||
typedef struct dircookie {
|
||||
u64 pos;
|
||||
int readed;
|
||||
int last;
|
||||
@ -35,9 +36,12 @@ typedef struct dircookie
|
||||
status_t fs_closedir(fs_volume *volume, fs_vnode *vnode, void *cookie);
|
||||
status_t fs_free_dircookie(fs_volume *volume, fs_vnode *vnode, void *cookie);
|
||||
status_t fs_opendir(fs_volume *volume, fs_vnode *vnode, void** cookie);
|
||||
status_t fs_readdir(fs_volume *volume, fs_vnode *vnode, void *_cookie, struct dirent *buf, size_t bufsize, uint32 *num );
|
||||
status_t fs_readdir(fs_volume *volume, fs_vnode *vnode, void *_cookie,
|
||||
struct dirent *buf, size_t bufsize, uint32 *num );
|
||||
status_t fs_rewinddir(fs_volume *volume, fs_vnode *vnode, void *cookie);
|
||||
|
||||
extern void fs_ntfs_update_times(fs_volume *vol, ntfs_inode *ni, ntfs_time_update_flags mask);
|
||||
void fs_ntfs_update_times(fs_volume *vol, ntfs_inode *ni,
|
||||
ntfs_time_update_flags mask);
|
||||
|
||||
#endif // NTFSDIR_H
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user