Пример #1
0
int hsi_nfs3_rmdir (struct hsfs_inode *parent, const char *name)
{
	struct hsfs_super *sb = parent->sb;
	int err = 0;
	diropargs3 argp;
	wccstat3 clnt_res;

	DEBUG_IN(" ino:%lu.\n", parent->ino);

	memset (&argp, 0, sizeof(diropargs3));
	memset (&clnt_res, 0, sizeof(wccstat3));
		
	argp.dir.data.data_len = parent->fh.data.data_len;
	argp.dir.data.data_val = parent->fh.data.data_val;
	argp.name = (char *) name;
		
	err = hsi_nfs3_clnt_call (sb, sb->clntp, NFSPROC3_RMDIR, 
			(xdrproc_t) xdr_diropargs3, (caddr_t) &argp,
			 (xdrproc_t) xdr_wccstat3, (caddr_t) &clnt_res);
		
	if (0 != err)
		goto out;
	
	err = hsi_nfs3_stat_to_errno(clnt_res.status); 	/*nfs error.*/
	clnt_freeres(sb->clntp, (xdrproc_t)xdr_wccstat3, (char *)&clnt_res);
out:
	DEBUG_OUT(" out, errno is(%d)\n", err);
	return err;
};
Пример #2
0
static void hsx_fuse_init_cap(struct hsfs_super *sb, struct fuse_conn_info *conn)
{
	char unsupported[1024] = "";
	int len;
	
	DEBUG_IN("Capable(0x%x)", conn->capable);
	(void)sb;	  /* Stop warning for some configuration... */
	
#ifdef FUSE_CAP_BIG_WRITES
	CHECK_CAP(FUSE_CAP_BIG_WRITES);
#endif
#ifdef FUSE_CAP_AUTO_INVAL_DATA
	CHECK_CAP(FUSE_CAP_AUTO_INVAL_DATA);
#endif
#ifdef FUSE_CAP_READDIR_PLUS
	CHECK_CAP(FUSE_CAP_READDIR_PLUS);
#endif
	
	len = strlen(unsupported);
	if (len){
		unsupported[len - 2] = '\0';
		WARNING("Your fuse has %s builtin while your kernel not.", unsupported);
	}
	
	DEBUG_OUT("Want(0x%x)", conn->capable);
}
Пример #3
0
int hsx_fuse_fill_reply (struct hsfs_inode *inode, struct fuse_entry_param *e)
{	
	DEBUG_IN(" ino %lu.\n", inode->ino);
	if(NULL == inode) {
		ERR("NULL POINTER in hsx_fuse_fill_reply");
		goto out;
	}
	if (0 == hsi_nfs3_fattr2stat(&(inode->attr), &(e->attr))) {
		e->ino = inode->ino;
		if (NF3REG == inode->attr.type) {
			e->attr_timeout = inode->sb->acregmin;
			e->entry_timeout = inode->sb->acregmax;
		}
		else if (NF3DIR == inode->attr.type) {
			e->attr_timeout = inode->sb->acdirmin;
			e->entry_timeout = inode->sb->acdirmax;
		}else {
			ERR("Error in get file type!\n");
			goto out;
		}
		DEBUG_OUT("OUT %s\n", "hsx_fuse_fill_reply");
		return 1;
	}else {
		ERR ("Error in fattr2stat\n");
	}

out:
	DEBUG_OUT("OUT ino %lu.\n", inode->ino);
	return 0;
}
Пример #4
0
void hsx_fuse_readdir_plus(fuse_req_t req, fuse_ino_t ino, size_t size, off_t off,
			   struct fuse_file_info *fi)
{
	struct hsfs_readdir_ctx *saved_ctx, *ctx = NULL;
	struct hsfs_inode *parent;
	struct hsfs_super *sb;
	size_t res, len = 0;
	char * buf;
	int err, count = 0;

	DEBUG_IN("P_I(%lu), Size(%lld), Off(0x%llx)", ino, size, off);

	(void)fi;
	sb = fuse_req_userdata(req);
	FUSE_ASSERT(sb != NULL);

	parent = hsfs_ilookup(sb, ino);
	FUSE_ASSERT(parent != NULL);

	err = hsi_nfs3_readdir_plus(parent, size, off, &ctx, size);
	if(err)
		goto out1;
	saved_ctx = ctx;

	buf = (char *) malloc(size);
	if( NULL == buf){
		err = ENOMEM;
		goto out2;
	}
	while(ctx != NULL){
		struct fuse_entry_param e;

		hsx_fuse_fill_reply(ctx->inode, &e);
		res = fuse_add_direntry_plus(req, buf + len, size - len, ctx->name,
					     &e, ctx->off);
	  	if(res > size - len)
			break;
		else if (res == size - len){
			ctx = ctx->next;
			break;
		}
		count++;
	       	hsx_fuse_ref_inc(ctx->inode, 1);
		len += res;
		ctx = ctx->next;
	}

	if (!err)
		fuse_reply_buf(req, buf, len);
	
	free(buf);
out2:
	__free_ctx(saved_ctx, 0);
out1:
	if(err)
		fuse_reply_err(req, err);

	DEBUG_OUT("with %d, %d entries returned", err, count);
	return;
}
Пример #5
0
int hsi_nfs3_access(struct hsfs_inode *hi, int mask)
{

	struct access3args args;
	struct access3res res;
	CLIENT *clntp = NULL;
	int status = 0;

	DEBUG_IN("MASK = %d", mask);

	memset(&args, 0, sizeof(struct access3args));
	memset(&res, 0, sizeof(struct access3res));

	hsi_nfs3_getfh3(hi, &args.object);

	args.access = mask & FULL_ACCESS;
	clntp = hi->sb->clntp;
	
	status = hsi_nfs3_clnt_call(hi->sb, clntp, NFSPROC3_ACCESS, 
			(xdrproc_t)xdr_access3args, (caddr_t)&args, 
			(xdrproc_t)xdr_access3res, (caddr_t)&res);
	if (status)
		goto out;
	
	status = hsi_nfs3_stat_to_errno(res.status);
out:
	clnt_freeres(clntp, (xdrproc_t)xdr_access3res, (caddr_t)&res);
	DEBUG_OUT("Out of hsi_nfs3_access, with STATUS = %d", status);
	return status;
}
Пример #6
0
/* return the next quoted block */
static obj_t *n_extractquote(nsp_state *N, cstate *state, unsigned short verbatim)
{
#define __FN__ __FILE__ ":n_extractquote()"
	obj_t *cobj;
	char q = *N->readptr;
	char *qs, *qe;
	obj_t tobj;
	int n;

	DEBUG_IN();
	settrace();
	sanetest();
	if ((q != '\'') && (q != '\"') && (q != '`')) {
		DEBUG_OUT();
		return NULL;
	}
	N->readptr++;
	qs = (char *)N->readptr;
	n_skipquote(N, q, state, verbatim);
	qe = (char *)N->readptr;

	if (verbatim) {
		cobj = nsp_setstr(N, &N->r, "", qs, qe - qs - 1);
	}
	else {
		nc_memset((void *)&tobj, 0, sizeof(obj_t));
		nsp_setstr(N, &tobj, "", NULL, qe - qs - 1);
		n = n_unescape(N, qs, tobj.val->d.str, qe - qs - 1, state);
		cobj = nsp_setstr(N, &N->r, "", tobj.val->d.str, n);
		nsp_unlinkval(N, &tobj);
	}
	DEBUG_OUT();
	return cobj;
#undef __FN__
}
Пример #7
0
void hsx_fuse_setxattr(fuse_req_t req, fuse_ino_t ino, const char *name, const
			char *value, size_t size, int flags _U_)
{
	struct hsfs_inode *hi = NULL;
	struct hsfs_super *sb = NULL;
	int type = 0;
	int err = 0;

	DEBUG_IN(" ino %lu.\n", ino);
	if ((sb = fuse_req_userdata(req)) == NULL) {
		ERR("ERR in fuse_req_userdata");
		goto out;
	}

	if ((hi = hsfs_ilookup(sb, ino)) == NULL) {
		ERR("ERR in hsfs_ilookup");
		goto out;
	}	
	
	if (strcmp(name, POSIX_ACL_XATTR_ACCESS) == 0)
		type = ACL_TYPE_ACCESS;
	else if (strcmp(name, POSIX_ACL_XATTR_DEFAULT) == 0)
		type = ACL_TYPE_DEFAULT;
	else
		goto out;
	
	err = hsi_nfs3_setxattr(hi, value, type, size);
	fuse_reply_err(req, err);

out:
	DEBUG_OUT("out,err: %d\n",err);
	fuse_reply_err(req, err);
	return;
}
Пример #8
0
int hsi_nfs3_fattr2stat(struct fattr3 *attr, struct stat *st)
{
	int err = 0;
	unsigned int type = 0;

	DEBUG_IN("%s", "\n");

	st->st_dev = makedev(0, 0); /* ignored now */
	st->st_ino = (ino_t) (attr->fileid);/*depend on 'use_ino' mount option*/
	type = (unsigned int) (attr->type);
	st->st_mode = (mode_t) (attr->mode & 07777);
	switch (type) {
		case NF3REG :
			st->st_mode |= S_IFREG;
			break;
		case NF3DIR :
			st->st_mode |= S_IFDIR;
			break;
		case NF3BLK :
			st->st_mode |= S_IFBLK;
			break;
		case NF3CHR :
			st->st_mode |= S_IFCHR;
			break;
		case NF3LNK :
			st->st_mode |= S_IFLNK;
			break;
		case NF3SOCK :
			st->st_mode |= S_IFSOCK;
			break;
		case NF3FIFO :
			st->st_mode |= S_IFIFO;
			break;
		default :
		  	err = EINVAL;
			goto out;
	}
	st->st_nlink = (nlink_t) (attr->nlink);
	st->st_uid = (uid_t) (attr->uid);
	st->st_gid = (gid_t) (attr->gid);
	st->st_rdev = makedev(attr->rdev.major, attr->rdev.minor);
	st->st_size = (off_t) (attr->size);
	st->st_blksize = 0; /* ignored now */
	st->st_blocks = (blkcnt_t) (attr->used / 512);
	st->st_atime = (time_t) (attr->atime.seconds);
	st->st_mtime = (time_t) (attr->mtime.seconds);
	st->st_ctime = (time_t) (attr->ctime.seconds);

	ST_ATIM_NSEC_SET(st, attr->atime.nseconds);
	ST_MTIM_NSEC_SET(st, attr->atime.nseconds);
	/* Don't we need ctime? */

 out:
	DEBUG_OUT("with errno %d.\n", err);
	return err;
}
Пример #9
0
void hsx_fuse_write(fuse_req_t req, fuse_ino_t ino, const char *buf,
                          size_t size, off_t off, struct fuse_file_info *fi)
{
	struct hsfs_rw_info winfo;
	struct hsfs_super * sb = (struct hsfs_super *)fuse_req_userdata(req);
	size_t cnt = 0;
	int err = 0;
	char * buffer = NULL;
	
	DEBUG_IN("offset 0x%x size 0x%x", (unsigned int)off, (unsigned int)size);
	buffer = (char *) malloc(sb->wsize);
	if( NULL == buffer){
		err = ENOMEM;
		fuse_reply_err(req, err);
		goto out;
	}
	
	memset(&winfo, 0, sizeof(struct hsfs_rw_info));
	if(fi->direct_io)
		winfo.stable = HSFS_FILE_SYNC;
	else
		winfo.stable = HSFS_UNSTABLE;
	if(NULL == (winfo.inode = hsfs_ilookup(sb, ino))){
		err = ENOENT;
		fuse_reply_err(req, err);
		goto out;
	}
	DEBUG("ino %lu", winfo.inode->ino);	
	while(cnt < size){
		size_t tmp_size = min(size - cnt, sb->wsize);
		
		winfo.rw_size = tmp_size;
		winfo.rw_off = off + cnt;
		memcpy(buffer, buf + cnt, tmp_size);
		winfo.data.data_len = tmp_size;
		winfo.data.data_val = buffer;
		err = hsi_nfs3_write(&winfo);
		
		if(err){
			fuse_reply_err(req, err);
			goto out;
		}
			
		cnt += winfo.ret_count;
	}

	fuse_reply_write(req, cnt);
out:	
	if(NULL != buffer)
		free(buffer);
	
	DEBUG_OUT("err %d", err);		
	return;

}
Пример #10
0
void hsx_fuse_readdir(fuse_req_t req, fuse_ino_t ino, size_t size, off_t off,
		      struct fuse_file_info *fi)
{
	struct hsfs_readdir_ctx *saved_ctx, *ctx = NULL;
	struct hsfs_inode *parent;
	struct hsfs_super *sb;
	size_t res, len = 0;
	char * buf;
	int err, count = 0;

