* Fixed lots of warnings (there are still a lot left).
* Got rid of the PARAMS_AS_STRING stuff (it's always defined, anyway). * Will remove BeOS support, too, in the future. * Minor cleanup. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22644 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -17,9 +17,6 @@
|
|||||||
#include <ByteOrder.h>
|
#include <ByteOrder.h>
|
||||||
#include <netinet/udp.h>
|
#include <netinet/udp.h>
|
||||||
|
|
||||||
/* Haiku requires a string for mount params... */
|
|
||||||
#define PARAMS_AS_STRING 1
|
|
||||||
|
|
||||||
#ifndef UDP_SIZE_MAX
|
#ifndef UDP_SIZE_MAX
|
||||||
#define UDP_SIZE_MAX 65515
|
#define UDP_SIZE_MAX 65515
|
||||||
#endif
|
#endif
|
||||||
@@ -28,6 +25,8 @@
|
|||||||
/* declare gSocket and others */
|
/* declare gSocket and others */
|
||||||
KSOCKET_MODULE_DECL;
|
KSOCKET_MODULE_DECL;
|
||||||
|
|
||||||
|
static int fs_rmdir(fs_nspace *ns, fs_node *dir, const char *name);
|
||||||
|
|
||||||
/* *** configuration *** */
|
/* *** configuration *** */
|
||||||
|
|
||||||
//#define NFS_FS_FLAGS B_FS_IS_SHARED
|
//#define NFS_FS_FLAGS B_FS_IS_SHARED
|
||||||
@@ -60,7 +59,9 @@ bool conf_no_check_ip_xid = false;
|
|||||||
|
|
||||||
static vint32 refcount = 0; /* we only want to read the config once ? */
|
static vint32 refcount = 0; /* we only want to read the config once ? */
|
||||||
|
|
||||||
static status_t read_config(void)
|
|
||||||
|
static status_t
|
||||||
|
read_config(void)
|
||||||
{
|
{
|
||||||
void *handle;
|
void *handle;
|
||||||
const char *str, *endptr;
|
const char *str, *endptr;
|
||||||
@@ -102,7 +103,8 @@ static status_t read_config(void)
|
|||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
extern status_t
|
|
||||||
|
status_t
|
||||||
create_socket(fs_nspace *ns)
|
create_socket(fs_nspace *ns)
|
||||||
{
|
{
|
||||||
struct sockaddr_in addr;
|
struct sockaddr_in addr;
|
||||||
@@ -150,7 +152,9 @@ create_socket(fs_nspace *ns)
|
|||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
extern status_t
|
|
||||||
|
#if 0
|
||||||
|
static status_t
|
||||||
connect_socket(fs_nspace *ns)
|
connect_socket(fs_nspace *ns)
|
||||||
{
|
{
|
||||||
uint16 port = conf_high_port;
|
uint16 port = conf_high_port;
|
||||||
@@ -168,8 +172,10 @@ connect_socket(fs_nspace *ns)
|
|||||||
}
|
}
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
extern status_t
|
|
||||||
|
status_t
|
||||||
init_postoffice(fs_nspace *ns)
|
init_postoffice(fs_nspace *ns)
|
||||||
{
|
{
|
||||||
status_t result;
|
status_t result;
|
||||||
@@ -193,7 +199,8 @@ init_postoffice(fs_nspace *ns)
|
|||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
extern void
|
|
||||||
|
void
|
||||||
shutdown_postoffice(fs_nspace *ns)
|
shutdown_postoffice(fs_nspace *ns)
|
||||||
{
|
{
|
||||||
status_t result;
|
status_t result;
|
||||||
@@ -204,7 +211,8 @@ shutdown_postoffice(fs_nspace *ns)
|
|||||||
wait_for_thread (ns->tid,&result);
|
wait_for_thread (ns->tid,&result);
|
||||||
}
|
}
|
||||||
|
|
||||||
extern status_t
|
|
||||||
|
status_t
|
||||||
postoffice_func(fs_nspace *ns)
|
postoffice_func(fs_nspace *ns)
|
||||||
{
|
{
|
||||||
uint8 *buffer=(uint8 *)malloc(B_UDP_MAX_SIZE);
|
uint8 *buffer=(uint8 *)malloc(B_UDP_MAX_SIZE);
|
||||||
@@ -240,9 +248,10 @@ postoffice_func(fs_nspace *ns)
|
|||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8 *send_rpc_call (fs_nspace *ns, const struct sockaddr_in *addr,
|
|
||||||
int32 prog, int32 vers, int32 proc,
|
uint8 *
|
||||||
const struct XDROutPacket *packet)
|
send_rpc_call(fs_nspace *ns, const struct sockaddr_in *addr, int32 prog,
|
||||||
|
int32 vers, int32 proc, const struct XDROutPacket *packet)
|
||||||
{
|
{
|
||||||
int32 xid;
|
int32 xid;
|
||||||
size_t authSize;
|
size_t authSize;
|
||||||
@@ -290,29 +299,24 @@ uint8 *send_rpc_call (fs_nspace *ns, const struct sockaddr_in *addr,
|
|||||||
checksemstate(xid, pending->sem, 0);
|
checksemstate(xid, pending->sem, 0);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
do
|
do {
|
||||||
{
|
|
||||||
ssize_t bytes;
|
ssize_t bytes;
|
||||||
do
|
do {
|
||||||
{
|
|
||||||
bytes = ksendto(ns->s,(const void *)XDROutPacketBuffer(&rpc_call),
|
bytes = ksendto(ns->s,(const void *)XDROutPacketBuffer(&rpc_call),
|
||||||
XDROutPacketLength(&rpc_call), 0,
|
XDROutPacketLength(&rpc_call), 0,
|
||||||
(const struct sockaddr *)addr, sizeof(*addr));
|
(const struct sockaddr *)addr, sizeof(*addr));
|
||||||
}
|
}
|
||||||
while ((bytes<0)&&(errno==EINTR));
|
while (bytes < 0 && errno == EINTR);
|
||||||
|
|
||||||
do
|
do {
|
||||||
{
|
|
||||||
result = acquire_sem_etc (pending->sem,1,B_TIMEOUT,(retries)?(conf_call_timeout):(2*conf_call_timeout));
|
result = acquire_sem_etc (pending->sem,1,B_TIMEOUT,(retries)?(conf_call_timeout):(2*conf_call_timeout));
|
||||||
}
|
}
|
||||||
while (result == B_INTERRUPTED);
|
while (result == B_INTERRUPTED);
|
||||||
|
|
||||||
retries--;
|
retries--;
|
||||||
}
|
} while (result == B_TIMED_OUT && retries >= 0);
|
||||||
while ((result==B_TIMED_OUT)&&(retries>=0));
|
|
||||||
|
|
||||||
if (result>=B_OK)
|
if (result >= B_OK) {
|
||||||
{
|
|
||||||
uint8 *buffer = pending->buffer;
|
uint8 *buffer = pending->buffer;
|
||||||
pending->buffer = NULL;
|
pending->buffer = NULL;
|
||||||
SemaphorePoolPut(&ns->pendingCalls.fPool, pending->sem);
|
SemaphorePoolPut(&ns->pendingCalls.fPool, pending->sem);
|
||||||
@@ -365,7 +369,9 @@ uint8 *send_rpc_call (fs_nspace *ns, const struct sockaddr_in *addr,
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool is_successful_reply (struct XDRInPacket *reply)
|
|
||||||
|
bool
|
||||||
|
is_successful_reply(struct XDRInPacket *reply)
|
||||||
{
|
{
|
||||||
bool success = false;
|
bool success = false;
|
||||||
|
|
||||||
@@ -375,26 +381,20 @@ bool is_successful_reply (struct XDRInPacket *reply)
|
|||||||
(void)xid;
|
(void)xid;
|
||||||
(void)mtype;
|
(void)mtype;
|
||||||
|
|
||||||
if (replyStat==RPC_MSG_DENIED)
|
if (replyStat == RPC_MSG_DENIED) {
|
||||||
{
|
|
||||||
rpc_reject_stat rejectStat = (rpc_reject_stat)XDRInPacketGetInt32(reply);
|
rpc_reject_stat rejectStat = (rpc_reject_stat)XDRInPacketGetInt32(reply);
|
||||||
|
|
||||||
if (rejectStat==RPC_RPC_MISMATCH)
|
if (rejectStat == RPC_RPC_MISMATCH) {
|
||||||
{
|
|
||||||
int32 low=XDRInPacketGetInt32(reply);
|
int32 low=XDRInPacketGetInt32(reply);
|
||||||
int32 high=XDRInPacketGetInt32(reply);
|
int32 high=XDRInPacketGetInt32(reply);
|
||||||
|
|
||||||
kmessage ("RPC_MISMATCH (%ld,%ld)", low, high);
|
kmessage ("RPC_MISMATCH (%ld,%ld)", low, high);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
rpc_auth_stat authStat = (rpc_auth_stat)XDRInPacketGetInt32(reply);
|
rpc_auth_stat authStat = (rpc_auth_stat)XDRInPacketGetInt32(reply);
|
||||||
|
|
||||||
kmessage ("RPC_AUTH_ERROR (%d)", authStat);
|
kmessage ("RPC_AUTH_ERROR (%d)", authStat);
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
rpc_auth_flavor flavor = (rpc_auth_flavor)XDRInPacketGetInt32(reply);
|
rpc_auth_flavor flavor = (rpc_auth_flavor)XDRInPacketGetInt32(reply);
|
||||||
char body[400];
|
char body[400];
|
||||||
size_t bodyLength = XDRInPacketGetDynamic(reply, body);
|
size_t bodyLength = XDRInPacketGetDynamic(reply, body);
|
||||||
@@ -403,14 +403,12 @@ bool is_successful_reply (struct XDRInPacket *reply)
|
|||||||
(void)flavor;
|
(void)flavor;
|
||||||
(void)bodyLength;
|
(void)bodyLength;
|
||||||
|
|
||||||
if (acceptStat==RPC_PROG_MISMATCH)
|
if (acceptStat == RPC_PROG_MISMATCH) {
|
||||||
{
|
|
||||||
int32 low = XDRInPacketGetInt32(reply);
|
int32 low = XDRInPacketGetInt32(reply);
|
||||||
int32 high = XDRInPacketGetInt32(reply);
|
int32 high = XDRInPacketGetInt32(reply);
|
||||||
|
|
||||||
kmessage ("RPC_PROG_MISMATCH (%ld,%ld)", low, high);
|
kmessage ("RPC_PROG_MISMATCH (%ld,%ld)", low, high);
|
||||||
}
|
} else if (acceptStat != RPC_SUCCESS)
|
||||||
else if (acceptStat!=RPC_SUCCESS)
|
|
||||||
kmessage ("Accepted but failed (%d)", acceptStat);
|
kmessage ("Accepted but failed (%d)", acceptStat);
|
||||||
else
|
else
|
||||||
success = true;
|
success = true;
|
||||||
@@ -419,7 +417,10 @@ bool is_successful_reply (struct XDRInPacket *reply)
|
|||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
status_t get_remote_address (fs_nspace *ns, int32 prog, int32 vers, int32 prot, struct sockaddr_in *addr)
|
|
||||||
|
status_t
|
||||||
|
get_remote_address(fs_nspace *ns, int32 prog, int32 vers, int32 prot,
|
||||||
|
struct sockaddr_in *addr)
|
||||||
{
|
{
|
||||||
struct XDROutPacket call;
|
struct XDROutPacket call;
|
||||||
uint8 *replyBuf;
|
uint8 *replyBuf;
|
||||||
@@ -556,8 +557,9 @@ status_t nfs_lookup (fs_nspace *ns, const nfs_fhandle *dir, const char *filename
|
|||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
status_t nfs_getattr (fs_nspace *ns, const nfs_fhandle *fhandle,
|
|
||||||
struct stat *st)
|
status_t
|
||||||
|
nfs_getattr(fs_nspace *ns, const nfs_fhandle *fhandle, struct stat *st)
|
||||||
{
|
{
|
||||||
struct XDROutPacket call;
|
struct XDROutPacket call;
|
||||||
struct XDRInPacket reply;
|
struct XDRInPacket reply;
|
||||||
@@ -569,10 +571,9 @@ status_t nfs_getattr (fs_nspace *ns, const nfs_fhandle *fhandle,
|
|||||||
|
|
||||||
XDROutPacketAddFixed(&call, fhandle->opaque, NFS_FHSIZE);
|
XDROutPacketAddFixed(&call, fhandle->opaque, NFS_FHSIZE);
|
||||||
|
|
||||||
replyBuf=send_rpc_call (ns,&ns->nfsAddr,NFS_PROGRAM,NFS_VERSION,NFSPROC_GETATTR,&call);
|
replyBuf = send_rpc_call(ns, &ns->nfsAddr, NFS_PROGRAM, NFS_VERSION,
|
||||||
|
NFSPROC_GETATTR, &call);
|
||||||
if (!replyBuf)
|
if (replyBuf == NULL) {
|
||||||
{
|
|
||||||
XDRInPacketDestroy(&reply);
|
XDRInPacketDestroy(&reply);
|
||||||
XDROutPacketDestroy(&call);
|
XDROutPacketDestroy(&call);
|
||||||
return EHOSTUNREACH;
|
return EHOSTUNREACH;
|
||||||
@@ -580,17 +581,14 @@ status_t nfs_getattr (fs_nspace *ns, const nfs_fhandle *fhandle,
|
|||||||
|
|
||||||
XDRInPacketSetTo(&reply, replyBuf, 0);
|
XDRInPacketSetTo(&reply, replyBuf, 0);
|
||||||
|
|
||||||
if (!is_successful_reply(&reply))
|
if (!is_successful_reply(&reply)) {
|
||||||
{
|
|
||||||
XDRInPacketDestroy(&reply);
|
XDRInPacketDestroy(&reply);
|
||||||
XDROutPacketDestroy(&call);
|
XDROutPacketDestroy(&call);
|
||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
status = XDRInPacketGetInt32(&reply);
|
status = XDRInPacketGetInt32(&reply);
|
||||||
|
if (status != NFS_OK) {
|
||||||
if (status!=NFS_OK)
|
|
||||||
{
|
|
||||||
XDRInPacketDestroy(&reply);
|
XDRInPacketDestroy(&reply);
|
||||||
XDROutPacketDestroy(&call);
|
XDROutPacketDestroy(&call);
|
||||||
return map_nfs_to_system_error(status);
|
return map_nfs_to_system_error(status);
|
||||||
@@ -603,7 +601,8 @@ status_t nfs_getattr (fs_nspace *ns, const nfs_fhandle *fhandle,
|
|||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
extern status_t
|
|
||||||
|
status_t
|
||||||
nfs_truncate_file(fs_nspace *ns, const nfs_fhandle *fhandle, struct stat *st)
|
nfs_truncate_file(fs_nspace *ns, const nfs_fhandle *fhandle, struct stat *st)
|
||||||
{
|
{
|
||||||
struct XDROutPacket call;
|
struct XDROutPacket call;
|
||||||
@@ -625,10 +624,9 @@ nfs_truncate_file(fs_nspace *ns, const nfs_fhandle *fhandle, struct stat *st)
|
|||||||
XDROutPacketAddInt32(&call, time(NULL));
|
XDROutPacketAddInt32(&call, time(NULL));
|
||||||
XDROutPacketAddInt32(&call, 0);
|
XDROutPacketAddInt32(&call, 0);
|
||||||
|
|
||||||
replyBuf=send_rpc_call (ns,&ns->nfsAddr,NFS_PROGRAM,NFS_VERSION,NFSPROC_SETATTR,&call);
|
replyBuf = send_rpc_call(ns, &ns->nfsAddr, NFS_PROGRAM, NFS_VERSION,
|
||||||
|
NFSPROC_SETATTR, &call);
|
||||||
if (!replyBuf)
|
if (replyBuf == NULL) {
|
||||||
{
|
|
||||||
XDRInPacketDestroy(&reply);
|
XDRInPacketDestroy(&reply);
|
||||||
XDROutPacketDestroy(&call);
|
XDROutPacketDestroy(&call);
|
||||||
return EHOSTUNREACH;
|
return EHOSTUNREACH;
|
||||||
@@ -636,17 +634,14 @@ nfs_truncate_file(fs_nspace *ns, const nfs_fhandle *fhandle, struct stat *st)
|
|||||||
|
|
||||||
XDRInPacketSetTo(&reply, replyBuf, 0);
|
XDRInPacketSetTo(&reply, replyBuf, 0);
|
||||||
|
|
||||||
if (!is_successful_reply(&reply))
|
if (!is_successful_reply(&reply)) {
|
||||||
{
|
|
||||||
XDRInPacketDestroy(&reply);
|
XDRInPacketDestroy(&reply);
|
||||||
XDROutPacketDestroy(&call);
|
XDROutPacketDestroy(&call);
|
||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
status = XDRInPacketGetInt32(&reply);
|
status = XDRInPacketGetInt32(&reply);
|
||||||
|
if (status != NFS_OK) {
|
||||||
if (status!=NFS_OK)
|
|
||||||
{
|
|
||||||
XDRInPacketDestroy(&reply);
|
XDRInPacketDestroy(&reply);
|
||||||
XDROutPacketDestroy(&call);
|
XDROutPacketDestroy(&call);
|
||||||
return map_nfs_to_system_error(status);
|
return map_nfs_to_system_error(status);
|
||||||
@@ -660,7 +655,9 @@ nfs_truncate_file(fs_nspace *ns, const nfs_fhandle *fhandle, struct stat *st)
|
|||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
void get_nfs_attr (struct XDRInPacket *reply, struct stat *st)
|
|
||||||
|
void
|
||||||
|
get_nfs_attr(struct XDRInPacket *reply, struct stat *st)
|
||||||
{
|
{
|
||||||
nfs_ftype ftype=(nfs_ftype)XDRInPacketGetInt32(reply);
|
nfs_ftype ftype=(nfs_ftype)XDRInPacketGetInt32(reply);
|
||||||
(void) ftype;
|
(void) ftype;
|
||||||
@@ -689,10 +686,11 @@ void get_nfs_attr (struct XDRInPacket *reply, struct stat *st)
|
|||||||
XDRInPacketGetInt32(reply); // usecs
|
XDRInPacketGetInt32(reply); // usecs
|
||||||
}
|
}
|
||||||
|
|
||||||
status_t map_nfs_to_system_error (status_t nfsstatus)
|
|
||||||
{
|
status_t
|
||||||
switch (nfsstatus)
|
map_nfs_to_system_error(status_t nfsstatus)
|
||||||
{
|
{
|
||||||
|
switch (nfsstatus) {
|
||||||
case NFS_OK:
|
case NFS_OK:
|
||||||
return B_OK;
|
return B_OK;
|
||||||
|
|
||||||
@@ -746,7 +744,8 @@ status_t map_nfs_to_system_error (status_t nfsstatus)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
extern nfs_fhandle
|
|
||||||
|
nfs_fhandle
|
||||||
handle_from_vnid(fs_nspace *ns, ino_t vnid)
|
handle_from_vnid(fs_nspace *ns, ino_t vnid)
|
||||||
{
|
{
|
||||||
fs_node *current;
|
fs_node *current;
|
||||||
@@ -755,7 +754,7 @@ handle_from_vnid(fs_nspace *ns, ino_t vnid)
|
|||||||
|
|
||||||
current = ns->first;
|
current = ns->first;
|
||||||
|
|
||||||
while ((current)&&(current->vnid!=vnid))
|
while (current != NULL && current->vnid != vnid)
|
||||||
current = current->next;
|
current = current->next;
|
||||||
|
|
||||||
while (release_sem(ns->sem) == B_INTERRUPTED);
|
while (release_sem(ns->sem) == B_INTERRUPTED);
|
||||||
@@ -763,7 +762,9 @@ handle_from_vnid(fs_nspace *ns, ino_t vnid)
|
|||||||
return current->fhandle;
|
return current->fhandle;
|
||||||
}
|
}
|
||||||
|
|
||||||
void insert_node (fs_nspace *ns, fs_node *node)
|
|
||||||
|
void
|
||||||
|
insert_node(fs_nspace *ns, fs_node *node)
|
||||||
{
|
{
|
||||||
fs_node *current;
|
fs_node *current;
|
||||||
|
|
||||||
@@ -787,7 +788,9 @@ void insert_node (fs_nspace *ns, fs_node *node)
|
|||||||
while (release_sem (ns->sem)==B_INTERRUPTED);
|
while (release_sem (ns->sem)==B_INTERRUPTED);
|
||||||
}
|
}
|
||||||
|
|
||||||
void remove_node (fs_nspace *ns, ino_t vnid)
|
|
||||||
|
void
|
||||||
|
remove_node(fs_nspace *ns, ino_t vnid)
|
||||||
{
|
{
|
||||||
fs_node *current;
|
fs_node *current;
|
||||||
fs_node *previous;
|
fs_node *previous;
|
||||||
@@ -797,14 +800,12 @@ void remove_node (fs_nspace *ns, ino_t vnid)
|
|||||||
current=ns->first;
|
current=ns->first;
|
||||||
previous=NULL;
|
previous=NULL;
|
||||||
|
|
||||||
while ((current)&&(current->vnid!=vnid))
|
while (current != NULL && current->vnid != vnid) {
|
||||||
{
|
|
||||||
previous = current;
|
previous = current;
|
||||||
current = current->next;
|
current = current->next;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (current)
|
if (current) {
|
||||||
{
|
|
||||||
if (previous)
|
if (previous)
|
||||||
previous->next=current->next;
|
previous->next=current->next;
|
||||||
else
|
else
|
||||||
@@ -816,7 +817,11 @@ void remove_node (fs_nspace *ns, ino_t vnid)
|
|||||||
while (release_sem (ns->sem)==B_INTERRUPTED);
|
while (release_sem (ns->sem)==B_INTERRUPTED);
|
||||||
}
|
}
|
||||||
|
|
||||||
extern int
|
|
||||||
|
// #pragma mark -
|
||||||
|
|
||||||
|
|
||||||
|
static int
|
||||||
#ifdef __HAIKU__
|
#ifdef __HAIKU__
|
||||||
fs_read_vnode(fs_nspace *ns, ino_t vnid, fs_node **node, char r)
|
fs_read_vnode(fs_nspace *ns, ino_t vnid, fs_node **node, char r)
|
||||||
#else
|
#else
|
||||||
@@ -848,7 +853,8 @@ fs_read_vnode(fs_nspace *ns, ino_t vnid, char r, fs_node **node)
|
|||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
extern int
|
|
||||||
|
static int
|
||||||
#ifdef __HAIKU__
|
#ifdef __HAIKU__
|
||||||
fs_release_vnode(fs_nspace *ns, fs_node *node, char r)
|
fs_release_vnode(fs_nspace *ns, fs_node *node, char r)
|
||||||
#else
|
#else
|
||||||
@@ -861,19 +867,8 @@ fs_write_vnode(fs_nspace *ns, fs_node *node, char r)
|
|||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef __HAIKU__
|
|
||||||
/* no reason to do it,
|
|
||||||
* the VFS does it the best possible way for an unix fs anyway.
|
|
||||||
* so we use NULL for this call.
|
|
||||||
*/
|
|
||||||
extern int
|
|
||||||
fs_get_vnode_name(fs_nspace *ns, fs_node *node, char *buffer, size_t len)
|
|
||||||
{
|
|
||||||
return ENOSYS;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
extern int
|
static int
|
||||||
#ifdef __HAIKU__
|
#ifdef __HAIKU__
|
||||||
fs_walk(fs_nspace *ns, fs_node *base, const char *file, ino_t *vnid, int *type)
|
fs_walk(fs_nspace *ns, fs_node *base, const char *file, ino_t *vnid, int *type)
|
||||||
#else
|
#else
|
||||||
@@ -947,7 +942,8 @@ fs_walk(fs_nspace *ns, fs_node *base, const char *file, char **newpath, ino_t *v
|
|||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
extern int
|
|
||||||
|
static int
|
||||||
fs_opendir(fs_nspace *ns, fs_node *node, nfs_cookie **cookie)
|
fs_opendir(fs_nspace *ns, fs_node *node, nfs_cookie **cookie)
|
||||||
{
|
{
|
||||||
struct stat st;
|
struct stat st;
|
||||||
@@ -965,7 +961,8 @@ fs_opendir(fs_nspace *ns, fs_node *node, nfs_cookie **cookie)
|
|||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
extern int
|
|
||||||
|
static int
|
||||||
fs_closedir(fs_nspace *ns, fs_node *node, nfs_cookie *cookie)
|
fs_closedir(fs_nspace *ns, fs_node *node, nfs_cookie *cookie)
|
||||||
{
|
{
|
||||||
(void) ns;
|
(void) ns;
|
||||||
@@ -974,7 +971,8 @@ fs_closedir(fs_nspace *ns, fs_node *node, nfs_cookie *cookie)
|
|||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
extern int
|
|
||||||
|
static int
|
||||||
fs_rewinddir(fs_nspace *ns, fs_node *node, nfs_cookie *cookie)
|
fs_rewinddir(fs_nspace *ns, fs_node *node, nfs_cookie *cookie)
|
||||||
{
|
{
|
||||||
(void) ns;
|
(void) ns;
|
||||||
@@ -984,7 +982,8 @@ fs_rewinddir(fs_nspace *ns, fs_node *node, nfs_cookie *cookie)
|
|||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
extern int
|
|
||||||
|
static int
|
||||||
#ifdef __HAIKU__
|
#ifdef __HAIKU__
|
||||||
fs_readdir(fs_nspace *ns, fs_node *node, nfs_cookie *cookie, struct dirent *buf, size_t bufsize, uint32 *num)
|
fs_readdir(fs_nspace *ns, fs_node *node, nfs_cookie *cookie, struct dirent *buf, size_t bufsize, uint32 *num)
|
||||||
#else
|
#else
|
||||||
@@ -1118,7 +1117,8 @@ fs_readdir(fs_nspace *ns, fs_node *node, nfs_cookie *cookie, long *num, struct d
|
|||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
extern int
|
|
||||||
|
static int
|
||||||
fs_free_dircookie(fs_nspace *ns, fs_node *node, nfs_cookie *cookie)
|
fs_free_dircookie(fs_nspace *ns, fs_node *node, nfs_cookie *cookie)
|
||||||
{
|
{
|
||||||
(void) ns;
|
(void) ns;
|
||||||
@@ -1127,7 +1127,8 @@ fs_free_dircookie(fs_nspace *ns, fs_node *node, nfs_cookie *cookie)
|
|||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
extern int
|
|
||||||
|
static int
|
||||||
fs_rstat(fs_nspace *ns, fs_node *node, struct stat *st)
|
fs_rstat(fs_nspace *ns, fs_node *node, struct stat *st)
|
||||||
{
|
{
|
||||||
status_t result;
|
status_t result;
|
||||||
@@ -1140,20 +1141,23 @@ fs_rstat(fs_nspace *ns, fs_node *node, struct stat *st)
|
|||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
extern void
|
|
||||||
|
void
|
||||||
fs_nspaceInit(struct fs_nspace *nspace)
|
fs_nspaceInit(struct fs_nspace *nspace)
|
||||||
{
|
{
|
||||||
RPCPendingCallsInit (&nspace->pendingCalls);
|
RPCPendingCallsInit (&nspace->pendingCalls);
|
||||||
}
|
}
|
||||||
|
|
||||||
extern void
|
|
||||||
|
void
|
||||||
fs_nspaceDestroy(struct fs_nspace *nspace)
|
fs_nspaceDestroy(struct fs_nspace *nspace)
|
||||||
{
|
{
|
||||||
RPCPendingCallsDestroy (&nspace->pendingCalls);
|
RPCPendingCallsDestroy (&nspace->pendingCalls);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef PARAMS_AS_STRING
|
|
||||||
int parse_nfs_params(const char *str, struct mount_nfs_params *params)
|
static int
|
||||||
|
parse_nfs_params(const char *str, struct mount_nfs_params *params)
|
||||||
{
|
{
|
||||||
const char *p, *e;
|
const char *p, *e;
|
||||||
long v;
|
long v;
|
||||||
@@ -1237,18 +1241,17 @@ dprintf("nfs:gid!\n");
|
|||||||
params->hostname, params->uid, params->gid);
|
params->hostname, params->uid, params->gid);
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
extern int
|
|
||||||
|
static int
|
||||||
#ifdef __HAIKU__
|
#ifdef __HAIKU__
|
||||||
fs_mount(nspace_id nsid, const char *devname, uint32 flags, const char *_parms, fs_nspace **data, ino_t *vnid)
|
fs_mount(dev_t nsid, const char *devname, uint32 flags, const char *_parms,
|
||||||
|
fs_volume *_data, ino_t *vnid)
|
||||||
#else
|
#else
|
||||||
fs_mount(nspace_id nsid, const char *devname, ulong flags, const char *_parms, size_t len, fs_nspace **data, ino_t *vnid)
|
fs_mount(nspace_id nsid, const char *devname, ulong flags, const char *_parms,
|
||||||
|
size_t len, fs_nspace **_data, ino_t *vnid)
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
#ifndef PARAMS_AS_STRING
|
|
||||||
struct mount_nfs_params *parms = (struct mount_nfs_params *)_parms; // XXX: FIXME
|
|
||||||
#endif
|
|
||||||
status_t result;
|
status_t result;
|
||||||
fs_nspace *ns;
|
fs_nspace *ns;
|
||||||
fs_node *rootNode;
|
fs_node *rootNode;
|
||||||
@@ -1261,17 +1264,7 @@ fs_mount(nspace_id nsid, const char *devname, ulong flags, const char *_parms, s
|
|||||||
return EINVAL;
|
return EINVAL;
|
||||||
|
|
||||||
dprintf("nfs: mount(%ld, %s, %08lx)\n", nsid, devname, flags);
|
dprintf("nfs: mount(%ld, %s, %08lx)\n", nsid, devname, flags);
|
||||||
#ifndef PARAMS_AS_STRING
|
|
||||||
dprintf("nfs: nfs_params(ip:%lu, server:%s, export:%s, uid:%d, gid:%d, hostname:%s)\n",
|
|
||||||
parms->serverIP,
|
|
||||||
parms->server,
|
|
||||||
parms->_export,
|
|
||||||
parms->uid,
|
|
||||||
parms->gid,
|
|
||||||
parms->hostname);
|
|
||||||
#else
|
|
||||||
dprintf("nfs: nfs_params: %s\n", _parms);
|
dprintf("nfs: nfs_params: %s\n", _parms);
|
||||||
#endif
|
|
||||||
|
|
||||||
// HAIKU: this should go to std_ops
|
// HAIKU: this should go to std_ops
|
||||||
if (!refcount)
|
if (!refcount)
|
||||||
@@ -1292,17 +1285,8 @@ dprintf("nfs: nfs_params: %s\n", _parms);
|
|||||||
ns->params.server = NULL;
|
ns->params.server = NULL;
|
||||||
ns->params._export = NULL;
|
ns->params._export = NULL;
|
||||||
ns->params.hostname = NULL;
|
ns->params.hostname = NULL;
|
||||||
#ifdef PARAMS_AS_STRING
|
|
||||||
if ((result = parse_nfs_params(_parms, &ns->params)) < 0)
|
if ((result = parse_nfs_params(_parms, &ns->params)) < 0)
|
||||||
goto err_params;
|
goto err_params;
|
||||||
#else
|
|
||||||
ns->params.serverIP=parms->serverIP;
|
|
||||||
ns->params.server=strdup(parms->server);
|
|
||||||
ns->params._export=strdup(parms->_export);
|
|
||||||
ns->params.uid=parms->uid;
|
|
||||||
ns->params.gid=parms->gid;
|
|
||||||
ns->params.hostname=strdup(parms->hostname);
|
|
||||||
#endif
|
|
||||||
ns->xid = 0;
|
ns->xid = 0;
|
||||||
ns->mountAddr.sin_family = AF_INET;
|
ns->mountAddr.sin_family = AF_INET;
|
||||||
ns->mountAddr.sin_addr.s_addr = htonl(ns->params.serverIP);
|
ns->mountAddr.sin_addr.s_addr = htonl(ns->params.serverIP);
|
||||||
@@ -1314,15 +1298,17 @@ dprintf("nfs: nfs_params: %s\n", _parms);
|
|||||||
if ((result = init_postoffice(ns)) < B_OK)
|
if ((result = init_postoffice(ns)) < B_OK)
|
||||||
goto err_postoffice;
|
goto err_postoffice;
|
||||||
|
|
||||||
if ((result=get_remote_address(ns,MOUNT_PROGRAM,MOUNT_VERSION,PMAP_IPPROTO_UDP,&ns->mountAddr))<B_OK)
|
if ((result = get_remote_address(ns, MOUNT_PROGRAM, MOUNT_VERSION,
|
||||||
|
PMAP_IPPROTO_UDP, &ns->mountAddr)) < B_OK)
|
||||||
goto err_sem;
|
goto err_sem;
|
||||||
|
|
||||||
memcpy(&ns->nfsAddr, &ns->mountAddr, sizeof(ns->mountAddr));
|
memcpy(&ns->nfsAddr, &ns->mountAddr, sizeof(ns->mountAddr));
|
||||||
dprintf("nfs: mountd at %08lx:%d\n", ns->mountAddr.sin_addr.s_addr, ntohs(ns->mountAddr.sin_port));
|
dprintf("nfs: mountd at %08x:%d\n", ns->mountAddr.sin_addr.s_addr, ntohs(ns->mountAddr.sin_port));
|
||||||
|
|
||||||
if ((result=get_remote_address(ns,NFS_PROGRAM,NFS_VERSION,PMAP_IPPROTO_UDP,&ns->nfsAddr))<B_OK)
|
if ((result = get_remote_address(ns, NFS_PROGRAM, NFS_VERSION,
|
||||||
|
PMAP_IPPROTO_UDP, &ns->nfsAddr)) < B_OK)
|
||||||
goto err_sem;
|
goto err_sem;
|
||||||
dprintf("nfs: nfsd at %08lx:%d\n", ns->nfsAddr.sin_addr.s_addr, ntohs(ns->nfsAddr.sin_port));
|
dprintf("nfs: nfsd at %08x:%d\n", ns->nfsAddr.sin_addr.s_addr, ntohs(ns->nfsAddr.sin_port));
|
||||||
// result = connect_socket(ns);
|
// result = connect_socket(ns);
|
||||||
//dprintf("nfs: connect: %s\n", strerror(result));
|
//dprintf("nfs: connect: %s\n", strerror(result));
|
||||||
|
|
||||||
@@ -1353,7 +1339,7 @@ dprintf("nfs: nfsd at %08lx:%d\n", ns->nfsAddr.sin_addr.s_addr, ntohs(ns->nfsAdd
|
|||||||
if ((result = publish_vnode(nsid, *vnid, rootNode)) < B_OK)
|
if ((result = publish_vnode(nsid, *vnid, rootNode)) < B_OK)
|
||||||
goto err_publish;
|
goto err_publish;
|
||||||
|
|
||||||
*data=ns;
|
*_data = ns;
|
||||||
|
|
||||||
ns->first=rootNode;
|
ns->first=rootNode;
|
||||||
|
|
||||||
@@ -1389,15 +1375,16 @@ err_nspace:
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
extern int
|
|
||||||
fs_unmount(fs_nspace *ns)
|
static int
|
||||||
|
fs_unmount(fs_volume _volume)
|
||||||
{
|
{
|
||||||
|
fs_nspace *ns = (fs_nspace *)_volume;
|
||||||
free(ns->params.hostname);
|
free(ns->params.hostname);
|
||||||
free(ns->params._export);
|
free(ns->params._export);
|
||||||
free(ns->params.server);
|
free(ns->params.server);
|
||||||
|
|
||||||
while (ns->first)
|
while (ns->first) {
|
||||||
{
|
|
||||||
fs_node *next = ns->first->next;
|
fs_node *next = ns->first->next;
|
||||||
free(ns->first);
|
free(ns->first);
|
||||||
ns->first = next;
|
ns->first = next;
|
||||||
@@ -1416,7 +1403,8 @@ fs_unmount(fs_nspace *ns)
|
|||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
extern int
|
|
||||||
|
static int
|
||||||
fs_rfsstat(fs_nspace *ns, struct fs_info *info)
|
fs_rfsstat(fs_nspace *ns, struct fs_info *info)
|
||||||
{
|
{
|
||||||
struct XDROutPacket call;
|
struct XDROutPacket call;
|
||||||
@@ -1431,10 +1419,9 @@ fs_rfsstat(fs_nspace *ns, struct fs_info *info)
|
|||||||
|
|
||||||
XDROutPacketAddFixed(&call, rootHandle.opaque, NFS_FHSIZE);
|
XDROutPacketAddFixed(&call, rootHandle.opaque, NFS_FHSIZE);
|
||||||
|
|
||||||
replyBuf=send_rpc_call (ns,&ns->nfsAddr,NFS_PROGRAM,NFS_VERSION,NFSPROC_STATFS,&call);
|
replyBuf = send_rpc_call(ns, &ns->nfsAddr, NFS_PROGRAM, NFS_VERSION,
|
||||||
|
NFSPROC_STATFS, &call);
|
||||||
if (!replyBuf)
|
if (replyBuf == NULL) {
|
||||||
{
|
|
||||||
XDRInPacketDestroy(&reply);
|
XDRInPacketDestroy(&reply);
|
||||||
XDROutPacketDestroy(&call);
|
XDROutPacketDestroy(&call);
|
||||||
return EHOSTUNREACH;
|
return EHOSTUNREACH;
|
||||||
@@ -1442,17 +1429,14 @@ fs_rfsstat(fs_nspace *ns, struct fs_info *info)
|
|||||||
|
|
||||||
XDRInPacketSetTo(&reply, replyBuf, 0);
|
XDRInPacketSetTo(&reply, replyBuf, 0);
|
||||||
|
|
||||||
if (!is_successful_reply(&reply))
|
if (!is_successful_reply(&reply)) {
|
||||||
{
|
|
||||||
XDRInPacketDestroy(&reply);
|
XDRInPacketDestroy(&reply);
|
||||||
XDROutPacketDestroy(&call);
|
XDROutPacketDestroy(&call);
|
||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
status = XDRInPacketGetInt32(&reply);
|
status = XDRInPacketGetInt32(&reply);
|
||||||
|
if (status != NFS_OK) {
|
||||||
if (status!=NFS_OK)
|
|
||||||
{
|
|
||||||
XDRInPacketDestroy(&reply);
|
XDRInPacketDestroy(&reply);
|
||||||
XDROutPacketDestroy(&call);
|
XDROutPacketDestroy(&call);
|
||||||
//dprintf("nfs: rfsstat() error 0x%08lx\n", map_nfs_to_system_error(status));
|
//dprintf("nfs: rfsstat() error 0x%08lx\n", map_nfs_to_system_error(status));
|
||||||
@@ -1471,12 +1455,9 @@ fs_rfsstat(fs_nspace *ns, struct fs_info *info)
|
|||||||
info->free_blocks = XDRInPacketGetInt32(&reply);
|
info->free_blocks = XDRInPacketGetInt32(&reply);
|
||||||
info->total_nodes = 100;
|
info->total_nodes = 100;
|
||||||
info->free_nodes = 100;
|
info->free_nodes = 100;
|
||||||
//strcpy (info->device_name,"nfs_device");
|
|
||||||
strcpy (info->device_name,"");
|
|
||||||
strcpy(info->volume_name, "nfs://");
|
strcpy(info->volume_name, "nfs://");
|
||||||
strcat(info->volume_name, ns->params.server);
|
strcat(info->volume_name, ns->params.server);
|
||||||
strcat(info->volume_name, ns->params._export);
|
strcat(info->volume_name, ns->params._export);
|
||||||
//strcpy (info->fsh_name,"nfs_fsh");
|
|
||||||
strcpy(info->fsh_name, "nfs");
|
strcpy(info->fsh_name, "nfs");
|
||||||
|
|
||||||
XDRInPacketDestroy(&reply);
|
XDRInPacketDestroy(&reply);
|
||||||
@@ -1484,7 +1465,8 @@ fs_rfsstat(fs_nspace *ns, struct fs_info *info)
|
|||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
extern int
|
|
||||||
|
static int
|
||||||
fs_open(fs_nspace *ns, fs_node *node, int omode, fs_file_cookie **cookie)
|
fs_open(fs_nspace *ns, fs_node *node, int omode, fs_file_cookie **cookie)
|
||||||
{
|
{
|
||||||
struct stat st;
|
struct stat st;
|
||||||
@@ -1510,7 +1492,8 @@ fs_open(fs_nspace *ns, fs_node *node, int omode, fs_file_cookie **cookie)
|
|||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
extern int
|
|
||||||
|
static int
|
||||||
fs_close(fs_nspace *ns, fs_node *node, fs_file_cookie *cookie)
|
fs_close(fs_nspace *ns, fs_node *node, fs_file_cookie *cookie)
|
||||||
{
|
{
|
||||||
(void) ns;
|
(void) ns;
|
||||||
@@ -1523,33 +1506,33 @@ fs_close(fs_nspace *ns, fs_node *node, fs_file_cookie *cookie)
|
|||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
extern int
|
|
||||||
|
static int
|
||||||
fs_free_cookie(fs_nspace *ns, fs_node *node, fs_file_cookie *cookie)
|
fs_free_cookie(fs_nspace *ns, fs_node *node, fs_file_cookie *cookie)
|
||||||
{
|
{
|
||||||
(void) ns;
|
(void) ns;
|
||||||
(void) node;
|
(void) node;
|
||||||
if (cookie)
|
|
||||||
free(cookie);
|
free(cookie);
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
extern int
|
|
||||||
fs_read(fs_nspace *ns, fs_node *node, fs_file_cookie *cookie, off_t pos, void *buf, size_t *len)
|
static int
|
||||||
|
fs_read(fs_nspace *ns, fs_node *node, fs_file_cookie *cookie, off_t pos,
|
||||||
|
void *buf, size_t *len)
|
||||||
{
|
{
|
||||||
size_t max = *len;
|
size_t max = *len;
|
||||||
*len = 0;
|
*len = 0;
|
||||||
|
|
||||||
if (!cookie) return EISDIR; /* do not permit reading of directories */
|
if (!cookie)
|
||||||
while ((*len)<max)
|
return EISDIR; /* do not permit reading of directories */
|
||||||
{
|
|
||||||
size_t count=min_c(NFS_MAXDATA,max-(*len));
|
|
||||||
|
|
||||||
|
while ((*len) < max) {
|
||||||
|
size_t count = min_c(NFS_MAXDATA, max-(*len));
|
||||||
struct XDROutPacket call;
|
struct XDROutPacket call;
|
||||||
struct XDRInPacket reply;
|
struct XDRInPacket reply;
|
||||||
|
|
||||||
int32 status;
|
int32 status;
|
||||||
uint8 *replyBuf;
|
uint8 *replyBuf;
|
||||||
|
|
||||||
struct stat st;
|
struct stat st;
|
||||||
size_t readbytes;
|
size_t readbytes;
|
||||||
|
|
||||||
@@ -1561,10 +1544,9 @@ fs_read(fs_nspace *ns, fs_node *node, fs_file_cookie *cookie, off_t pos, void *b
|
|||||||
XDROutPacketAddInt32(&call, count);
|
XDROutPacketAddInt32(&call, count);
|
||||||
XDROutPacketAddInt32(&call, 0);
|
XDROutPacketAddInt32(&call, 0);
|
||||||
|
|
||||||
replyBuf=send_rpc_call (ns,&ns->nfsAddr,NFS_PROGRAM,NFS_VERSION,NFSPROC_READ,&call);
|
replyBuf = send_rpc_call(ns, &ns->nfsAddr, NFS_PROGRAM, NFS_VERSION,
|
||||||
|
NFSPROC_READ, &call);
|
||||||
if (!replyBuf)
|
if (replyBuf == NULL) {
|
||||||
{
|
|
||||||
XDRInPacketDestroy(&reply);
|
XDRInPacketDestroy(&reply);
|
||||||
XDROutPacketDestroy(&call);
|
XDROutPacketDestroy(&call);
|
||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
@@ -1572,24 +1554,20 @@ fs_read(fs_nspace *ns, fs_node *node, fs_file_cookie *cookie, off_t pos, void *b
|
|||||||
|
|
||||||
XDRInPacketSetTo(&reply, replyBuf, 0);
|
XDRInPacketSetTo(&reply, replyBuf, 0);
|
||||||
|
|
||||||
if (!is_successful_reply(&reply))
|
if (!is_successful_reply(&reply)) {
|
||||||
{
|
|
||||||
XDRInPacketDestroy(&reply);
|
XDRInPacketDestroy(&reply);
|
||||||
XDROutPacketDestroy(&call);
|
XDROutPacketDestroy(&call);
|
||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
status = XDRInPacketGetInt32(&reply);
|
status = XDRInPacketGetInt32(&reply);
|
||||||
|
if (status != NFS_OK) {
|
||||||
if (status!=NFS_OK)
|
|
||||||
{
|
|
||||||
XDRInPacketDestroy(&reply);
|
XDRInPacketDestroy(&reply);
|
||||||
XDROutPacketDestroy(&call);
|
XDROutPacketDestroy(&call);
|
||||||
return map_nfs_to_system_error(status);
|
return map_nfs_to_system_error(status);
|
||||||
}
|
}
|
||||||
|
|
||||||
get_nfs_attr(&reply, &st);
|
get_nfs_attr(&reply, &st);
|
||||||
|
|
||||||
cookie->st = st;
|
cookie->st = st;
|
||||||
|
|
||||||
readbytes = XDRInPacketGetDynamic(&reply, buf);
|
readbytes = XDRInPacketGetDynamic(&reply, buf);
|
||||||
@@ -1598,31 +1576,29 @@ fs_read(fs_nspace *ns, fs_node *node, fs_file_cookie *cookie, off_t pos, void *b
|
|||||||
(*len) += readbytes;
|
(*len) += readbytes;
|
||||||
pos += readbytes;
|
pos += readbytes;
|
||||||
|
|
||||||
if (pos>=st.st_size)
|
|
||||||
{
|
|
||||||
XDRInPacketDestroy(&reply);
|
XDRInPacketDestroy(&reply);
|
||||||
XDROutPacketDestroy(&call);
|
XDROutPacketDestroy(&call);
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
XDRInPacketDestroy (&reply);
|
if (pos >= st.st_size)
|
||||||
XDROutPacketDestroy (&call);
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
extern int
|
|
||||||
fs_write(fs_nspace *ns, fs_node *node, fs_file_cookie *cookie, off_t pos, const void *buf, size_t *len)
|
static int
|
||||||
|
fs_write(fs_nspace *ns, fs_node *node, fs_file_cookie *cookie, off_t pos,
|
||||||
|
const void *buf, size_t *len)
|
||||||
{
|
{
|
||||||
size_t bytesWritten = 0;
|
size_t bytesWritten = 0;
|
||||||
|
|
||||||
if (!cookie) return EISDIR; /* do not permit reading of directories */
|
if (!cookie)
|
||||||
|
return EISDIR; /* do not permit reading of directories */
|
||||||
if (cookie->omode & O_APPEND)
|
if (cookie->omode & O_APPEND)
|
||||||
pos+=cookie->original_size;
|
pos+=cookie->original_size;
|
||||||
|
|
||||||
while (bytesWritten<*len)
|
while (bytesWritten < *len) {
|
||||||
{
|
|
||||||
size_t count=min_c(NFS_MAXDATA,(*len)-bytesWritten);
|
size_t count=min_c(NFS_MAXDATA,(*len)-bytesWritten);
|
||||||
|
|
||||||
struct XDROutPacket call;
|
struct XDROutPacket call;
|
||||||
@@ -1680,7 +1656,7 @@ fs_write(fs_nspace *ns, fs_node *node, fs_file_cookie *cookie, off_t pos, const
|
|||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
extern int
|
static int
|
||||||
fs_wstat(fs_nspace *ns, fs_node *node, struct stat *st, long mask)
|
fs_wstat(fs_nspace *ns, fs_node *node, struct stat *st, long mask)
|
||||||
{
|
{
|
||||||
struct XDROutPacket call;
|
struct XDROutPacket call;
|
||||||
@@ -1731,7 +1707,7 @@ fs_wstat(fs_nspace *ns, fs_node *node, struct stat *st, long mask)
|
|||||||
return my_notify_listener (B_STAT_CHANGED,ns->nsid,0,0,node->vnid,NULL);
|
return my_notify_listener (B_STAT_CHANGED,ns->nsid,0,0,node->vnid,NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
extern int
|
static int
|
||||||
fs_wfsstat(fs_nspace *ns, struct fs_info *info, long mask)
|
fs_wfsstat(fs_nspace *ns, struct fs_info *info, long mask)
|
||||||
{
|
{
|
||||||
(void) ns;
|
(void) ns;
|
||||||
@@ -1740,7 +1716,7 @@ fs_wfsstat(fs_nspace *ns, struct fs_info *info, long mask)
|
|||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
extern int
|
static int
|
||||||
#ifdef __HAIKU__
|
#ifdef __HAIKU__
|
||||||
fs_create(fs_nspace *ns, fs_node *dir, const char *name, int omode, int perms, fs_file_cookie **cookie, ino_t *vnid)
|
fs_create(fs_nspace *ns, fs_node *dir, const char *name, int omode, int perms, fs_file_cookie **cookie, ino_t *vnid)
|
||||||
#else
|
#else
|
||||||
@@ -1872,7 +1848,7 @@ fs_create(fs_nspace *ns, fs_node *dir, const char *name, int omode, int perms, i
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
extern int
|
static int
|
||||||
fs_unlink(fs_nspace *ns, fs_node *dir, const char *name)
|
fs_unlink(fs_nspace *ns, fs_node *dir, const char *name)
|
||||||
{
|
{
|
||||||
status_t result;
|
status_t result;
|
||||||
@@ -1968,7 +1944,7 @@ fs_unlink(fs_nspace *ns, fs_node *dir, const char *name)
|
|||||||
return my_notify_listener (B_ENTRY_REMOVED,ns->nsid,dir->vnid,0,st.st_ino,name);
|
return my_notify_listener (B_ENTRY_REMOVED,ns->nsid,dir->vnid,0,st.st_ino,name);
|
||||||
}
|
}
|
||||||
|
|
||||||
extern int
|
static int
|
||||||
fs_remove_vnode(fs_nspace *ns, fs_node *node, char r)
|
fs_remove_vnode(fs_nspace *ns, fs_node *node, char r)
|
||||||
{
|
{
|
||||||
(void) r;
|
(void) r;
|
||||||
@@ -1978,7 +1954,7 @@ fs_remove_vnode(fs_nspace *ns, fs_node *node, char r)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifndef __HAIKU__
|
#ifndef __HAIKU__
|
||||||
extern int
|
static int
|
||||||
fs_secure_vnode(fs_nspace *ns, fs_node *node)
|
fs_secure_vnode(fs_nspace *ns, fs_node *node)
|
||||||
{
|
{
|
||||||
(void) ns;
|
(void) ns;
|
||||||
@@ -1987,7 +1963,7 @@ fs_secure_vnode(fs_nspace *ns, fs_node *node)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
extern int
|
static int
|
||||||
fs_mkdir(fs_nspace *ns, fs_node *dir, const char *name, int perms)
|
fs_mkdir(fs_nspace *ns, fs_node *dir, const char *name, int perms)
|
||||||
{
|
{
|
||||||
nfs_fhandle fhandle;
|
nfs_fhandle fhandle;
|
||||||
@@ -2077,7 +2053,7 @@ fs_mkdir(fs_nspace *ns, fs_node *dir, const char *name, int perms)
|
|||||||
return my_notify_listener (B_ENTRY_CREATED,ns->nsid,dir->vnid,0,st.st_ino,name);
|
return my_notify_listener (B_ENTRY_CREATED,ns->nsid,dir->vnid,0,st.st_ino,name);
|
||||||
}
|
}
|
||||||
|
|
||||||
extern int
|
static int
|
||||||
fs_rename(fs_nspace *ns, fs_node *olddir, const char *oldname, fs_node *newdir, const char *newname)
|
fs_rename(fs_nspace *ns, fs_node *olddir, const char *oldname, fs_node *newdir, const char *newname)
|
||||||
{
|
{
|
||||||
struct stat st;
|
struct stat st;
|
||||||
@@ -2151,7 +2127,8 @@ fs_rename(fs_nspace *ns, fs_node *olddir, const char *oldname, fs_node *newdir,
|
|||||||
return my_notify_listener (B_ENTRY_MOVED,ns->nsid,olddir->vnid,newdir->vnid,st.st_ino,newname);
|
return my_notify_listener (B_ENTRY_MOVED,ns->nsid,olddir->vnid,newdir->vnid,st.st_ino,newname);
|
||||||
}
|
}
|
||||||
|
|
||||||
extern int
|
|
||||||
|
static int
|
||||||
fs_rmdir(fs_nspace *ns, fs_node *dir, const char *name)
|
fs_rmdir(fs_nspace *ns, fs_node *dir, const char *name)
|
||||||
{
|
{
|
||||||
status_t result;
|
status_t result;
|
||||||
@@ -2244,7 +2221,7 @@ fs_rmdir(fs_nspace *ns, fs_node *dir, const char *name)
|
|||||||
return my_notify_listener (B_ENTRY_REMOVED,ns->nsid,dir->vnid,0,st.st_ino,name);
|
return my_notify_listener (B_ENTRY_REMOVED,ns->nsid,dir->vnid,0,st.st_ino,name);
|
||||||
}
|
}
|
||||||
|
|
||||||
extern int
|
static int
|
||||||
fs_readlink(fs_nspace *ns, fs_node *node, char *buf, size_t *bufsize)
|
fs_readlink(fs_nspace *ns, fs_node *node, char *buf, size_t *bufsize)
|
||||||
{
|
{
|
||||||
struct XDROutPacket call;
|
struct XDROutPacket call;
|
||||||
@@ -2297,7 +2274,7 @@ fs_readlink(fs_nspace *ns, fs_node *node, char *buf, size_t *bufsize)
|
|||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
extern int
|
static int
|
||||||
#ifdef __HAIKU__
|
#ifdef __HAIKU__
|
||||||
fs_symlink(fs_nspace *ns, fs_node *dir, const char *name, const char *path, int mode)
|
fs_symlink(fs_nspace *ns, fs_node *dir, const char *name, const char *path, int mode)
|
||||||
#else
|
#else
|
||||||
@@ -2395,7 +2372,9 @@ fs_symlink(fs_nspace *ns, fs_node *dir, const char *name, const char *path)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
int fs_access(void *ns, void *node, int mode)
|
|
||||||
|
static int
|
||||||
|
fs_access(void *ns, void *node, int mode)
|
||||||
{
|
{
|
||||||
(void) ns;
|
(void) ns;
|
||||||
(void) node;
|
(void) node;
|
||||||
@@ -2404,6 +2383,7 @@ int fs_access(void *ns, void *node, int mode)
|
|||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#ifdef __HAIKU__
|
#ifdef __HAIKU__
|
||||||
|
|
||||||
static status_t
|
static status_t
|
||||||
@@ -2411,11 +2391,10 @@ nfs_std_ops(int32 op, ...)
|
|||||||
{
|
{
|
||||||
switch (op) {
|
switch (op) {
|
||||||
case B_MODULE_INIT:
|
case B_MODULE_INIT:
|
||||||
dprintf("nfs:std_ops(INIT)\n");
|
|
||||||
return B_OK;
|
return B_OK;
|
||||||
case B_MODULE_UNINIT:
|
case B_MODULE_UNINIT:
|
||||||
dprintf("nfs:std_ops(UNINIT)\n");
|
|
||||||
return B_OK;
|
return B_OK;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
}
|
}
|
||||||
@@ -2446,7 +2425,7 @@ static file_system_module_info sNFSModule = {
|
|||||||
|
|
||||||
/* vnode operations */
|
/* vnode operations */
|
||||||
&fs_walk,
|
&fs_walk,
|
||||||
NULL, // &fs_get_vnode_name,
|
NULL, // fs_get_vnode_name
|
||||||
&fs_read_vnode,
|
&fs_read_vnode,
|
||||||
&fs_release_vnode,
|
&fs_release_vnode,
|
||||||
&fs_remove_vnode,
|
&fs_remove_vnode,
|
||||||
@@ -2536,8 +2515,7 @@ module_info *modules[] = {
|
|||||||
NULL,
|
NULL,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#else // !__HAIKU__
|
||||||
#else
|
|
||||||
|
|
||||||
_EXPORT vnode_ops fs_entry =
|
_EXPORT vnode_ops fs_entry =
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
#ifndef _NFS_ADD_ON_H
|
#ifndef _NFS_ADD_ON_H
|
||||||
|
|
||||||
#define _NFS_ADD_ON_H
|
#define _NFS_ADD_ON_H
|
||||||
|
|
||||||
/* wrappers */
|
/* wrappers */
|
||||||
@@ -22,7 +21,6 @@ typedef dev_t nspace_id;
|
|||||||
typedef int socklen_t;
|
typedef int socklen_t;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#include "RPCPendingCalls.h"
|
#include "RPCPendingCalls.h"
|
||||||
#include "XDROutPacket.h"
|
#include "XDROutPacket.h"
|
||||||
#include "XDRInPacket.h"
|
#include "XDRInPacket.h"
|
||||||
@@ -32,8 +30,8 @@ typedef int socklen_t;
|
|||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <SupportDefs.h>
|
#include <SupportDefs.h>
|
||||||
|
|
||||||
struct mount_nfs_params
|
|
||||||
{
|
struct mount_nfs_params {
|
||||||
unsigned int serverIP;
|
unsigned int serverIP;
|
||||||
char *server;
|
char *server;
|
||||||
char *_export;
|
char *_export;
|
||||||
@@ -42,15 +40,13 @@ struct mount_nfs_params
|
|||||||
char *hostname;
|
char *hostname;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct fs_node
|
struct fs_node {
|
||||||
{
|
|
||||||
ino_t vnid;
|
ino_t vnid;
|
||||||
struct nfs_fhandle fhandle;
|
struct nfs_fhandle fhandle;
|
||||||
struct fs_node *next;
|
struct fs_node *next;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct fs_nspace
|
struct fs_nspace {
|
||||||
{
|
|
||||||
nspace_id nsid;
|
nspace_id nsid;
|
||||||
|
|
||||||
thread_id tid;
|
thread_id tid;
|
||||||
@@ -89,56 +85,6 @@ typedef struct nfs_cookie nfs_cookie;
|
|||||||
typedef struct fs_file_cookie fs_file_cookie;
|
typedef struct fs_file_cookie fs_file_cookie;
|
||||||
typedef struct nfs_fhandle nfs_fhandle;
|
typedef struct nfs_fhandle nfs_fhandle;
|
||||||
|
|
||||||
#if 0
|
|
||||||
int fs_read_vnode(fs_nspace *ns, ino_t vnid, char r, fs_node **node);
|
|
||||||
int fs_write_vnode(fs_nspace *ns, fs_node *node, char r);
|
|
||||||
|
|
||||||
int fs_walk(fs_nspace *ns, fs_node *base, const char *file, char **newpath,
|
|
||||||
ino_t *vnid);
|
|
||||||
|
|
||||||
int fs_opendir(fs_nspace *ns, fs_node *node, nfs_cookie **cookie);
|
|
||||||
int fs_closedir(fs_nspace *ns, fs_node *node, nfs_cookie *cookie);
|
|
||||||
int fs_rewinddir(fs_nspace *ns, fs_node *node, nfs_cookie *cookie);
|
|
||||||
int fs_readdir(fs_nspace *ns, fs_node *node, nfs_cookie *cookie, long *num,
|
|
||||||
struct dirent *buf, size_t bufsize);
|
|
||||||
|
|
||||||
int fs_free_dircookie(fs_nspace *ns, fs_node *node, nfs_cookie *cookie);
|
|
||||||
int fs_rstat(fs_nspace *ns, fs_node *node, struct stat *);
|
|
||||||
int fs_mount(nspace_id nsid, const char *devname, ulong flags,
|
|
||||||
struct mount_nfs_params *parms, size_t len, fs_nspace **data, ino_t *vnid);
|
|
||||||
int fs_unmount(fs_nspace *ns);
|
|
||||||
int fs_rfsstat(fs_nspace *ns, struct fs_info *);
|
|
||||||
|
|
||||||
int fs_open(fs_nspace *ns, fs_node *node, int omode, fs_file_cookie **cookie);
|
|
||||||
int fs_close(fs_nspace *ns, fs_node *node, fs_file_cookie *cookie);
|
|
||||||
int fs_free_cookie(fs_nspace *ns, fs_node *node, fs_file_cookie *cookie);
|
|
||||||
int fs_read(fs_nspace *ns, fs_node *node, fs_file_cookie *cookie, off_t pos, void *buf,
|
|
||||||
size_t *len);
|
|
||||||
|
|
||||||
int fs_write(fs_nspace *ns, fs_node *node, fs_file_cookie *cookie, off_t pos,
|
|
||||||
const void *buf, size_t *len);
|
|
||||||
|
|
||||||
int fs_wstat(fs_nspace *ns, fs_node *node, struct stat *, long mask);
|
|
||||||
int fs_wfsstat(fs_nspace *ns, struct fs_info *, long mask);
|
|
||||||
int fs_create(fs_nspace *ns, fs_node *dir, const char *name,
|
|
||||||
int omode, int perms, ino_t *vnid, fs_file_cookie **cookie);
|
|
||||||
|
|
||||||
int fs_unlink(fs_nspace *ns, fs_node *dir, const char *name);
|
|
||||||
int fs_remove_vnode(fs_nspace *ns, fs_node *node, char r);
|
|
||||||
int fs_secure_vnode(fs_nspace *ns, fs_node *node);
|
|
||||||
|
|
||||||
int fs_mkdir(fs_nspace *ns, fs_node *dir, const char *name, int perms);
|
|
||||||
|
|
||||||
int fs_rename(fs_nspace *ns, fs_node *olddir, const char *oldname,
|
|
||||||
fs_node *newdir, const char *newname);
|
|
||||||
|
|
||||||
int fs_rmdir(fs_nspace *ns, fs_node *dir, const char *name);
|
|
||||||
int fs_readlink(fs_nspace *ns, fs_node *node, char *buf, size_t *bufsize);
|
|
||||||
|
|
||||||
int fs_symlink(fs_nspace *ns, fs_node *dir, const char *name,
|
|
||||||
const char *path);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
status_t create_socket(fs_nspace *ns);
|
status_t create_socket(fs_nspace *ns);
|
||||||
status_t init_postoffice(fs_nspace *ns);
|
status_t init_postoffice(fs_nspace *ns);
|
||||||
void shutdown_postoffice(fs_nspace *ns);
|
void shutdown_postoffice(fs_nspace *ns);
|
||||||
@@ -159,13 +105,10 @@ extern status_t nfs_getattr(fs_nspace *ns, const nfs_fhandle *fhandle, struct st
|
|||||||
extern void insert_node(fs_nspace *ns, fs_node *node);
|
extern void insert_node(fs_nspace *ns, fs_node *node);
|
||||||
extern void remove_node(fs_nspace *ns, ino_t vnid);
|
extern void remove_node(fs_nspace *ns, ino_t vnid);
|
||||||
|
|
||||||
extern int fs_access(void *ns, void *node, int mode);
|
enum {
|
||||||
|
|
||||||
enum
|
|
||||||
{
|
|
||||||
C_ERROR_STALE = B_ERRORS_END + 1
|
C_ERROR_STALE = B_ERRORS_END + 1
|
||||||
};
|
};
|
||||||
|
|
||||||
#define USE_SYSTEM_AUTHENTICATION 1
|
#define USE_SYSTEM_AUTHENTICATION 1
|
||||||
|
|
||||||
#endif
|
#endif /* _NFS_ADD_ON_H */
|
||||||
|
|||||||
Reference in New Issue
Block a user