Package: pmount Version: 0.9.99-alpha-1 Severity: wishlist Tags: patch Dear Maintainer,
Since systemd arrived, the kernel timezone is set to the default userland timezone, and I did not find how to easily disable it yet. When mounting a VFAT filesystem, the kernel applies the current timezone offset to the timestamps. The result is that all timestamps on the other side of the daylight saving time change are off by one hour. To avoid that issue, the kernel has the "tz=UTC" option, to treat the timestamps on the filesystem as being in UTC. This has the same result as leaving the kernel in UTC time zone. pmount should allow the user to add the tz=UTC option. The following patch adds the --utc option to do exactly that. Regards, -- Nicolas George -- System Information: Debian Release: jessie/sid APT prefers testing APT policy: (500, 'testing'), (500, 'stable'), (50, 'unstable') Architecture: amd64 (x86_64) Foreign Architectures: i386 Kernel: Linux 3.14-1-amd64 (SMP w/4 CPU cores) Locale: LANG=C, LC_CTYPE=fr_FR.UTF-8 (charmap=UTF-8) Shell: /bin/sh linked to /bin/dash Versions of packages pmount depends on: ii libblkid1 2.20.1-5.8 ii libc6 2.19-7 pmount recommends no packages. Versions of packages pmount suggests: pn cryptsetup <none> -- Configuration Files: /etc/pmount.conf changed [not included] [ modified for "not_physically_logged_allow = yes" ] -- no debconf information
>From 5f3b1c93a5d241fda0829350aa09dbf7090112bb Mon Sep 17 00:00:00 2001 From: Nicolas George <geo...@nsup.org> Date: Sat, 19 Jul 2014 16:08:36 +0200 Subject: [PATCH] pmount: add --utc option. --- man/pmount.1 | 8 ++++++++ src/pmount.c | 27 ++++++++++++++++++--------- 2 files changed, 26 insertions(+), 9 deletions(-) diff --git a/man/pmount.1 b/man/pmount.1 index a9b3f95..fc4be59 100644 --- a/man/pmount.1 +++ b/man/pmount.1 @@ -194,6 +194,14 @@ currently makes the filesystem case-sensitive (which is pretty bad...). .TP +.B \fB\-\-utc +Use UTC for the timestamps on the filesystem. +Some filesystems (essentially VFAT) store the timestamps without a +timezone indication. +By default, the timestamps are interpreted relative to the +current kernel time zone without DST correction. + +.TP .B \-u \fIumask\fR, \fB\-\-umask \fIumask\fR Use specified umask instead of the default one. For UDF, the default is '000', for VFAT and NTFS the default is '077'. This value is diff --git a/src/pmount.c b/src/pmount.c index 1652deb..45a3645 100644 --- a/src/pmount.c +++ b/src/pmount.c @@ -61,6 +61,7 @@ const int E_INTERNAL = 100; #define OPT_FMASK 128 #define OPT_DMASK 129 +#define OPT_UTC 130 /** * Print some help. @@ -240,7 +241,7 @@ do_mount_fstab( const char* device ) int do_mount( const char* device, const char* mntpt, const char* fsname, int async, int noatime, int exec, int force_write, const char* iocharset, - int utf8, + int utf8, int utc, const char* umask, const char *fmask, const char *dmask, int suppress_errors ) { @@ -249,6 +250,7 @@ do_mount( const char* device, const char* mntpt, const char* fsname, int async, char umask_opt[100]; char fdmask_opt[100]; char iocharset_opt[100]; + const char* utc_opt = ""; const char* sync_opt = ",sync"; const char* atime_opt = ",atime"; const char* exec_opt = ",noexec"; @@ -350,6 +352,9 @@ do_mount( const char* device, const char* mntpt, const char* fsname, int async, else access_opt = ""; + if(! strcmp(fsname, "vfat") && utc ) + utc_opt = ",tz=UTC"; + if( iocharset && fs->iocharset_format ) { if( !is_word_str( iocharset ) ) { fprintf( stderr, _("Error: invalid charset name '%s'\n"), iocharset ); @@ -383,9 +388,9 @@ do_mount( const char* device, const char* mntpt, const char* fsname, int async, fs->iocharset_format, "iso8859-1"); } - snprintf( options, sizeof( options ), "%s%s%s%s%s%s%s%s%s", + snprintf( options, sizeof( options ), "%s%s%s%s%s%s%s%s%s%s", fs->options, sync_opt, atime_opt, exec_opt, access_opt, ugid_opt, - umask_opt, fdmask_opt, iocharset_opt ); + umask_opt, fdmask_opt, iocharset_opt, utc_opt ); /* go for it */ return spawnl( SPAWN_EROOT | SPAWN_RROOT | (suppress_errors ? SPAWN_NO_STDERR : 0 ), @@ -414,7 +419,7 @@ do_mount( const char* device, const char* mntpt, const char* fsname, int async, int do_mount_auto( const char* device, const char* mntpt, int async, int noatime, int exec, int force_write, const char* iocharset, - int utf8, + int utf8, int utc, const char* umask, const char *fmask, const char *dmask ) { const struct FS* fs; @@ -437,7 +442,7 @@ do_mount_auto( const char* device, const char* mntpt, int async, tp = "ntfs-3g"; } result = do_mount( device, mntpt, tp, async, noatime, exec, - force_write, iocharset, utf8, umask, fmask, + force_write, iocharset, utf8, utc, umask, fmask, dmask, nostderr ); if(result == 0) return result; @@ -459,14 +464,14 @@ do_mount_auto( const char* device, const char* mntpt, int async, if( (fs+1)->fsname == NULL ) nostderr = 0; result = do_mount( device, mntpt, fs->fsname, async, noatime, exec, - force_write, iocharset, utf8, umask, fmask, dmask, nostderr ); + force_write, iocharset, utf8, utc, umask, fmask, dmask, nostderr ); if( result == 0 ) break; /* sometimes VFAT fails when using iocharset; try again without */ if( iocharset ) result = do_mount( device, mntpt, fs->fsname, async, noatime, exec, - force_write, NULL, utf8, umask, fmask, dmask, nostderr ); + force_write, NULL, utf8, utc, umask, fmask, dmask, nostderr ); if( result <= 0 ) break; } @@ -673,6 +678,7 @@ main( int argc, char** argv ) const char* dmask = NULL; const char* passphrase = NULL; int utf8 = -1; /* Whether we live in a UTF-8 world or not */ + int utc = 0; /* Whether the timestamps are stored in UTC rather than local time */ int result; enum { MOUNT, LOCK, UNLOCK } mode = MOUNT; @@ -688,6 +694,7 @@ main( int argc, char** argv ) { "exec", 0, NULL, 'e' }, { "type", 1, NULL, 't' }, { "charset", 1, NULL, 'c' }, + { "utc", 0, NULL, OPT_UTC }, { "umask", 1, NULL, 'u' }, { "fmask", 1, NULL, OPT_FMASK }, { "dmask", 1, NULL, OPT_DMASK }, @@ -756,6 +763,8 @@ main( int argc, char** argv ) case 'c': iocharset = optarg; break; + case OPT_UTC: utc = 1; printf("coucou\n"); break; + case 'u': umask = optarg; break; case OPT_FMASK: fmask = optarg; break; @@ -995,12 +1004,12 @@ main( int argc, char** argv ) if( use_fstype ) result = do_mount( decrypted_device, mntpt, use_fstype, async, noatime, exec, force_write, - iocharset, utf8, umask, + iocharset, utf8, utc, umask, fmask, dmask, 0 ); else result = do_mount_auto( decrypted_device, mntpt, async, noatime, exec, force_write, - iocharset, utf8, umask, + iocharset, utf8, utc, umask, fmask, dmask ); } -- 2.0.1