	DEBUG_IN("P_I(%lu), Size(%lld), Off(0x%llx)", ino, size, off);

	(void)fi;
	sb = fuse_req_userdata(req);
	FUSE_ASSERT(sb != NULL);

	parent = hsfs_ilookup(sb, ino);
	FUSE_ASSERT(parent != NULL);

	err = hsi_nfs3_readdir(parent, size, off, &ctx);
	if(err)
		goto out1;
	saved_ctx = ctx;

	buf = (char *) malloc(size);
	if( NULL == buf){
		err = ENOMEM;
		goto out2;
	}
	while(ctx != NULL){
		res = fuse_add_direntry(req, buf + len, size - len, ctx->name,
					&ctx->stbuf, ctx->off);
		/* From fuse doc, buf is not copied if res larger than
		 * requested */
	  	if(res >= size - len)
			break;
		len += res;
		ctx = ctx->next;
		count++;
	}
	/* If EOF, we will return an empty buffer here. */
	if (!err)
		fuse_reply_buf(req, buf, len);
	
	free(buf);
out2:
	__free_ctx(saved_ctx, 0);
out1:
	if(err)
		fuse_reply_err(req, err);

	DEBUG_OUT("with %d, %d entries returned.", err, count);
}
Пример #11
0
int hsi_nfs3_rename(struct hsfs_inode *parent, const char *name,
		struct hsfs_inode *newparent, const char *newname)
{
	int ret = 0;
	int err = 0;
	struct hsfs_super *sb = parent->sb;
	CLIENT *clntp = sb->clntp;
	rename3args args;
	rename3res res;

