Deleted Added
sdiff udiff text old ( 44282 ) new ( 47584 )
full compact
1/*-
2 * Copyright (c) 1990, 1993, 1994
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

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

37 The Regents of the University of California. All rights reserved.\n";
38#endif /* not lint */
39
40#ifndef lint
41#if 0
42static char sccsid[] = "@(#)rm.c 8.5 (Berkeley) 4/18/94";
43#else
44static const char rcsid[] =
45 "$Id: rm.c,v 1.18 1997/08/07 21:37:39 steve Exp $";
46#endif
47#endif /* not lint */
48
49#include <sys/types.h>
50#include <sys/stat.h>
51
52#include <err.h>
53#include <errno.h>
54#include <fcntl.h>
55#include <fts.h>
56#include <stdio.h>
57#include <stdlib.h>
58#include <string.h>

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

325 * kernel support.
326 */
327void
328rm_overwrite(file, sbp)
329 char *file;
330 struct stat *sbp;
331{
332 struct stat sb;
333 off_t len;
334 int fd, wlen;
335 char buf[8 * 1024];
336
337 fd = -1;
338 if (sbp == NULL) {
339 if (lstat(file, &sb))
340 goto err;
341 sbp = &sb;
342 }
343 if (!S_ISREG(sbp->st_mode))
344 return;
345 if ((fd = open(file, O_WRONLY, 0)) == -1)
346 goto err;
347
348#define PASS(byte) { \
349 memset(buf, byte, sizeof(buf)); \
350 for (len = sbp->st_size; len > 0; len -= wlen) { \
351 wlen = len < sizeof(buf) ? len : sizeof(buf); \
352 if (write(fd, buf, wlen) != wlen) \
353 goto err; \
354 } \
355}
356 PASS(0xff);
357 if (fsync(fd) || lseek(fd, (off_t)0, SEEK_SET))
358 goto err;
359 PASS(0x00);
360 if (fsync(fd) || lseek(fd, (off_t)0, SEEK_SET))
361 goto err;
362 PASS(0xff);
363 if (!fsync(fd) && !close(fd))
364 return;
365
366err: eval = 1;
367 warn("%s", file);
368}
369
370
371int
372check(path, name, sp)
373 char *path, *name;
374 struct stat *sp;

--- 71 unchanged lines hidden ---