linux_file.c.diff

ftigeot, 09/02/2009 09:22 AM

Download (6.12 KB)

View differences:

linux_file.c 2009-09-02 10:32:42 +0200
75 75
	error = nlookup_init(&nd, path, UIO_SYSSPACE, NLC_FOLLOW);
76 76
	if (error == 0) {
77 77
		error = kern_open(&nd, O_WRONLY | O_CREAT | O_TRUNC,
78
				  args->mode, &args->sysmsg_iresult);
78
				    args->mode, &args->sysmsg_result);
79 79
	}
80 80
	linux_free_path(&path);
81 81
	return(error);
......
135 135
	error = nlookup_init(&nd, path, UIO_SYSSPACE, NLC_FOLLOW);
136 136
	if (error == 0) {
137 137
		error = kern_open(&nd, flags,
138
				  args->mode, &args->sysmsg_iresult);
138
				    args->mode, &args->sysmsg_result);
139 139
	}
140 140

  
141 141
	if (error == 0 && !(flags & O_NOCTTY) && 
142 142
		SESS_LEADER(p) && !(p->p_flag & P_CONTROLT)) {
143 143
		struct file *fp;
144 144

  
145
		fp = holdfp(p->p_fd, args->sysmsg_iresult, -1);
145
		fp = holdfp(p->p_fd, args->sysmsg_result, -1);
146 146
		if (fp) {
147 147
			if (fp->f_type == DTYPE_VNODE)
148 148
				fo_ioctl(fp, TIOCSCTTY, NULL, p->p_ucred, NULL);
......
202 202
	lda.fd = args->fd;
203 203
	lda.dent = args->dent;
204 204
	lda.count = -1;
205
	lda.sysmsg_iresult = 0;
205
	lda.sysmsg_result = 0;
206 206
	error = sys_linux_getdents(&lda);
207
	args->sysmsg_iresult = lda.sysmsg_iresult;
207
	args->sysmsg_result = lda.sysmsg_result;
208 208
	return(error);
209 209
}
210 210

  
......
245 245
	struct dirent *bdp;
246 246
	struct vnode *vp;
247 247
	caddr_t inp, buf;		/* BSD-format */
248
	int reclen;			/* BSD-format */
249
	size_t len;
248
	int len, reclen;		/* BSD-format */
250 249
	caddr_t outp;			/* Linux-format */
251
	int linuxreclen = 0;		/* Linux-format */
252
	size_t resid;
250
	int resid, linuxreclen=0;	/* Linux-format */
253 251
	struct file *fp;
254 252
	struct uio auio;
255 253
	struct iovec aiov;
......
257 255
	off_t off;
258 256
	struct l_dirent linux_dirent;
259 257
	struct l_dirent64 linux_dirent64;
260
	int error, eofflag, justone;
261
	size_t buflen, nbytes;
258
	int buflen, error, eofflag, nbytes, justone;
262 259
	off_t *cookies = NULL, *cookiep;
263 260
	int ncookies;
264 261

  
......
282 279
		goto done;
283 280

  
284 281
	nbytes = args->count;
285
	if (nbytes == (size_t)-1) {
282
	if (nbytes == -1) {
286 283
		/* readdir(2) case. Always struct dirent. */
287 284
		if (is64bit) {
288 285
			error = EINVAL;
......
293 290
	} else {
294 291
		justone = 0;
295 292
	}
296
	if ((size_t)nbytes < 0)
293
	if (nbytes < 0)
297 294
		nbytes = 0;
298 295

  
299 296
	off = fp->f_offset;
......
327 324
	inp = buf;
328 325
	outp = (caddr_t)args->dirent;
329 326
	resid = nbytes;
330
	if (auio.uio_resid >= buflen);
327
	if ((len = buflen - auio.uio_resid) <= 0)
331 328
		goto eof;
332
	len = buflen - auio.uio_resid;
329

  
333 330
	cookiep = cookies;
334 331

  
335 332
	if (cookies) {
......
440 437
		nbytes = resid + linuxreclen;
441 438

  
442 439
eof:
443
	args->sysmsg_iresult = (int)(nbytes - resid);
440
	args->sysmsg_result = nbytes - resid;
444 441

  
445 442
out:
446 443
	if (cookies)
......
692 689
	error = nlookup_init(&nd, path, UIO_SYSSPACE, 0);
693 690
	if (error == 0) {
694 691
		error = kern_readlink(&nd, args->buf, args->count,
695
				      &args->sysmsg_iresult);
692
					&args->sysmsg_result);
696 693
	}
697 694
	nlookup_done(&nd);
698 695
	linux_free_path(&path);
......
814 811
	int error;
815 812

  
816 813
	bsd.fd = uap->fd;
817
	bsd.sysmsg_iresult = 0;
814
	bsd.sysmsg_result = 0;
818 815

  
819 816
	error = sys_fsync(&bsd);
820
	uap->sysmsg_iresult = bsd.sysmsg_iresult;
817
	uap->sysmsg_result = bsd.sysmsg_result;
821 818
	return(error);
822 819
}
823 820

  
......
839 836
	auio.uio_segflg = UIO_USERSPACE;
840 837
	auio.uio_td = td;
841 838

  
842
	if ((ssize_t)auio.uio_resid < 0) {
839
	if (auio.uio_resid < 0)
843 840
		error = EINVAL;
844
	} else {
845
		error = kern_preadv(uap->fd, &auio, O_FOFFSET,
846
				    &uap->sysmsg_szresult);
847
	}
841
	else
842
		error = kern_preadv(uap->fd, &auio, O_FOFFSET, &uap->sysmsg_result);
848 843
	return(error);
849 844
}
850 845

  
......
866 861
        auio.uio_segflg = UIO_USERSPACE;
867 862
        auio.uio_td = td;
868 863

  
869
	if ((ssize_t)auio.uio_resid < 0) {
864
	if (auio.uio_resid < 0)
870 865
		error = EINVAL;
871
	} else {
872
		error = kern_pwritev(uap->fd, &auio, O_FOFFSET,
873
				     &uap->sysmsg_szresult);
874
	}
866
	else
867
		error = kern_pwritev(uap->fd, &auio, O_FOFFSET, &uap->sysmsg_result);
868

  
875 869
	return(error);
876 870
}
877 871

  
......
883 877

  
884 878
	args2.path = args->path;