	DEBUG_IN(" %s to %s", name, newname);

	memset(&args, 0, sizeof(args));
	memset(&res, 0, sizeof(res));

	hsi_nfs3_getfh3(parent, &args.from.dir);
	hsi_nfs3_getfh3(newparent, &args.to.dir);

	args.from.name = (char *)name;
	args.to.name = (char *)newname;

	err = hsi_nfs3_clnt_call(sb, clntp, NFSPROC3_RENAME,
			(xdrproc_t)xdr_rename3args, (caddr_t)&args,
			(xdrproc_t)xdr_rename3res, (caddr_t)&res);
	if (err)
		goto out1;

	ret = res.status;
	if (NFS3_OK != ret) {
		ERR("Call NFS3 Server failure:(%d).\n", ret);
		err = hsi_nfs3_stat_to_errno(ret);
		goto out2;
	}
	/* if(res.rename3res_u.res.fromdir_wcc.after.present) { */
/* 		memcpy(&(parent->attr), &res.rename3res_u.res.fromdir_wcc. */
/* 				after.post_op_attr_u.attributes, */
/* 				sizeof(fattr3)); */
	/* } */
	/* if(res.rename3res_u.res.todir_wcc.after.present) { */
/* 		memcpy(&(newparent->attr), &res.rename3res_u.res.todir_wcc. */
/* 				after.post_op_attr_u.attributes, */
/* 				sizeof(fattr3)); */
	/* } */
out2:
	clnt_freeres(clntp, (xdrproc_t)xdr_rename3res, (char *)&res);
out1:
	DEBUG_OUT(" %s to %s errno:%d", name, newname, err);
	return err;
}
Пример #12
0
void hsx_fuse_init(void *userdata, struct fuse_conn_info *conn)
{
	struct hsfs_super *sb = (struct hsfs_super *)userdata;
	unsigned long ref;

	DEBUG_IN("SB(%p), Kernel_VER(%d.%d), FUSE_VER(%d.%d)", sb,
		 conn->proto_major, conn->proto_minor,
		 FUSE_MAJOR_VERSION, FUSE_MINOR_VERSION);

	ref = hsx_fuse_ref_xchg(sb->root, 1);
	FUSE_ASSERT(ref == 0);

	hsx_fuse_init_cap(sb, conn);

	DEBUG_OUT("Success conn at %p", conn);
}
Пример #13
0
void hsx_fuse_open (fuse_req_t req, fuse_ino_t ino _U_, struct fuse_file_info *fi)
{
	int err=0;
	uint64_t fh =(uint64_t) malloc (FI_FH_LEN);
	DEBUG_IN ("ino : (%lu)  fi->flags:%d",ino, fi->flags);
	if (!fh){
		err = ENOMEM;
		ERR ("malloc failed:%d\n",err);
		fuse_reply_err(req, err);

	}
	else {
		fi->fh = fh;
		fuse_reply_open(req, fi);
	}
	DEBUG_OUT(" fh:%lu",fh);	
}
Пример #14
0
// set last message, from transaction or default if none specified. msg_index is used for error reporting only
void DialogState::setLastReceivedMessage(const string &msg, const string &name, int msg_index)
{
  DEBUG_IN("name = '%s' Message Length = %d", name.c_str(), msg.length());

  // set default transactions's last message
  {
    TransactionState &txn = get_transaction("", msg_index);
    txn.setLastReceivedMessage(msg);
  }

  // set per-transaction message
  if (!name.empty()) {
    TransactionState &txn = get_transaction(name, msg_index);
    txn.setLastReceivedMessage(msg);
    DEBUG("Set last message for transaction %s", name.c_str());
  }
}
Пример #15
0
int hsi_nfs3_getattr(struct hsfs_inode *inode, struct stat *st)
{
	int err = 0;
	nfs_fh3 fh;
	struct nfs_fattr fattr;
	
	DEBUG_IN("(%p)", inode);

	hsi_nfs3_getfh3(inode, &fh);
	nfs_init_fattr(&fattr);
	err = hsi_nfs3_do_getattr(inode->sb, &fh, &fattr, st);
	if (err)
		goto out;

	err = nfs_refresh_inode(inode, &fattr);
out:
	DEBUG_OUT("(%d)", err);
	return err;
}
Пример #16
0
int hsi_nfs3_statfs (struct hsfs_inode *inode)
{ 
	struct hsfs_super *sb = inode->sb;
	struct fsstat3res res;	
	struct fsstat3resok resok;       
	struct nfs_fh3 fh;
	int st = 0;

	memset (&res, 0, sizeof(res));
	memset (&fh, 0, sizeof(fh));
	memset (&resok, 0, sizeof(resok));

	hsi_nfs3_getfh3(inode, &fh);

	DEBUG_IN("I(%p:%lu)", inode, inode->ino);

	st = hsi_nfs3_clnt_call (sb, sb->clntp, NFSPROC3_FSSTAT,
			(xdrproc_t)xdr_nfs_fh3, (caddr_t)&fh, 
			(xdrproc_t)xdr_fsstat3res, (caddr_t)&res);
	if (st)	
		goto out;

	st = res.status;
	if (NFS3_OK != st){

		st = hsi_nfs3_stat_to_errno (st);
		ERR ("rpc request failed: %d\n",st);
		clnt_freeres (sb->clntp, (xdrproc_t)xdr_fsstat3res,(char *)&res);
		goto out;
	}
	resok = res.fsstat3res_u.resok;
	inode->sb->tbytes = resok.tbytes;
	inode->sb->fbytes = resok.fbytes;
	inode->sb->abytes = resok.abytes;
	inode->sb->tfiles = resok.tfiles;
	inode->sb->ffiles = resok.ffiles;
	inode->sb->afiles = resok.afiles;
	clnt_freeres (sb->clntp, (xdrproc_t)xdr_fsstat3res,(char *)&res);
out:	
	DEBUG_OUT ("(%d)",st);
	return st;

}
Пример #17
0
void hsx_fuse_mkdir(fuse_req_t req, fuse_ino_t parent, const char *name,
	       	mode_t mode)
{	
	int err = 0;
	struct hsfs_inode *hi_parent = NULL;
	struct hsfs_inode *new = NULL;
	struct fuse_entry_param e;
	struct hsfs_super *sb = NULL;
	const char *dirname = name;
	DEBUG_IN("ino:%lu.\n", parent);

	memset(&e, 0, sizeof(struct fuse_entry_param));

	sb = fuse_req_userdata(req);
	hi_parent = hsx_fuse_iget(sb, parent);
	
	if(NULL == sb) {
		ERR("ERR in fuse_req_userdata");
		goto out;
	}
	if(NULL == hi_parent) {
		ERR("ERR in hsx_fuse_iget");
		goto out;
	}

	
	err = hsi_nfs3_mkdir(hi_parent, &new, dirname, mode);
	if(0 != err ) {
		fuse_reply_err(req, err);
		goto out;
	}else {
		hsx_fuse_fill_reply(new, &e);
		fuse_reply_entry(req, &e);
		goto out;
	}
out:
	DEBUG_OUT(" out errno is: %d\n", err);
	return;
};
Пример #18
0
void hsx_fuse_readlink(fuse_req_t req, fuse_ino_t ino)
{
	int st = 0;
	int err = 0;
	struct hsfs_inode *hi = NULL;
	struct hsfs_super *hi_sb = NULL;
	char *link = NULL;
	DEBUG_IN("%s\n","THE HSX_FUSE_READLINK.");

	hi_sb = fuse_req_userdata(req);
	if(!hi_sb){
		ERR("%s gets inode->sb fails \n", progname);
		err = ENOENT;
		goto out;
	}
	hi = hsfs_ilookup(hi_sb, ino);
	if(!hi){
		ERR("%s gets inode fails \n", progname);
		err = ENOENT;
		goto out;
	}
	st = hsi_nfs3_readlink(hi,&link);
	if(st != 0){
		err = st;
		goto out;
	}
	fuse_reply_readlink(req, link);

out:
	if(link != NULL){
		free(link);
	}
	if(st != 0){
		fuse_reply_err(req, err);
	}
	DEBUG_OUT(" WITH ERRNO %d\n", err);
	return;
}
Пример #19
0
int hsi_nfs3_do_getattr(struct hsfs_super *sb, struct nfs_fh3 *fh,
			struct nfs_fattr *fattr, struct stat *st)
{
	struct getattr3res res;
	struct fattr3 *attr = NULL;
	int err;
	
