Bug 199472 - Add extra hints to ftruncate.2
Summary: Add extra hints to ftruncate.2
Status: Closed FIXED
Alias: None
Product: Documentation
Classification: Unclassified
Component: Books & Articles (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Some People
Assignee: freebsd-doc (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-04-15 21:04 UTC by Andrew Stevenson
Modified: 2015-06-02 15:13 UTC (History)
1 user (show)

See Also:


Attachments
patch to truncate.2 (425 bytes, patch)
2015-04-15 21:04 UTC, Andrew Stevenson
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Andrew Stevenson 2015-04-15 21:04:36 UTC
Created attachment 155631 [details]
patch to truncate.2

Calling truncate on an fd doesn't update the offset of that fd, even if it will now point past the end of the file. This makes sense but I had to look it up when asked and thought it might be useful if this was documented in the man page.
Comment 1 commit-hook freebsd_committer freebsd_triage 2015-05-04 14:47:45 UTC
A commit references this bug:

Author: jhb
Date: Mon May  4 14:47:00 UTC 2015
New revision: 282417
URL: https://svnweb.freebsd.org/changeset/base/282417

Log:
  Various updates to the ftruncate(2) documentation:
  - Note that ftruncate(2) can operate on shared memory objects and cross
    reference shm_open(2).
  - Note that ftruncate(2) does not change the file position pointer (aka
    seek pointer) of the file descriptor.
  - ftruncate(2) will fail with EINVAL for all sorts of other fd types than
    just sockets, so instead note that it fails for all but regular files and
    shared memory objects.
  - Note that ftruncate(2) also appeared in 4.2BSD along with truncate(2).
    (Or at least the manpage for both appeared in 4.2, I did not check the
    kernel code itself to see if either predated 4.2.)

  PR:		199472 (2)
  Submitted by:	andrew@ugh.net.au (2)
  MFC after:	1 week

Changes:
  head/lib/libc/sys/truncate.2
Comment 2 John Baldwin freebsd_committer freebsd_triage 2015-05-04 14:50:08 UTC
Committed along with some other changes, thanks!
Comment 3 commit-hook freebsd_committer freebsd_triage 2015-06-02 15:13:30 UTC
A commit references this bug:

Author: jhb
Date: Tue Jun  2 15:12:35 UTC 2015
New revision: 283916
URL: https://svnweb.freebsd.org/changeset/base/283916

Log:
  MFC 282417:
  Various updates to the ftruncate(2) documentation:
  - Note that ftruncate(2) can operate on shared memory objects and cross
    reference shm_open(2).
  - Note that ftruncate(2) does not change the file position pointer (aka
    seek pointer) of the file descriptor.
  - ftruncate(2) will fail with EINVAL for all sorts of other fd types than
    just sockets, so instead note that it fails for all but regular files and
    shared memory objects.
  - Note that ftruncate(2) also appeared in 4.2BSD along with truncate(2).
    (Or at least the manpage for both appeared in 4.2, I did not check the
    kernel code itself to see if either predated 4.2.)

  PR:		199472

Changes:
_U  stable/10/
  stable/10/lib/libc/sys/truncate.2
_U  stable/8/lib/libc/
_U  stable/8/lib/libc/sys/
  stable/8/lib/libc/sys/truncate.2
_U  stable/9/lib/libc/
_U  stable/9/lib/libc/sys/
  stable/9/lib/libc/sys/truncate.2