Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

Wernher von Braun settled for a V-2 when he coulda had a V-8.


devel / comp.unix.shell / Another annoying "find -mtime vs -ctime" question

SubjectAuthor
* Another annoying "find -mtime vs -ctime" questionOttavio Caruso
`- Re: Another annoying "find -mtime vs -ctime" questionLew Pitcher

1
Another annoying "find -mtime vs -ctime" question

<s75jqd$lu0$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=3733&group=comp.unix.shell#3733

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: ottavio2...@yahoo.com (Ottavio Caruso)
Newsgroups: comp.unix.shell
Subject: Another annoying "find -mtime vs -ctime" question
Date: Sat, 8 May 2021 09:57:48 +0100
Organization: A noiseless patient Spider
Lines: 27
Message-ID: <s75jqd$lu0$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Sat, 8 May 2021 08:57:49 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="01215d44afa79e6a88127424b64f5f1f";
logging-data="22464"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/u26l14zp0CsuigSaxMvWS3zcK45Uvj8I="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101
Thunderbird/78.3.1
Cancel-Lock: sha1:SdMSYMZ+/zeG+a+Ix47MdXZ+fZI=
Content-Language: en-GB
X-Mozilla-News-Host: snews://news.eternal-september.org:563
 by: Ottavio Caruso - Sat, 8 May 2021 08:57 UTC

I want to write a script that recursively backs up all files in a
directory that haven't changed in, say 35 years.

Caveat: the directory is a vfat directory:

$ mount|grep sda6
/dev/sda6 on /home/oc/storage type vfat
(rw,relatime,uid=1000,gid=1000,fmask=0133,dmask=0022,codepage=437,iocharset=ascii,shortname=mixed,utf8,errors=remount-ro)

$ grep storage /etc/fstab
UUID=BD49-37B5 /home/oc/storage vfat uid=1000,gid=1000,fmask=133
0

$ find /home/oc/storage/Documents/ -type f -mtime -35|wc -l
190
$ find /home/oc/storage/Documents/ -type f -ctime -35|wc -l
795

I've checked the list of all files in option -mtime vs -ctime and in
both cases I've seen files that I am pretty sure I have never touched in
the last 35 days. Conservatively, I'd go for using the -mtime option,
but I wonder if the fact the partition is vfat may skew the results from
find.

--
Ottavio Caruso

Re: Another annoying "find -mtime vs -ctime" question

<s7777o$unp$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=3737&group=comp.unix.shell#3737

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: lew.pitc...@digitalfreehold.ca (Lew Pitcher)
Newsgroups: comp.unix.shell
Subject: Re: Another annoying "find -mtime vs -ctime" question
Date: Sat, 8 May 2021 23:35:20 -0000 (UTC)
Organization: The Pitcher Digital Freehold
Lines: 67
Message-ID: <s7777o$unp$1@dont-email.me>
References: <s75jqd$lu0$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Sat, 8 May 2021 23:35:20 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="715448ee688f50d6a9aa1d4fb9878c99";
logging-data="31481"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/WyePa9TbAszxp7XQlllSlWRwxZro3Hpc="
User-Agent: Pan/0.139 (Sexual Chocolate; GIT bf56508
git://git.gnome.org/pan2)
Cancel-Lock: sha1:VzlWgIQgLVwPR2TOqSc0YaSLk9k=
 by: Lew Pitcher - Sat, 8 May 2021 23:35 UTC

On Sat, 08 May 2021 09:57:48 +0100, Ottavio Caruso wrote:

> I want to write a script that recursively backs up all files in a
> directory that haven't changed in, say 35 years.
>
> Caveat: the directory is a vfat directory:
>
> $ mount|grep sda6
> /dev/sda6 on /home/oc/storage type vfat
> (rw,relatime,uid=1000,gid=1000,fmask=0133,dmask=0022,codepage=437,iocharset=ascii,shortname=mixed,utf8,errors=remount-ro)
>
> $ grep storage /etc/fstab
> UUID=BD49-37B5 /home/oc/storage vfat uid=1000,gid=1000,fmask=133
> 0
>
> $ find /home/oc/storage/Documents/ -type f -mtime -35|wc -l
> 190
> $ find /home/oc/storage/Documents/ -type f -ctime -35|wc -l
> 795
>
> I've checked the list of all files in option -mtime vs -ctime and in
> both cases I've seen files that I am pretty sure I have never touched in
> the last 35 days. Conservatively, I'd go for using the -mtime option,
> but I wonder if the fact the partition is vfat may skew the results from
> find.

IIRC, the FAT filesystem (and the VFAT filesystem built on it) does not natively
support Unix mtime or ctime values. Indeed, the kernel documentation for the vfat
fs indicates that the vfat directory entry (the equivalent of a combined unix
directory entry /and/ a unix inode) can be described with the structure

struct directory { // Short 8.3 names
unsigned char name[8]; // file name
unsigned char ext[3]; // file extension
unsigned char attr; // attribute byte
unsigned char lcase; // Case for base and extension
unsigned char ctime_ms; // Creation time, milliseconds
unsigned char ctime[2]; // Creation time
unsigned char cdate[2]; // Creation date
unsigned char adate[2]; // Last access date
unsigned char reserved[2]; // reserved values (ignored)
unsigned char time[2]; // time stamp
unsigned char date[2]; // date stamp
unsigned char start[2]; // starting cluster number
unsigned char size[4]; // size of the file
};

Unix mtime reports the "time of last modification", while ctime reports the "time
of last inode modification", neither of which appear in a FAT directory entry.

I believe that Linux initially "fakes" the (V)FAT mtime and ctime values when retrieved
through a stat(2) call. At first, it can only use the vfat ctime or adate values
to create the faux mtime and ctime values (adate is close to, but not exactly, the
unix atime of the file, while the vfat cdate/ctime values have no stat(2) analogue).
However, as the vfat fs layer keeps a "shadow inode" entry for each vfat directory
entry, the vfat fs layer will update these faux mtime and ctime values with each
filesystem activity. Note that the faux mtime and ctime values are lost when the vfat
fs is umounted.

As to why you get inconsistant results when looking for mtimes and ctimes on vfat
filesystems, my /guess/ is that you are seeing the cumulative effects of these filesystem
compromises and translations, which are transient and activity dependant.

HTH
--
Lew Pitcher
"In Skills, We Trust"

1
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor