Sat Jun 27 08:29:56 2015 UTC ()
Remove useless and harmful sync(2) call in umount(8)

Remove sync(2) call before unmount(2) in umount(8). This sync(2) is useless
since unmount(2) will perform a VFS_SYNC anyway.

But moreover, this sync(2) may be harmful, as there are some situation where
it cannot return (unreachable NFS server, for instance), causing umount -f
to be uneffective.


(manu)
diff -r1.47 -r1.48 src/sbin/umount/umount.c

cvs diff -r1.47 -r1.48 src/sbin/umount/umount.c (expand / switch to unified diff)

--- src/sbin/umount/umount.c 2013/07/02 01:39:17 1.47
+++ src/sbin/umount/umount.c 2015/06/27 08:29:56 1.48
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: umount.c,v 1.47 2013/07/02 01:39:17 christos Exp $ */ 1/* $NetBSD: umount.c,v 1.48 2015/06/27 08:29:56 manu Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 1980, 1989, 1993 4 * Copyright (c) 1980, 1989, 1993
5 * The Regents of the University of California. All rights reserved. 5 * The Regents of the University of California. All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer. 11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright 12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the 13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution. 14 * documentation and/or other materials provided with the distribution.
@@ -29,27 +29,27 @@ @@ -29,27 +29,27 @@
29 * SUCH DAMAGE. 29 * SUCH DAMAGE.
30 */ 30 */
31 31
32#include <sys/cdefs.h> 32#include <sys/cdefs.h>
33#ifndef lint 33#ifndef lint
34__COPYRIGHT("@(#) Copyright (c) 1980, 1989, 1993\ 34__COPYRIGHT("@(#) Copyright (c) 1980, 1989, 1993\
35 The Regents of the University of California. All rights reserved."); 35 The Regents of the University of California. All rights reserved.");
36#endif /* not lint */ 36#endif /* not lint */
37 37
38#ifndef lint 38#ifndef lint
39#if 0 39#if 0
40static char sccsid[] = "@(#)umount.c 8.8 (Berkeley) 5/8/95"; 40static char sccsid[] = "@(#)umount.c 8.8 (Berkeley) 5/8/95";
41#else 41#else
42__RCSID("$NetBSD: umount.c,v 1.47 2013/07/02 01:39:17 christos Exp $"); 42__RCSID("$NetBSD: umount.c,v 1.48 2015/06/27 08:29:56 manu Exp $");
43#endif 43#endif
44#endif /* not lint */ 44#endif /* not lint */
45 45
46#include <sys/param.h> 46#include <sys/param.h>
47#include <sys/stat.h> 47#include <sys/stat.h>
48#include <sys/mount.h> 48#include <sys/mount.h>
49#include <sys/time.h> 49#include <sys/time.h>
50#ifndef SMALL 50#ifndef SMALL
51#include <sys/socket.h> 51#include <sys/socket.h>
52 52
53#include <netdb.h> 53#include <netdb.h>
54#include <rpc/rpc.h> 54#include <rpc/rpc.h>
55#include <rpc/pmap_clnt.h> 55#include <rpc/pmap_clnt.h>
@@ -86,29 +86,26 @@ static int umountfs(const char *, const @@ -86,29 +86,26 @@ static int umountfs(const char *, const
86static void usage(void) __dead; 86static void usage(void) __dead;
87 87
88int 88int
89main(int argc, char *argv[]) 89main(int argc, char *argv[])
90{ 90{
91 int ch, errs, all = 0, raw = 0; 91 int ch, errs, all = 0, raw = 0;
92#ifndef SMALL 92#ifndef SMALL
93 int mnts; 93 int mnts;
94 struct statvfs *mntbuf; 94 struct statvfs *mntbuf;
95 struct addrinfo hints; 95 struct addrinfo hints;
96#endif /* SMALL */ 96#endif /* SMALL */
97 const char **typelist = NULL; 97 const char **typelist = NULL;
98 98
99 /* Start disks transferring immediately. */ 
100 sync(); 
101 
102#ifdef SMALL 99#ifdef SMALL
103#define OPTS "fR" 100#define OPTS "fR"
104#else 101#else
105#define OPTS "AaFfh:Rt:v" 102#define OPTS "AaFfh:Rt:v"
106#endif 103#endif
107 while ((ch = getopt(argc, argv, OPTS)) != -1) 104 while ((ch = getopt(argc, argv, OPTS)) != -1)
108 switch (ch) { 105 switch (ch) {
109 case 'f': 106 case 'f':
110 fflag = MNT_FORCE; 107 fflag = MNT_FORCE;
111 break; 108 break;
112 case 'R': 109 case 'R':
113 raw = 1; 110 raw = 1;
114 break; 111 break;