885 879
	args2.flags = 0;
886
	args2.sysmsg_iresult = 0;
880
	args2.sysmsg_result = 0;
887 881
	error = sys_linux_umount(&args2);
888
	args->sysmsg_iresult = args2.sysmsg_iresult;
882
	args->sysmsg_result = args2.sysmsg_result;
889 883
	return(error);
890 884
}
891 885

  
......
897 891

  
898 892
	bsd.path = args->path;
899 893
	bsd.flags = args->flags;	/* XXX correct? */
900
	bsd.sysmsg_iresult = 0;
894
	bsd.sysmsg_result = 0;
901 895

  
902 896
	error = sys_unmount(&bsd);
903
	args->sysmsg_iresult = bsd.sysmsg_iresult;
897
	args->sysmsg_result = bsd.sysmsg_result;
904 898
	return(error);
905 899
}
906 900

  
......
1087 1081
	if (error == 0) {
1088 1082
		switch (args->cmd) {
1089 1083
		case LINUX_F_DUPFD:
1090
			args->sysmsg_iresult = dat.fc_fd;
1084
			args->sysmsg_result = dat.fc_fd;
1091 1085
			break;
1092 1086
		case LINUX_F_GETFD:
1093
			args->sysmsg_iresult = dat.fc_cloexec;
1087
			args->sysmsg_result = dat.fc_cloexec;
1094 1088
			break;
1095 1089
		case LINUX_F_SETFD:
1096 1090
			break;
1097 1091
		case LINUX_F_GETFL:
1098
			args->sysmsg_iresult = 0;
1092
			args->sysmsg_result = 0;
1099 1093
			if (dat.fc_flags & O_RDONLY)
1100
				args->sysmsg_iresult |= LINUX_O_RDONLY;
1094
				args->sysmsg_result |= LINUX_O_RDONLY;
1101 1095
			if (dat.fc_flags & O_WRONLY)
1102
				args->sysmsg_iresult |= LINUX_O_WRONLY;
1096
				args->sysmsg_result |= LINUX_O_WRONLY;
1103 1097
			if (dat.fc_flags & O_RDWR)
1104
				args->sysmsg_iresult |= LINUX_O_RDWR;
1098
				args->sysmsg_result |= LINUX_O_RDWR;
1105 1099
			if (dat.fc_flags & O_NDELAY)
1106
				args->sysmsg_iresult |= LINUX_O_NONBLOCK;
1100
				args->sysmsg_result |= LINUX_O_NONBLOCK;
1107 1101
			if (dat.fc_flags & O_APPEND)
1108
				args->sysmsg_iresult |= LINUX_O_APPEND;
1102
				args->sysmsg_result |= LINUX_O_APPEND;
1109 1103
			if (dat.fc_flags & O_FSYNC)
1110
				args->sysmsg_iresult |= LINUX_O_SYNC;
1104
				args->sysmsg_result |= LINUX_O_SYNC;
1111 1105
			if (dat.fc_flags & O_ASYNC)
1112
				args->sysmsg_iresult |= LINUX_FASYNC;
1106
				args->sysmsg_result |= LINUX_FASYNC;
1113 1107
			break;
1114 1108
		case LINUX_F_GETLK:
1115 1109
			bsd_to_linux_flock(&dat.fc_flock, &linux_flock);
......
1120 1114
		case LINUX_F_SETLKW:
1121 1115
			break;
1122 1116
		case LINUX_F_GETOWN:
1123
			args->sysmsg_iresult = dat.fc_owner;
1117
			args->sysmsg_result = dat.fc_owner;
1124 1118
			break;
1125 1119
		case LINUX_F_SETOWN:
1126 1120
			break;
......
1144 1138
	args64.fd = args->fd;
1145 1139
	args64.cmd = args->cmd;
1146 1140
	args64.arg = args->arg;
1147
	args64.sysmsg_iresult = 0;
1141
	args64.sysmsg_result = 0;
1148 1142
	error = linux_fcntl_common(&args64);
1149
	args->sysmsg_iresult = args64.sysmsg_iresult;
1143
	args->sysmsg_result = args64.sysmsg_result;
1150 1144
	return(error);
1151 1145
}
1152 1146