Re: command date

2009-08-10 Thread Steve Ward
On Mon, Aug 10, 2009 at 20:40, Dmitri Ivanov wrote:

>
> echo $[ $(date --date="090309" +%s) - $(date --date="090308" +%s) ]
> gives 82800 instead of 86400.
> It seems that 1 hour is lost only for a special date: Mar 9, 2009
>
> Dmitri Ivanov
>
>
>

Daylight-saving time transition in USA.


command date

2009-08-10 Thread Dmitri Ivanov


echo $[ $(date --date="090309" +%s) - $(date --date="090308" +%s) ]
gives 82800 instead of 86400.
It seems that 1 hour is lost only for a special date: Mar 9, 2009

Dmitri Ivanov




chmod feature request: setting different modes for files and directories

2009-08-10 Thread Tobia Conforto

Dear coreutils maintainers,

I'd like to ask for an often needed feature of chmod: the ability to  
set different modes for files and directories. I will briefly explain  
the need, and then propose a possible syntax.


For example, to make a directory setgid, one needs to give the setgid  
permission to all sub-directories already present, but not to the  
files. Currently one has to write something like this:


find some/path -type d -exec chmod g+s {} +

Or some variation with -print0 and xargs. The same is true when  
someone extracts some files from an archive or copies them over a  
removable media, where permissions need to be reset to something sane,  
like 755/644:


chmod -R 755 another/path
find another/path -type f -exec chmod 644 {} +

These could all be written more concisely if chmod supported selection  
of permissions by inode type. Here is the syntax I'm thinking about,  
for the two examples above:


chmod -R d:g+s some/path

chmod -R d:755,f:644 another/path

This is backwards-compatible, intuitive, and concise. The character  
before the colon could be made to mimic find's -type option.


Let me know if you'd like me to come up with an implementation, or if  
there is some other list where this topic would be more appropriate.


-Tobia




Re: [PATCH] dd: work around buffer length restrictions with oflag=direct (O_DIRECT)

2009-08-10 Thread Pádraig Brady
Jim Meyering wrote:
> +#ifdef POSIX_FADV_DONTNEED
> +  off_t off = lseek (STDOUT_FILENO, 0, SEEK_CUR);
> +  if (0 <= off)
> +ignore_value (posix_fadvise (STDOUT_FILENO,
> + off, 0, POSIX_FADV_DONTNEED));
> +#endif

That reminds me that it would be nice to have
[io]flag=stream to read/write files without polluting the cache etc.

cheers,
Pádraig.





Re: BTRFS file clone support for cp

2009-08-10 Thread Pádraig Brady
Giuseppe Scrivano wrote:
> Jim Meyering  writes:
> 
>> I am now convinced that cp's new behavior belongs on
>> a separate option, --reflink (i.e., it should not be the default).
>> Giuseppe, do you feel like adding that option and adjusting your
>> test accordingly?
> 
> I attached two separate patches, --reflink option and file-clone test.
> Last versions of btrfs have a bug (I asked on #btrfs and they confirmed
> it), btrfs doesn't use correctly all the free space available.  In fact
> I get ENOSPC while in reality only 54% is used.  Probably it is better
> to postpone the second patch inclusion after the bug is fixed.

That explains some of the weirdness I noticed.
Thanks for looking into it.
(there was also weird values for `du cloned_file`)

> Another note, I changed this line in the NEWS file:
> -  "when both the source and destination are on the same btrfs partition."
> 
> considering that BTRFS supports multiple devices I am not convinced that
> it is always true, I guess source and destination could be on different
> partitions, though I couldn't find a clear answer on the btrfs wiki to
> this question.

I would very much doubt one could clone outside a single file system.
If a file system can span multiple devices/partitions then maybe.
In any case would be better to say "file system" rather than "partition",
as the latter is not directly related.

cheers,
Pádraig.




new snapshot available: coreutils-7.4.115-c9c92

2009-08-10 Thread Jim Meyering
I think we are ready for coreutils-7.5, so I have made this
snapshot release.  If you can test it on cutting-edge systems
(both operating systems and file systems),
feedback would be most welcome, especially if you can
write before the end of the week.

coreutils snapshot:
  http://meyering.net/cu/coreutils-ss.tar.gz  9.4 MB
  http://meyering.net/cu/coreutils-ss.tar.xz  4.0 MB
  http://meyering.net/cu/coreutils-ss.tar.gz.sig
  http://meyering.net/cu/coreutils-ss.tar.xz.sig
aka
  http://meyering.net/cu/coreutils-7.4.115-c9c92.tar.gz
  http://meyering.net/cu/coreutils-7.4.115-c9c92.tar.xz

NEWS
==
** Bug fixes

  dd's oflag=direct option now works even when the size of the input
  is not a multiple of e.g., 512 bytes.

  install runs faster again with SELinux enabled
  [introduced in coreutils-7.0]

  ls -1U (with two or more arguments, at least one a nonempty directory)
  would print entry names *before* the name of the containing directory.
  Also fixed incorrect output of ls -1RU and ls -1sU.
  [introduced in coreutils-7.0]

  sort now correctly ignores fields whose ending position is specified
  before the start position. Previously in numeric mode the remaining
  part of the line after the start position was used as the sort key.
  [This bug appears to have been present in "the beginning".]

  truncate -s failed to skip all whitespace in the option argument in
  some locales.

** New programs

  stdbuf: A new program to run a command with modified stdio buffering
  for its standard streams.

** Changes in behavior

  ls --color: files with multiple hard links are no longer colored differently
  by default. That can be enabled by changing the LS_COLORS environment
  variable. You can control that using the MULTIHARDLINK dircolors input
  variable which corresponds to the 'mh' LS_COLORS item. Note these variables
  were renamed from 'HARDLINK' and 'hl' which were available since
  coreutils-7.1 when this feature was introduced.

