kvm-fwmem.patch

aoiko, 11/11/2007 09:58 PM

Download (1.17 KB)

View differences:

lib/libkvm/kvm.c 11 Nov 2007 15:55:14 -0000
167 167
		_kvm_syserr(kd, kd->program, "%s", mf);
168 168
		goto failed;
169 169
	}
170
	if (S_ISREG(st.st_mode) && st.st_size <= 0) {
171
		errno = EINVAL;
172
		_kvm_syserr(kd, kd->program, "empty file");
173
		goto failed;
174
	}
170 175
	if (fcntl(kd->pmfd, F_SETFD, FD_CLOEXEC) < 0) {
171 176
		_kvm_syserr(kd, kd->program, "%s", mf);
172 177
		goto failed;
......
180 185
		 */
181 186
		if (strcmp(mf, _PATH_DEVNULL) == 0) {
182 187
			kd->vmfd = open(_PATH_DEVNULL, O_RDONLY);
183
		} else if (strcmp(mf, _PATH_MEM) != 0) {
184
			_kvm_err(kd, kd->program,
185
				 "%s: not physical memory device", mf);
186
			goto failed;
187 188
		} else {
188 189
			if ((kd->vmfd = open(_PATH_KMEM, flag)) < 0) {
189 190
				_kvm_syserr(kd, kd->program, "%s", _PATH_KMEM);
......
458 459
					return NULL;
459 460
				}
460 461
			}
461
			cc = read(kd->vmfd, &ch, 1);
462
			cc = read(kd->pmfd, &ch, 1);
462 463
			if ((ssize_t)cc < 0) {
463 464
				_kvm_syserr(kd, 0, "kvm_readstr");
464 465
				return NULL;