Deleted Added
full compact
kern_gzio.c (231949) kern_gzio.c (241896)
1/*
2 * $Id: kern_gzio.c,v 1.6 2008-10-18 22:54:45 lbazinet Exp $
3 *
4 * core_gzip.c -- gzip routines used in compressing user process cores
5 *
6 * This file is derived from src/lib/libz/gzio.c in FreeBSD.
7 */
8
9/* gzio.c -- IO on .gz files
10 * Copyright (C) 1995-1998 Jean-loup Gailly.
11 * For conditions of distribution and use, see copyright notice in zlib.h
12 *
13 */
14
1/*
2 * $Id: kern_gzio.c,v 1.6 2008-10-18 22:54:45 lbazinet Exp $
3 *
4 * core_gzip.c -- gzip routines used in compressing user process cores
5 *
6 * This file is derived from src/lib/libz/gzio.c in FreeBSD.
7 */
8
9/* gzio.c -- IO on .gz files
10 * Copyright (C) 1995-1998 Jean-loup Gailly.
11 * For conditions of distribution and use, see copyright notice in zlib.h
12 *
13 */
14
15/* @(#) $FreeBSD: head/sys/kern/kern_gzio.c 231949 2012-02-21 01:05:12Z kib $ */
15/* @(#) $FreeBSD: head/sys/kern/kern_gzio.c 241896 2012-10-22 17:50:54Z kib $ */
16
17#include <sys/param.h>
18#include <sys/proc.h>
19#include <sys/malloc.h>
20#include <sys/vnode.h>
21#include <sys/syslog.h>
22#include <sys/endian.h>
23#include <net/zutil.h>

--- 190 unchanged lines hidden (view full) ---

214 gzFile file;
215 const voidp buf;
216 unsigned len;
217{
218 gz_stream *s = (gz_stream*)file;
219 off_t curoff;
220 size_t resid;
221 int error;
16
17#include <sys/param.h>
18#include <sys/proc.h>
19#include <sys/malloc.h>
20#include <sys/vnode.h>
21#include <sys/syslog.h>
22#include <sys/endian.h>
23#include <net/zutil.h>

--- 190 unchanged lines hidden (view full) ---

214 gzFile file;
215 const voidp buf;
216 unsigned len;
217{
218 gz_stream *s = (gz_stream*)file;
219 off_t curoff;
220 size_t resid;
221 int error;
222 int vfslocked;
223
224 if (s == NULL || s->mode != 'w') return Z_STREAM_ERROR;
225
226 s->stream.next_in = (Bytef*)buf;
227 s->stream.avail_in = len;
228
229 curoff = s->outoff;
230 while (s->stream.avail_in != 0) {
231
232 if (s->stream.avail_out == 0) {
233
234 s->stream.next_out = s->outbuf;
222
223 if (s == NULL || s->mode != 'w') return Z_STREAM_ERROR;
224
225 s->stream.next_in = (Bytef*)buf;
226 s->stream.avail_in = len;
227
228 curoff = s->outoff;
229 while (s->stream.avail_in != 0) {
230
231 if (s->stream.avail_out == 0) {
232
233 s->stream.next_out = s->outbuf;
235 vfslocked = VFS_LOCK_GIANT(s->file->v_mount);
236 error = vn_rdwr_inchunks(UIO_WRITE, s->file, s->outbuf, Z_BUFSIZE,
237 curoff, UIO_SYSSPACE, IO_UNIT,
238 curproc->p_ucred, NOCRED, &resid, curthread);
234 error = vn_rdwr_inchunks(UIO_WRITE, s->file, s->outbuf, Z_BUFSIZE,
235 curoff, UIO_SYSSPACE, IO_UNIT,
236 curproc->p_ucred, NOCRED, &resid, curthread);
239 VFS_UNLOCK_GIANT(vfslocked);
240 if (error) {
241 log(LOG_ERR, "gzwrite: vn_rdwr return %d\n", error);
242 curoff += Z_BUFSIZE - resid;
243 s->z_err = Z_ERRNO;
244 break;
245 }
246 curoff += Z_BUFSIZE;
247 s->stream.avail_out = Z_BUFSIZE;

--- 21 unchanged lines hidden (view full) ---

269 gzFile file;
270 int flush;
271{
272 uInt len;
273 int done = 0;
274 gz_stream *s = (gz_stream*)file;
275 off_t curoff = s->outoff;
276 size_t resid;
237 if (error) {
238 log(LOG_ERR, "gzwrite: vn_rdwr return %d\n", error);
239 curoff += Z_BUFSIZE - resid;
240 s->z_err = Z_ERRNO;
241 break;
242 }
243 curoff += Z_BUFSIZE;
244 s->stream.avail_out = Z_BUFSIZE;

--- 21 unchanged lines hidden (view full) ---

266 gzFile file;
267 int flush;
268{
269 uInt len;
270 int done = 0;
271 gz_stream *s = (gz_stream*)file;
272 off_t curoff = s->outoff;
273 size_t resid;
277 int vfslocked = 0;
278 int error;
279
280 if (s == NULL || s->mode != 'w') return Z_STREAM_ERROR;
281
282 if (s->stream.avail_in) {
283 log(LOG_WARNING, "do_flush: avail_in non-zero on entry\n");
284 }
285
286 s->stream.avail_in = 0; /* should be zero already anyway */
287
288 for (;;) {
289 len = Z_BUFSIZE - s->stream.avail_out;
290
291 if (len != 0) {
274 int error;
275
276 if (s == NULL || s->mode != 'w') return Z_STREAM_ERROR;
277
278 if (s->stream.avail_in) {
279 log(LOG_WARNING, "do_flush: avail_in non-zero on entry\n");
280 }
281
282 s->stream.avail_in = 0; /* should be zero already anyway */
283
284 for (;;) {
285 len = Z_BUFSIZE - s->stream.avail_out;
286
287 if (len != 0) {
292 vfslocked = VFS_LOCK_GIANT(s->file->v_mount);
293 error = vn_rdwr_inchunks(UIO_WRITE, s->file, s->outbuf, len, curoff,
294 UIO_SYSSPACE, IO_UNIT, curproc->p_ucred,
295 NOCRED, &resid, curthread);
288 error = vn_rdwr_inchunks(UIO_WRITE, s->file, s->outbuf, len, curoff,
289 UIO_SYSSPACE, IO_UNIT, curproc->p_ucred,
290 NOCRED, &resid, curthread);
296 VFS_UNLOCK_GIANT(vfslocked);
297 if (error) {
298 s->z_err = Z_ERRNO;
299 s->outoff = curoff + len - resid;
300 return Z_ERRNO;
301 }
302 s->stream.next_out = s->outbuf;
303 s->stream.avail_out = Z_BUFSIZE;
304 curoff += len;

--- 102 unchanged lines hidden ---
291 if (error) {
292 s->z_err = Z_ERRNO;
293 s->outoff = curoff + len - resid;
294 return Z_ERRNO;
295 }
296 s->stream.next_out = s->outbuf;
297 s->stream.avail_out = Z_BUFSIZE;
298 curoff += len;

--- 102 unchanged lines hidden ---