	DEBUG_IN("(%p, %p, %p, %p)", sb, fh, fattr, st);

	memset(&res, 0, sizeof(res));
	err = hsi_nfs3_clnt_call(sb, sb->clntp, NFSPROC3_GETATTR,
				 (xdrproc_t)xdr_nfs_fh3, (caddr_t)fh,
				(xdrproc_t)xdr_getattr3res, (caddr_t)&res);
	if (err)
		goto out_no_free;

	if (NFS3_OK != res.status) {
		err = hsi_nfs3_stat_to_errno(res.status);
		ERR("RPC Server returns failed status : %d.\n", err);
		goto out;
	}
	
	attr = &res.getattr3res_u.attributes;
	if (fattr){
		hsi_nfs3_fattr2fattr(attr, fattr);
		DEBUG("get nfs_fattr(V:%x, U:%u, G:%u, S:%llu, I:%llu)",
		      fattr->valid, fattr->uid, fattr->gid, fattr->size, fattr->fileid);
	}
	if (st)
		hsi_nfs3_fattr2stat(attr, st);
	
 out:
	clnt_freeres(sb->clntp, (xdrproc_t)xdr_getattr3res, (char *)&res);
 out_no_free:
	DEBUG_OUT("with errno %d.\n", err);
	return err;
}
Пример #20
0
void hsx_fuse_rename(fuse_req_t req, fuse_ino_t parent, const char *name,
				fuse_ino_t newparent, const char *newname)
{
	int err = 0;
	struct hsfs_super *sb = NULL;
	struct hsfs_inode *hi = NULL, *newhi = NULL;

	DEBUG_IN(" %s to %s", name, newname);

	if (name == NULL) {
		ERR("Source name is NULL\n");
		err = EINVAL;
		goto out;
	}
	else if (newname == NULL) {
		ERR("Target name is NULL\n");
		err = EINVAL;
		goto out;
	}
	else if (!(strcmp(name, ""))) {
		ERR("Source name is empty\n");
		err = EINVAL;
		goto out;
	}
	else if (!(strcmp(newname, ""))) {
		ERR("Target name is empty\n");
		err = EINVAL;
		goto out;
	}
	else if (strlen(name) > NAME_MAX) {
		ERR("Source name is too long\n");
		err = ENAMETOOLONG;
		goto out;
	}
	else if (strlen(newname) > NAME_MAX) {
		ERR("Target name is too long\n");
		err = ENAMETOOLONG;
		goto out;
	}

	if (!(sb = fuse_req_userdata(req))) {
		ERR("Get user data failed\n");
		err = EIO;
		goto out;
	}
	if (!(hi = hsx_fuse_iget(sb, parent))) {
		ERR("Get hsfs inode failed\n");
		err = ENOENT;
		goto out;
	}
	if (!(newhi = hsx_fuse_iget(sb, newparent))) {
		ERR("Get hsfs inode failed\n");
		err = ENOENT;
		goto out;
	}

	if ((err = hsi_nfs3_rename(hi, name, newhi, newname))) {
		goto out;
	}
out:
	fuse_reply_err(req, err);
	DEBUG_OUT(" %s to %s errno:%d", name, newname, err);
}
Пример #21
0
int hsi_nfs3_setattr(struct hsfs_inode *inode, struct hsfs_sattr *attr)
{
	int err = 0;
	CLIENT *clntp = NULL;
	struct setattr3args args;
	struct wccstat3 res;
	struct fattr3 *fattr = NULL;
	
	DEBUG_IN("%s", "\n");

	clntp= inode->sb->clntp;
	memset(&args, 0, sizeof(args));
	args.object.data.data_len = inode->fh.data.data_len;
	args.object.data.data_val = inode->fh.data.data_val;
	if (S_ISSETMODE(attr->valid)) {
		args.new_attributes.mode.set = TRUE;
		args.new_attributes.mode.set_uint32_u.val = attr->mode;
	}
	else
		args.new_attributes.mode.set = FALSE;	
 
	if (S_ISSETUID(attr->valid)) {
		args.new_attributes.uid.set = TRUE;
		args.new_attributes.uid.set_uint32_u.val = attr->uid;
	}
	else
		args.new_attributes.uid.set = FALSE;
	
	if (S_ISSETGID(attr->valid)) {
		args.new_attributes.gid.set = TRUE;
		args.new_attributes.gid.set_uint32_u.val = attr->gid;
	}
	else
		args.new_attributes.gid.set = FALSE;

	if (S_ISSETSIZE(attr->valid)) {
		args.new_attributes.size.set = TRUE;
		args.new_attributes.size.set_uint64_u.val = attr->size;
	}
	else
		args.new_attributes.size.set = FALSE;

	if (S_ISSETATIME(attr->valid)) {
		args.new_attributes.atime.set = SET_TO_CLIENT_TIME;
		args.new_attributes.atime.set_time_u.time.seconds = attr->atime.tv_sec;
		args.new_attributes.atime.set_time_u.time.nseconds = attr->atime.tv_nsec;
	}
	else
		args.new_attributes.atime.set = DONT_CHANGE;
	
	if (S_ISSETMTIME(attr->valid)) {
		args.new_attributes.mtime.set = SET_TO_CLIENT_TIME;
		args.new_attributes.mtime.set_time_u.time.seconds = attr->mtime.tv_sec;
		args.new_attributes.mtime.set_time_u.time.nseconds = attr->mtime.tv_nsec;
	}
	else
		args.new_attributes.mtime.set = DONT_CHANGE;

	if (S_ISSETATIMENOW(attr->valid)) 
		args.new_attributes.atime.set = SET_TO_SERVER_TIME;

	if (S_ISSETMTIMENOW(attr->valid))
		args.new_attributes.mtime.set = SET_TO_SERVER_TIME;
	
	args.guard.check = FALSE;
	memset(&res, 0, sizeof(res));
	err = hsi_nfs3_clnt_call(inode->sb, clntp, NFSPROC3_SETATTR,
			(xdrproc_t)xdr_setattr3args, (caddr_t)&args,
			(xdrproc_t)xdr_wccstat3, (caddr_t)&res);
	if (err) 
		goto out_no_free;

	if (NFS3_OK != res.status) {
		err = hsi_nfs3_stat_to_errno(res.status);
		ERR("RPC Server returns failed status : %d.\n", err);
		goto out;
	}
	if (!res.wccstat3_u.wcc.after.present) {
		err = EAGAIN;
		ERR("Try again to set file attributes.\n");
		goto out;
	}
	fattr = &res.wccstat3_u.wcc.after.post_op_attr_u.attributes;
	inode->attr.type = fattr->type;
	inode->attr.mode = fattr->mode;
	inode->attr.nlink = fattr->nlink;
	inode->attr.uid = fattr->uid;
	inode->attr.gid = fattr->gid;
	inode->attr.size = fattr->size;
	inode->attr.used = fattr->used;
	inode->attr.rdev.major = fattr->rdev.major;
	inode->attr.rdev.minor = fattr->rdev.minor;
	inode->attr.fsid = fattr->fsid;
	inode->attr.fileid = fattr->fileid;
 
	inode->attr.atime.seconds = fattr->atime.seconds;
	inode->attr.atime.nseconds = fattr->atime.nseconds;
	inode->attr.mtime.seconds = fattr->mtime.seconds;
	inode->attr.mtime.nseconds = fattr->mtime.nseconds;
	inode->attr.ctime.seconds = fattr->ctime.seconds;
	inode->attr.ctime.nseconds = fattr->ctime.nseconds;
 out:
	clnt_freeres(clntp, (xdrproc_t)xdr_wccstat3, (char *)&res);
 out_no_free:
	DEBUG_OUT("with errno : %d.\n", err);
	return err;
}
Пример #22
0
// get last message, from transaction or default if none specified. msg_index is used for error reporting only
const string &DialogState::getLastReceivedMessage(const string &name, int msg_index)
{
  DEBUG_IN("name = %s", name.c_str());
  TransactionState &txn = get_transaction(name, msg_index);
  return txn.getLastReceivedMessage();
}
Пример #23
0
    MSG_OUT(MessageType_MessageType_CipheredKeyValue,   CipheredKeyValue_fields,    NO_PROCESS_FUNC)
    MSG_OUT(MessageType_MessageType_ButtonRequest,      ButtonRequest_fields,       NO_PROCESS_FUNC)
    MSG_OUT(MessageType_MessageType_Address,            Address_fields,             NO_PROCESS_FUNC)
    MSG_OUT(MessageType_MessageType_EntropyRequest,     EntropyRequest_fields,      NO_PROCESS_FUNC)
    MSG_OUT(MessageType_MessageType_MessageSignature,   MessageSignature_fields,    NO_PROCESS_FUNC)
    MSG_OUT(MessageType_MessageType_SignedIdentity,     SignedIdentity_fields,      NO_PROCESS_FUNC)
    MSG_OUT(MessageType_MessageType_EncryptedMessage,   EncryptedMessage_fields,    NO_PROCESS_FUNC)
    MSG_OUT(MessageType_MessageType_DecryptedMessage,   DecryptedMessage_fields,    NO_PROCESS_FUNC)
    MSG_OUT(MessageType_MessageType_PassphraseRequest,  PassphraseRequest_fields,   NO_PROCESS_FUNC)
    MSG_OUT(MessageType_MessageType_TxSize,             TxSize_fields,              NO_PROCESS_FUNC)
    MSG_OUT(MessageType_MessageType_WordRequest,        WordRequest_fields,         NO_PROCESS_FUNC)
    MSG_OUT(MessageType_MessageType_CharacterRequest,   CharacterRequest_fields,    NO_PROCESS_FUNC)

#if DEBUG_LINK
    /* Debug Messages */
    DEBUG_IN(MessageType_MessageType_DebugLinkDecision, DebugLinkDecision_fields,   NO_PROCESS_FUNC)
    DEBUG_IN(MessageType_MessageType_DebugLinkGetState, DebugLinkGetState_fields, (void (*)(void *))fsm_msgDebugLinkGetState)
    DEBUG_IN(MessageType_MessageType_DebugLinkStop,     DebugLinkStop_fields, (void (*)(void *))fsm_msgDebugLinkStop)

    /* Debug Out Messages */
    DEBUG_OUT(MessageType_MessageType_DebugLinkState, DebugLinkState_fields,        NO_PROCESS_FUNC)
    DEBUG_OUT(MessageType_MessageType_DebugLinkLog, DebugLinkLog_fields,            NO_PROCESS_FUNC)
#endif
};

/* === Variables =========================================================== */

extern bool reset_msg_stack;

/* === Functions =========================================================== */