Commits

Anonymous committed 2f183e4

Fix open mode and write return

  • Participants
  • Parent commits a3a0b70

Comments (0)

Files changed (4)

 	stat->mtime = O9FS_GBIT32(fs->inbuf + Minhd + 2 + 2 + 2 + 4 + 1 + 4 + 8 + 4 + 4);
 	stat->length = O9FS_GBIT64(fs->inbuf + Minhd + 2 + 2 + 2 + 4 + 1 + 4 + 8 + 4 + 4 + 4);
 
-	/* For now the other fields are not used, so we don't bother parsing them */
+	/* So far the other fields are not used, don't bother parsing them */
 /*
 	p = fs->inbuf + Minhd + 2 + 2 + 2 + 4 + 1 + 4 + 8 + 4 + 4 + 4 + 8;
 	stat->name = o9fs_getstr(p, &sn);
 {
 	long n;
 	u_char *p;
-	uint8_t omode;
+	uint32_t omode;
 	DIN();
 
 	if (fid == NULL) {
 			return -1;
 		}
 		p = o9fs_putstr(p, name);
-		O9FS_PBIT32(p, perm);
+		O9FS_PBIT32(p, o9fs_utoperm(perm));
 		p += 4;
 	}
 	omode = o9fs_uflags2omode(mode);

File o9fs_extern.h

 struct	o9fid *o9fs_getfid(struct o9fs *);
 void	o9fs_putfid(struct o9fs *, struct o9fid *);
 int		o9fs_ptoumode(int);
-int		o9fs_utopmode(int);
+int		o9fs_utoperm(int);
 int		o9fs_uflags2omode(uint32_t);
 void	*o9fsrealloc(void *, size_t, size_t);
 void	_printvp(struct vnode *);
 }
 
 int
-o9fs_ptoumode(int mode)
+o9fs_permtou(int mode)
 {
 	int umode;
 	
 }
 
 int
-o9fs_utopmode(int mode)
+o9fs_utoperm(int mode)
 {
 	int pmode;
 
 }
 
 int
-o9fs_uflags2omode(uint32_t uflags)
+o9fs_uflags2omode(uint32_t flags)
 {
 	int omode;
-	
+
 	omode = 0;
-	switch(uflags & O_ACCMODE) {
-	case FREAD:
+	flags = OFLAGS(flags);
+
+	switch (flags & O_ACCMODE) {
+	case O_RDONLY:
 		omode = O9FS_OREAD;
 		break;
-	case FWRITE:
+	case O_WRONLY:
 		omode = O9FS_OWRITE;
 		break;
-	case (FREAD|FWRITE):
+	case O_RDWR:
 		omode = O9FS_ORDWR;
 		break;
 	}
 
-	if (uflags & O_CREAT)
-		omode |= O9FS_OEXEC;
-	if (uflags & O_TRUNC)
+	if (flags & O_TRUNC)
 		omode |= O9FS_OTRUNC;
 	return omode;
 }

File o9fs_vnops.c

 		return -1;
 	}
 
-	if (o9fs_opencreate(fs, nf, O9FS_TCREATE, 0, o9fs_utopmode(vap->va_mode), cnp->cn_nameptr) < 0) {
+	if (o9fs_opencreate(fs, nf, O9FS_TCREATE, 0, vap->va_mode, cnp->cn_nameptr) < 0) {
 		o9fs_putfid(fs, nf);
 		DRET();
 		return -1;
 
 	f->offset = offset + n;
 	DRET();
-	return n;
+	return 0;
 }
 
 int
 	vap->va_rdev = 0;
 	vap->va_bytes = 0;
 	vap->va_type = vp->v_type;
-	vap->va_mode = o9fs_ptoumode(stat->mode);
+	vap->va_mode = o9fs_permtou(stat->mode);
 	vap->va_nlink = 0;
 	vap->va_fileid = f->qid.path;	/* qid.path is 64bit, va_fileid 32bit */
 	vap->va_filerev = f->qid.vers;