Skip to content

Commit

Permalink
ZOMG! some old commits ... you should check what's in here and commit…
Browse files Browse the repository at this point in the history
… sane stuff, didn't have the time to do it at this moment

Signed-off-by: Lucian Adrian Grijincu <lucian.grijincu@gmail.com>
  • Loading branch information
luciang committed Oct 29, 2010
1 parent b0ed6c8 commit a8e73a0
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 8 deletions.
6 changes: 4 additions & 2 deletions src/add-ons/kernel/file_systems/lklhaikufs/lh-error.h
Expand Up @@ -112,15 +112,17 @@ lh_to_haiku_error_x(int err)
}

static status_t
lh_to_haiku_error(int err)
lh_to_haiku_error_str(int err, const char* func)
{
status_t herr = lh_to_haiku_error_x(err);
if (herr != B_OK) {
dprintf("lklfs:: error rc=%d err=%s\n", (int) herr, strerror(herr));
dprintf("lklfs:: %s error rc=%d err=%s\n", func, (int) herr, strerror(herr));
}
return herr;
}


#define lh_to_haiku_error(err) lh_to_haiku_error_str(err, __func__)

#endif // BRIDGE_HAIKU

3 changes: 3 additions & 0 deletions src/add-ons/kernel/file_systems/lklhaikufs/lkl-haiku-bridge.h
Expand Up @@ -114,5 +114,8 @@ extern int lklfs_read_impl(void* cookie, lh_off_t pos, void* buffer, lh_size_t*
extern int lklfs_write_impl(void* cookie, lh_off_t pos, const void* buffer, lh_size_t* length);
extern int lklfs_sync_impl(void);
extern int lklfs_get_mode(void* vol_, lklfs_vnode* vnode, int* _type);
extern int lklfs_create_impl(void * vol_, lklfs_vnode* dir, const char* name,
int lhOpenMode, int perms, void ** cookie_);


#endif // LKL_HAIKU_BRIDGE_H__
11 changes: 7 additions & 4 deletions src/add-ons/kernel/file_systems/lklhaikufs/lklfs_vnode_ops.c
Expand Up @@ -232,12 +232,14 @@ static status_t
lklfs_create(fs_volume* volume, fs_vnode* dir, const char* name,
int openMode, int perms, void** _cookie, ino_t* _newVnodeID)
{
int rc = lklfs_open_impl(volume->private_volume, dir->private_node,
haiku_to_lh_openMode(openMode | O_CREAT), perms, _cookie);
if (rc != 0)
int rc = lklfs_create_impl(volume->private_volume, dir->private_node,
name, haiku_to_lh_openMode(openMode), perms, _cookie);
if (rc != 0) {
//dprintf("lklfs_create_impl returned rc=%d\n", rc);
return lh_to_haiku_error(-rc);
}

return lklfs_lookup(volume, dir, name, _newVnodeID);
return lklfs_lookup(volume, dir, name, _newVnodeID);
}


Expand Down Expand Up @@ -339,6 +341,7 @@ lklfs_write(fs_volume* volume, fs_vnode* vnode, void* cookie,
return B_NO_MEMORY;

memcpy(kernBuff, buffer, *length);
dprintf("lklfs_write cookie(=fd)=%d pos=%d *length=%d\n", (int)cookie, (int)pos, (int)*length);
rc = lklfs_write_impl(cookie, pos, kernBuff, length);
free(kernBuff);

Expand Down
42 changes: 40 additions & 2 deletions src/add-ons/kernel/file_systems/lklhaikufs/wrap_lkl.c
Expand Up @@ -397,16 +397,54 @@ lklfs_open_impl(void * vol_, lklfs_vnode* vnode, int lhOpenMode, int mode, void
fd = lkl_sys_open(abs_path, lklOpenMode, mode);
// don't need to worry about the permission bits as this
// will never create new files.
free(abs_path);
if (fd < 0)
free(abs_path); // TODO: FIXME
if (fd < 0) {
//dprintf("lklfs_open_impl(%s):: fd=%d\n", abs_path, fd);
return fd;
}

*cookie_ = (void*) fd;

return 0;
}


int
lklfs_create_impl(void * vol_, lklfs_vnode* dir, const char* name,
int lhOpenMode, int perms, void ** cookie_)
{
int fd;
int lklOpenMode = lh_to_lkl_openMode(lhOpenMode) | O_CREAT;
char* dir_path = vnode_to_abs_path(vol_, dir);
if (dir_path == NULL)
return -ENOMEM;

lh_size_t len = strlen(dir_path) + strlen(name) + 2;
char* file_path = malloc(len);
if (file_path == NULL) {
free(dir_path);
return -ENOMEM;
}

snprintf(file_path, len, "%s/%s", dir_path, name);
free(dir_path);

//dprintf("lklfs_create_impl(%s) lklOpenMode=%d perms=%d\n", file_path, lklOpenMode, perms);
fd = lkl_sys_open(file_path, lklOpenMode, perms);
// don't need to worry about the permission bits as this
// will never create new files.
free(file_path); // TODO: FIXME
if (fd < 0) {
//dprintf("lklfs_create_impl(%s):: fd=%d\n", file_path, fd);
return fd;
}

*cookie_ = (void*) fd;
//dprintf("lklfs_create_impl(%s) fd=%d\n", file_path, fd);
return 0;
}


int
lklfs_access_impl(void * vol_, lklfs_vnode* vnode, int accessMode)
{
Expand Down

0 comments on commit a8e73a0

Please sign in to comment.