Hi there,

creat(3) "is made obsolete by: open(2)". The diff below replaces all
occurrences of

creat(path, mode)

with

open(path, O_CREAT|O_TRUNC|O_WRONLY, mode)

in usr.bin.

Cheers,
Frederic

Index: usr.bin/indent/indent.c
===================================================================
RCS file: /cvs/src/usr.bin/indent/indent.c,v
retrieving revision 1.29
diff -u -p -r1.29 indent.c
--- usr.bin//indent/indent.c    9 Oct 2015 01:37:07 -0000       1.29
+++ usr.bin//indent/indent.c    10 Nov 2015 19:38:27 -0000
@@ -1184,7 +1184,7 @@ bakcopy(void)
            errc(1, ENAMETOOLONG, "%s.BAK", p);

     /* copy in_name to backup file */
-    bakchn = creat(bakfile, 0600);
+    bakchn = open(bakfile, O_CREAT | O_TRUNC | O_WRONLY, 0600);
     if (bakchn < 0)
        err(1, "%s", bakfile);
     while ((n = read(fileno(input), buff, sizeof buff)) > 0)
Index: usr.bin/mail/quit.c
===================================================================
RCS file: /cvs/src/usr.bin/mail/quit.c,v
retrieving revision 1.21
diff -u -p -r1.21 quit.c
--- usr.bin//mail/quit.c        24 Nov 2014 20:01:43 -0000      1.21
+++ usr.bin//mail/quit.c        10 Nov 2015 19:38:27 -0000
@@ -220,7 +220,7 @@ quit(void)
                        return(-1);
                }
                (void)Fclose(obuf);
-               (void)close(creat(mbox, 0600));
+               (void)close(open(mbox, O_CREAT | O_TRUNC | O_WRONLY, 0600));
                if ((obuf = Fopen(mbox, "r+")) == NULL) {
                        warn("%s", mbox);
                        (void)Fclose(ibuf);
Index: usr.bin/mail/v7.local.c
===================================================================
RCS file: /cvs/src/usr.bin/mail/v7.local.c,v
retrieving revision 1.15
diff -u -p -r1.15 v7.local.c
--- usr.bin//mail/v7.local.c    27 Oct 2009 23:59:40 -0000      1.15
+++ usr.bin//mail/v7.local.c    10 Nov 2015 19:38:27 -0000
@@ -72,7 +72,7 @@ demail(void)
 {

        if (value("keep") != NULL || rm(mailname) < 0)
-               (void)close(creat(mailname, 0600));
+               (void)close(open(mailname, O_CREAT | O_TRUNC | O_WRONLY, 0600));
 }

 /*
Index: usr.bin/patch/inp.c
===================================================================
RCS file: /cvs/src/usr.bin/patch/inp.c,v
retrieving revision 1.44
diff -u -p -r1.44 inp.c
--- usr.bin//patch/inp.c        26 Jul 2015 14:32:19 -0000      1.44
+++ usr.bin//patch/inp.c        10 Nov 2015 19:38:27 -0000
@@ -159,7 +159,7 @@ plan_a(const char *filename)
                if (check_only)
                        return true;
                makedirs(filename, true);
-               close(creat(filename, 0666));
+               close(open(filename, O_CREAT | O_TRUNC | O_WRONLY, 0666));
                statfailed = stat(filename, &filestat);
        }
        if (statfailed)
Index: usr.bin/tftp/main.c
===================================================================
RCS file: /cvs/src/usr.bin/tftp/main.c,v
retrieving revision 1.38
diff -u -p -r1.38 main.c
--- usr.bin//tftp/main.c        18 Oct 2015 03:54:22 -0000      1.38
+++ usr.bin//tftp/main.c        10 Nov 2015 19:38:27 -0000
@@ -473,7 +473,7 @@ get(int argc, char *argv[])
                }
                if (argc < 4) {
                        cp = argc == 3 ? argv[2] : tail(src);
-                       fd = creat(cp, 0644);
+                       fd = open(cp, O_CREAT | O_TRUNC | O_WRONLY, 0644);
                        if (fd < 0) {
                                warn("create: %s", cp);
                                return;
@@ -485,7 +485,7 @@ get(int argc, char *argv[])
                        break;
                }
                cp = tail(src); /* new .. jdg */
-               fd = creat(cp, 0644);
+               fd = open(cp, O_CREAT | O_TRUNC | O_WRONLY, 0644);
                if (fd < 0) {
                        warn("create: %s", cp);
                        continue;

Reply via email to