** New features

  chroot now accepts the options --userspec and --groups.

  cp accepts a new option, --reflink: create a lightweight copy
  using copy-on-write (COW).  This is currently supported only on
  btrfs file systems.

  cp now preserves time stamps on symbolic links, when possible

  cp, install, mv: take advantage of btrfs' O(1) copy-on-write feature
  when both the source and destination are on the same btrfs partition.

  sort accepts a new option, --human-numeric-sort (-h): sort numbers
  while honoring human readable suffixes like KiB and MB etc.

  tail --follow now uses inotify when possible, to be more responsive
  to file changes and more efficient when monitoring many files.


git shortlog
==
Changes in coreutils since 7.4.73-0d64b:

Giuseppe Scrivano (4):
  tail: use the inotify backend also with --pid=PID
  cp: support btrfs' copy-on-write file clone operation
  tail: exit successfully upon watched process death
  cp: accept the --reflink option

Heikki Orsila (1):
  tr: improve --help's description of --complement (-c)

Jim Meyering (29):
  build: update from gnulib
  build: avoid build warn/failure due to -Wstack-protector
  tests: avoid false-positive cp/link-heap failure
  tail: adjust type of a local variable
  doc: point to Guile's ChangeLog-writing guidelines
  build: update from gnulib
  readlink: improve one-line summary: prints canonical file names, too
  build: use a fixed-name temporary in man/Makefile.am
  tests: new test for bug in ls -1U dir arg ...
  maint: make update-copyright handle more cases
  maint: update-copyright: fix just-introduced bug
  maint: update sleep.c's copyright year list
  maint: update NEWS
  maint: make update-copyright work in yet another case
  maint: move update-copyright to gnulib
  tests: test for just-fixed tail --pid bug
  tail: tweak indentation
  tests: new function: require_openat_support_
  build: update to a usable gnulib commit
  build: *really* update to a usable gnulib commit
  maint: move the update-copyright rule to gnulib's maint.mk
  cp -pP (and e.g., -a): preserve time stamps on symlinks, too
  dd: remove unnecessary #if HAVE_FTRUNCATE
  dd: work around buffer length restrictions with oflag=direct (O_DIRECT)
  maint: move selinux-at module from gl/ to gnulib
  dd: preserve semantics of O_DIRECT even for final block
  build: update from gnulib, for HOST_NAME_MAX on solaris 10
  nl, pinky: replace uses of strcat
  tests: raise ulimit virt-mem limit to avoid new failure

Joel E. Denny (1):
  maint: improve update-copyright rule

Kamil Dudka (3):
  doc: improve readlink description here, too
  ls -1U dir arg ... now works again
  install runs faster again with SELinux enabled

Ondřej Vašík (1):
  copy.c: remov

[PATCH] nl, pinky: replace uses of strcat

2009-08-10 Thread Jim Meyering

>From e32320de66f0587f288803330ea5e09341297153 Mon Sep 17 00:00:00 2001
From: Jim Meyering 
Date: Mon, 10 Aug 2009 08:11:33 +0200
Subject: [PATCH] nl, pinky: replace uses of strcat

* src/nl.c (main): Avoid strcat, on principle.  Use stpcpy instead.
* src/pinky.c (print_long_entry): Likewise.
---
 src/nl.c|6 +++---
 src/pinky.c |   12 
 2 files changed, 7 insertions(+), 11 deletions(-)

diff --git a/src/nl.c b/src/nl.c
index 56d5a39..2deb314 100644
--- a/src/nl.c
+++ b/src/nl.c
@@ -577,15 +577,15 @@ main (int argc, char **argv)

   header_del_len = len * 3;
   header_del = xmalloc (header_del_len + 1);
-  strcat (strcat (strcpy (header_del, section_del), section_del), section_del);
+  stpcpy (stpcpy (stpcpy (header_del, section_del), section_del), section_del);

   body_del_len = len * 2;
   body_del = xmalloc (body_del_len + 1);
-  strcat (strcpy (body_del, section_del), section_del);
+  stpcpy (stpcpy (body_del, section_del), section_del);

   footer_del_len = len;
   footer_del = xmalloc (footer_del_len + 1);
-  strcpy (footer_del, section_del);
+  stpcpy (footer_del, section_del);

   /* Initialize the input buffer.  */
   initbuffer (&line_buf);
diff --git a/src/pinky.c b/src/pinky.c
index 2505236..8ddd218 100644
--- a/src/pinky.c
+++ b/src/pinky.c
@@ -363,10 +363,8 @@ print_long_entry (const char name[])
   char buf[1024];
   const char *const baseproject = "/.project";
   char *const project =
-  xmalloc (strlen (pw->pw_dir) + strlen (baseproject) + 1);
-
-  strcpy (project, pw->pw_dir);
-  strcat (project, baseproject);
+xmalloc (strlen (pw->pw_dir) + strlen (baseproject) + 1);
+  stpcpy (stpcpy (project, pw->pw_dir), baseproject);

   stream = fopen (project, "r");
   if (stream)
@@ -389,10 +387,8 @@ print_long_entry (const char name[])
   char buf[1024];
   const char *const baseplan = "/.plan";
   char *const plan =
-  xmalloc (strlen (pw->pw_dir) + strlen (baseplan) + 1);
-
-  strcpy (plan, pw->pw_dir);
-  strcat (plan, baseplan);
+xmalloc (strlen (pw->pw_dir) + strlen (baseplan) + 1);
+  stpcpy (stpcpy (plan, pw->pw_dir), baseplan);

   stream = fopen (plan, "r");
   if (stream)
--
1.6.4.284.g34125