Re: svn commit: r285140 - in head: include lib/libc/stdio

2015-07-04 Thread Tijl Coosemans
On Sat, 4 Jul 2015 16:42:15 + (UTC) Mariusz Zaborski osho...@freebsd.org 
wrote:
 Author: oshogbo
 Date: Sat Jul  4 16:42:14 2015
 New Revision: 285140
 URL: https://svnweb.freebsd.org/changeset/base/285140
 
 Log:
   Add fdclose(3) function.
   
   This function is equivalent to fclose(3) function except that it
   does not close the underlying file descriptor.
   fdclose(3) is step forward to make FILE structure private.

You can probably close this bug now:
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=75767
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r285140 - in head: include lib/libc/stdio

2015-07-04 Thread Mariusz Zaborski
Author: oshogbo
Date: Sat Jul  4 16:42:14 2015
New Revision: 285140
URL: https://svnweb.freebsd.org/changeset/base/285140

Log:
  Add fdclose(3) function.
  
  This function is equivalent to fclose(3) function except that it
  does not close the underlying file descriptor.
  fdclose(3) is step forward to make FILE structure private.
  
  Reviewed by:  wblock, jilles, jhb, pjd
  Approved by:  pjd (mentor)
  Differential Revision:https://reviews.freebsd.org/D2697

Modified:
  head/include/stdio.h
  head/lib/libc/stdio/Symbol.map
  head/lib/libc/stdio/fclose.3
  head/lib/libc/stdio/fclose.c

Modified: head/include/stdio.h
==
--- head/include/stdio.hSat Jul  4 16:33:37 2015(r285139)
+++ head/include/stdio.hSat Jul  4 16:42:14 2015(r285140)
@@ -396,6 +396,7 @@ int  (dprintf)(int, const char * __restr
 int asprintf(char **, const char *, ...) __printflike(2, 3);
 char   *ctermid_r(char *);
 voidfcloseall(void);
+int fdclose(FILE *, int *);
 char   *fgetln(FILE *, size_t *);
 const char *fmtcheck(const char *, const char *) __format_arg(2);
 int fpurge(FILE *);

Modified: head/lib/libc/stdio/Symbol.map
==
--- head/lib/libc/stdio/Symbol.map  Sat Jul  4 16:33:37 2015
(r285139)
+++ head/lib/libc/stdio/Symbol.map  Sat Jul  4 16:42:14 2015
(r285140)
@@ -162,6 +162,10 @@ FBSD_1.3 {
mkostemps;
 };
 
+FBSD_1.4 {
+   fdclose;
+};
+
 FBSDprivate_1.0 {
_flockfile;
_flockfile_debug_stub;

Modified: head/lib/libc/stdio/fclose.3
==
--- head/lib/libc/stdio/fclose.3Sat Jul  4 16:33:37 2015
(r285139)
+++ head/lib/libc/stdio/fclose.3Sat Jul  4 16:42:14 2015
(r285140)
@@ -1,5 +1,6 @@
-.\ Copyright (c) 1990, 1991, 1993
-.\The Regents of the University of California.  All rights reserved.
+.\ Copyright (c) 1990, 1991, 1993 The Regents of the University of California.
+.\ Copyright (c) 2015 Mariusz Zaborski osho...@freebsd.org
+.\ All rights reserved.
 .\
 .\ This code is derived from software contributed to Berkeley by
 .\ Chris Torek and the American National Standards Committee X3,
@@ -32,11 +33,12 @@
 .\ @(#)fclose.3   8.1 (Berkeley) 6/4/93
 .\ $FreeBSD$
 .\
-.Dd April 22, 2006
+.Dd July 4, 2015
 .Dt FCLOSE 3
 .Os
 .Sh NAME
 .Nm fclose ,
+.Nm fdclose ,
 .Nm fcloseall
 .Nd close a stream
 .Sh LIBRARY
@@ -45,6 +47,8 @@
 .In stdio.h
 .Ft int
 .Fn fclose FILE *stream
+.Ft int
+.Fn fdclose FILE *stream int *fdp
 .Ft void
 .Fn fcloseall void
 .Sh DESCRIPTION
@@ -59,36 +63,77 @@ first, using
 .Xr fflush 3 .
 .Pp
 The
+.Fn fdclose
+function is equivalent to
+.Fn fclose
+except that it does not close the underlying file descriptor.
+If
+.Fa fdp
+is not
+.Dv NULL ,
+the file descriptor will be written to it.
+If the
+.Fa fdp
+argument will be different then NULL the file descriptor will be returned in 
it,
+If the stream does not have an associated file descriptor,
+.Fa fdp
+will be set to -1.
+This type of stream is created with functions such as
+.Xr fmemopen 3 ,
+.Xr funopen 3 ,
+or
+.Xr open_memstream 3 .
+.Pp
+The
 .Fn fcloseall
 function calls
 .Fn fclose
 on all open streams.
 .Sh RETURN VALUES
-Upon successful completion 0 is returned.
+.Fn fcloseall
+does not return a value.
+.Pp
+Upon successful completion the
+.Fn fclose
+and
+.Fn fdclose
+functions return 0.
 Otherwise,
 .Dv EOF
 is returned and the global variable
 .Va errno
 is set to indicate the error.
-In either case no further access to the stream is possible.
 .Sh ERRORS
+.Fn fdclose
+fails if:
+.Bl -tag -width Er
+.It Bq Er EOPNOTSUPP
+The stream does not have an associated file descriptor.
+.El
+.Pp
 The
 .Fn fclose
-function
-may also fail and set
+and
+.Fn fdclose
+functions may also fail and set
 .Va errno
-for any of the errors specified for the routines
-.Xr close 2
-or
+for any of the errors specified for
 .Xr fflush 3 .
+.Pp
+The
+.Fn fclose
+function may also fail and set errno for any of the errors specified for
+.Xr close 2 .
 .Sh NOTES
 The
 .Fn fclose
-function
-does not handle NULL arguments; they will result in a segmentation
-violation.
-This is intentional - it makes it easier to make sure programs written
-under
+and
+.Fn fdclose
+functions do not handle NULL arguments in the
+.Fa stream
+variable; this will result in a segmentation violation.
+This is intentional.
+It makes it easier to make sure programs written under
 .Fx
 are bug free.
 This behaviour is an implementation detail, and programs should not
@@ -104,8 +149,13 @@ The
 function
 conforms to
 .St -isoC .
-.Pp
+.Sh HISTORY
 The
 .Fn fcloseall
 function first appeared in
 .Fx 7.0 .
+.Pp
+The
+.Fn fdclose
+function first appeared in
+.Fx 11.0 .

Modified: head/lib/libc/stdio/fclose.c

Re: svn commit: r285140 - in head: include lib/libc/stdio

2015-07-04 Thread Mariusz Zaborski
On Sat, Jul 04, 2015 at 07:33:55PM +0200, Tijl Coosemans wrote:
 On Sat, 4 Jul 2015 16:42:15 + (UTC) Mariusz Zaborski 
 osho...@freebsd.org wrote:
  Author: oshogbo
  Date: Sat Jul  4 16:42:14 2015
  New Revision: 285140
  URL: https://svnweb.freebsd.org/changeset/base/285140
  
  Log:
Add fdclose(3) function.

This function is equivalent to fclose(3) function except that it
does not close the underlying file descriptor.
fdclose(3) is step forward to make FILE structure private.
 
 You can probably close this bug now:
 https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=75767

Oh, thanks! I didn't know that there was such PR.
I will close it.

Cheers,
Mariusz


pgpUixgjmOogH.pgp
Description: PGP signature