License cleanup: add SPDX GPL-2.0 license identifier to files with no license
Many source files in the tree are missing licensing information, which
makes it harder for compliance tools to determine the correct license.
By default all files without license information are under the default
license of the kernel, which is GPL version 2.
Update the files which contain no license information with the 'GPL-2.0'
SPDX license identifier. The SPDX identifier is a legally binding
shorthand, which can be used instead of the full boiler plate text.
This patch is based on work done by Thomas Gleixner and Kate Stewart and
Philippe Ombredanne.
How this work was done:
Patches were generated and checked against linux-4.14-rc6 for a subset of
the use cases:
- file had no licensing information it it.
- file was a */uapi/* one with no licensing information in it,
- file was a */uapi/* one with existing licensing information,
Further patches will be generated in subsequent months to fix up cases
where non-standard license headers were used, and references to license
had to be inferred by heuristics based on keywords.
The analysis to determine which SPDX License Identifier to be applied to
a file was done in a spreadsheet of side by side results from of the
output of two independent scanners (ScanCode & Windriver) producing SPDX
tag:value files created by Philippe Ombredanne. Philippe prepared the
base worksheet, and did an initial spot review of a few 1000 files.
The 4.13 kernel was the starting point of the analysis with 60,537 files
assessed. Kate Stewart did a file by file comparison of the scanner
results in the spreadsheet to determine which SPDX license identifier(s)
to be applied to the file. She confirmed any determination that was not
immediately clear with lawyers working with the Linux Foundation.
Criteria used to select files for SPDX license identifier tagging was:
- Files considered eligible had to be source code files.
- Make and config files were included as candidates if they contained >5
lines of source
- File already had some variant of a license header in it (even if <5
lines).
All documentation files were explicitly excluded.
The following heuristics were used to determine which SPDX license
identifiers to apply.
- when both scanners couldn't find any license traces, file was
considered to have no license information in it, and the top level
COPYING file license applied.
For non */uapi/* files that summary was:
SPDX license identifier # files
---------------------------------------------------|-------
GPL-2.0 11139
and resulted in the first patch in this series.
If that file was a */uapi/* path one, it was "GPL-2.0 WITH
Linux-syscall-note" otherwise it was "GPL-2.0". Results of that was:
SPDX license identifier # files
---------------------------------------------------|-------
GPL-2.0 WITH Linux-syscall-note 930
and resulted in the second patch in this series.
- if a file had some form of licensing information in it, and was one
of the */uapi/* ones, it was denoted with the Linux-syscall-note if
any GPL family license was found in the file or had no licensing in
it (per prior point). Results summary:
SPDX license identifier # files
---------------------------------------------------|------
GPL-2.0 WITH Linux-syscall-note 270
GPL-2.0+ WITH Linux-syscall-note 169
((GPL-2.0 WITH Linux-syscall-note) OR BSD-2-Clause) 21
((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause) 17
LGPL-2.1+ WITH Linux-syscall-note 15
GPL-1.0+ WITH Linux-syscall-note 14
((GPL-2.0+ WITH Linux-syscall-note) OR BSD-3-Clause) 5
LGPL-2.0+ WITH Linux-syscall-note 4
LGPL-2.1 WITH Linux-syscall-note 3
((GPL-2.0 WITH Linux-syscall-note) OR MIT) 3
((GPL-2.0 WITH Linux-syscall-note) AND MIT) 1
and that resulted in the third patch in this series.
- when the two scanners agreed on the detected license(s), that became
the concluded license(s).
- when there was disagreement between the two scanners (one detected a
license but the other didn't, or they both detected different
licenses) a manual inspection of the file occurred.
- In most cases a manual inspection of the information in the file
resulted in a clear resolution of the license that should apply (and
which scanner probably needed to revisit its heuristics).
- When it was not immediately clear, the license identifier was
confirmed with lawyers working with the Linux Foundation.
- If there was any question as to the appropriate license identifier,
the file was flagged for further research and to be revisited later
in time.
In total, over 70 hours of logged manual review was done on the
spreadsheet to determine the SPDX license identifiers to apply to the
source files by Kate, Philippe, Thomas and, in some cases, confirmation
by lawyers working with the Linux Foundation.
Kate also obtained a third independent scan of the 4.13 code base from
FOSSology, and compared selected files where the other two scanners
disagreed against that SPDX file, to see if there was new insights. The
Windriver scanner is based on an older version of FOSSology in part, so
they are related.
Thomas did random spot checks in about 500 files from the spreadsheets
for the uapi headers and agreed with SPDX license identifier in the
files he inspected. For the non-uapi files Thomas did random spot checks
in about 15000 files.
In initial set of patches against 4.14-rc6, 3 files were found to have
copy/paste license identifier errors, and have been fixed to reflect the
correct identifier.
Additionally Philippe spent 10 hours this week doing a detailed manual
inspection and review of the 12,461 patched files from the initial patch
version early this week with:
- a full scancode scan run, collecting the matched texts, detected
license ids and scores
- reviewing anything where there was a license detected (about 500+
files) to ensure that the applied SPDX license was correct
- reviewing anything where there was no detection but the patch license
was not GPL-2.0 WITH Linux-syscall-note to ensure that the applied
SPDX license was correct
This produced a worksheet with 20 files needing minor correction. This
worksheet was then exported into 3 different .csv files for the
different types of files to be modified.
These .csv files were then reviewed by Greg. Thomas wrote a script to
parse the csv files and add the proper SPDX tag to the file, in the
format that the file expected. This script was further refined by Greg
based on the output to detect more types of files automatically and to
distinguish between header and source .c files (which need different
comment types.) Finally Greg ran the script using the .csv files to
generate the patches.
Reviewed-by: Kate Stewart <kstewart@linuxfoundation.org>
Reviewed-by: Philippe Ombredanne <pombredanne@nexb.com>
Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-11-01 22:07:57 +08:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0 */
|
2005-04-17 06:20:36 +08:00
|
|
|
/*
|
|
|
|
* linux/include/linux/hfsplus_fs.h
|
|
|
|
*
|
|
|
|
* Copyright (C) 1999
|
|
|
|
* Brad Boyer (flar@pants.nu)
|
|
|
|
* (C) 2003 Ardis Technologies <roman@ardistech.com>
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _LINUX_HFSPLUS_FS_H
|
|
|
|
#define _LINUX_HFSPLUS_FS_H
|
|
|
|
|
2013-05-01 06:27:55 +08:00
|
|
|
#ifdef pr_fmt
|
|
|
|
#undef pr_fmt
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
#include <linux/fs.h>
|
2008-07-25 16:46:36 +08:00
|
|
|
#include <linux/mutex.h>
|
2005-04-17 06:20:36 +08:00
|
|
|
#include <linux/buffer_head.h>
|
2011-07-18 23:06:23 +08:00
|
|
|
#include <linux/blkdev.h>
|
2005-04-17 06:20:36 +08:00
|
|
|
#include "hfsplus_raw.h"
|
|
|
|
|
|
|
|
#define DBG_BNODE_REFS 0x00000001
|
|
|
|
#define DBG_BNODE_MOD 0x00000002
|
|
|
|
#define DBG_CAT_MOD 0x00000004
|
|
|
|
#define DBG_INODE 0x00000008
|
|
|
|
#define DBG_SUPER 0x00000010
|
|
|
|
#define DBG_EXTENT 0x00000020
|
|
|
|
#define DBG_BITMAP 0x00000040
|
2013-02-28 09:03:04 +08:00
|
|
|
#define DBG_ATTR_MOD 0x00000080
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2010-12-17 00:08:39 +08:00
|
|
|
#if 0
|
|
|
|
#define DBG_MASK (DBG_EXTENT|DBG_INODE|DBG_BNODE_MOD)
|
|
|
|
#define DBG_MASK (DBG_BNODE_MOD|DBG_CAT_MOD|DBG_INODE)
|
|
|
|
#define DBG_MASK (DBG_CAT_MOD|DBG_BNODE_REFS|DBG_INODE|DBG_EXTENT)
|
|
|
|
#endif
|
2005-04-17 06:20:36 +08:00
|
|
|
#define DBG_MASK (0)
|
|
|
|
|
2013-05-01 06:27:55 +08:00
|
|
|
#define hfs_dbg(flg, fmt, ...) \
|
|
|
|
do { \
|
|
|
|
if (DBG_##flg & DBG_MASK) \
|
|
|
|
printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__); \
|
2013-05-01 06:27:54 +08:00
|
|
|
} while (0)
|
|
|
|
|
2013-05-01 06:27:55 +08:00
|
|
|
#define hfs_dbg_cont(flg, fmt, ...) \
|
|
|
|
do { \
|
|
|
|
if (DBG_##flg & DBG_MASK) \
|
|
|
|
pr_cont(fmt, ##__VA_ARGS__); \
|
2013-05-01 06:27:54 +08:00
|
|
|
} while (0)
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/* Runtime config options */
|
|
|
|
#define HFSPLUS_DEF_CR_TYPE 0x3F3F3F3F /* '????' */
|
|
|
|
|
|
|
|
#define HFSPLUS_TYPE_DATA 0x00
|
|
|
|
#define HFSPLUS_TYPE_RSRC 0xFF
|
|
|
|
|
2010-12-17 00:08:38 +08:00
|
|
|
typedef int (*btree_keycmp)(const hfsplus_btree_key *,
|
|
|
|
const hfsplus_btree_key *);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
#define NODE_HASH_SIZE 256
|
|
|
|
|
2013-02-28 09:03:04 +08:00
|
|
|
/* B-tree mutex nested subclasses */
|
|
|
|
enum hfsplus_btree_mutex_classes {
|
|
|
|
CATALOG_BTREE_MUTEX,
|
|
|
|
EXTENTS_BTREE_MUTEX,
|
|
|
|
ATTR_BTREE_MUTEX,
|
|
|
|
};
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
/* An HFS+ BTree held in memory */
|
|
|
|
struct hfs_btree {
|
|
|
|
struct super_block *sb;
|
|
|
|
struct inode *inode;
|
|
|
|
btree_keycmp keycmp;
|
|
|
|
|
|
|
|
u32 cnid;
|
|
|
|
u32 root;
|
|
|
|
u32 leaf_count;
|
|
|
|
u32 leaf_head;
|
|
|
|
u32 leaf_tail;
|
|
|
|
u32 node_count;
|
|
|
|
u32 free_nodes;
|
|
|
|
u32 attributes;
|
|
|
|
|
|
|
|
unsigned int node_size;
|
|
|
|
unsigned int node_size_shift;
|
|
|
|
unsigned int max_key_len;
|
|
|
|
unsigned int depth;
|
|
|
|
|
2010-10-01 11:46:52 +08:00
|
|
|
struct mutex tree_lock;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
unsigned int pages_per_bnode;
|
|
|
|
spinlock_t hash_lock;
|
|
|
|
struct hfs_bnode *node_hash[NODE_HASH_SIZE];
|
|
|
|
int node_hash_cnt;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct page;
|
|
|
|
|
|
|
|
/* An HFS+ BTree node in memory */
|
|
|
|
struct hfs_bnode {
|
|
|
|
struct hfs_btree *tree;
|
|
|
|
|
|
|
|
u32 prev;
|
|
|
|
u32 this;
|
|
|
|
u32 next;
|
|
|
|
u32 parent;
|
|
|
|
|
|
|
|
u16 num_recs;
|
|
|
|
u8 type;
|
|
|
|
u8 height;
|
|
|
|
|
|
|
|
struct hfs_bnode *next_hash;
|
|
|
|
unsigned long flags;
|
|
|
|
wait_queue_head_t lock_wq;
|
|
|
|
atomic_t refcnt;
|
|
|
|
unsigned int page_offset;
|
|
|
|
struct page *page[0];
|
|
|
|
};
|
|
|
|
|
|
|
|
#define HFS_BNODE_LOCK 0
|
|
|
|
#define HFS_BNODE_ERROR 1
|
|
|
|
#define HFS_BNODE_NEW 2
|
|
|
|
#define HFS_BNODE_DIRTY 3
|
|
|
|
#define HFS_BNODE_DELETED 4
|
|
|
|
|
2013-11-13 07:11:09 +08:00
|
|
|
/*
|
|
|
|
* Attributes file states
|
|
|
|
*/
|
|
|
|
#define HFSPLUS_EMPTY_ATTR_TREE 0
|
|
|
|
#define HFSPLUS_CREATING_ATTR_TREE 1
|
|
|
|
#define HFSPLUS_VALID_ATTR_TREE 2
|
|
|
|
#define HFSPLUS_FAILED_ATTR_TREE 3
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
/*
|
|
|
|
* HFS+ superblock info (built from Volume Header on disk)
|
|
|
|
*/
|
|
|
|
|
|
|
|
struct hfsplus_vh;
|
|
|
|
struct hfs_btree;
|
|
|
|
|
|
|
|
struct hfsplus_sb_info {
|
2011-07-18 23:06:23 +08:00
|
|
|
void *s_vhdr_buf;
|
2005-04-17 06:20:36 +08:00
|
|
|
struct hfsplus_vh *s_vhdr;
|
2011-07-18 23:06:23 +08:00
|
|
|
void *s_backup_vhdr_buf;
|
2010-11-23 21:37:47 +08:00
|
|
|
struct hfsplus_vh *s_backup_vhdr;
|
2005-04-17 06:20:36 +08:00
|
|
|
struct hfs_btree *ext_tree;
|
|
|
|
struct hfs_btree *cat_tree;
|
|
|
|
struct hfs_btree *attr_tree;
|
2013-11-13 07:11:09 +08:00
|
|
|
atomic_t attr_tree_state;
|
2005-04-17 06:20:36 +08:00
|
|
|
struct inode *alloc_file;
|
|
|
|
struct inode *hidden_dir;
|
|
|
|
struct nls_table *nls;
|
|
|
|
|
|
|
|
/* Runtime variables */
|
|
|
|
u32 blockoffset;
|
2010-11-23 21:37:47 +08:00
|
|
|
sector_t part_start;
|
|
|
|
sector_t sect_count;
|
2005-04-17 06:20:36 +08:00
|
|
|
int fs_shift;
|
|
|
|
|
2010-10-01 11:45:08 +08:00
|
|
|
/* immutable data from the volume header */
|
2005-04-17 06:20:36 +08:00
|
|
|
u32 alloc_blksz;
|
|
|
|
int alloc_blksz_shift;
|
|
|
|
u32 total_blocks;
|
2010-10-01 11:45:08 +08:00
|
|
|
u32 data_clump_blocks, rsrc_clump_blocks;
|
|
|
|
|
|
|
|
/* mutable data from the volume header, protected by alloc_mutex */
|
2005-04-17 06:20:36 +08:00
|
|
|
u32 free_blocks;
|
2010-10-01 11:45:08 +08:00
|
|
|
struct mutex alloc_mutex;
|
|
|
|
|
|
|
|
/* mutable data from the volume header, protected by vh_mutex */
|
2005-04-17 06:20:36 +08:00
|
|
|
u32 next_cnid;
|
|
|
|
u32 file_count;
|
|
|
|
u32 folder_count;
|
2010-10-01 11:45:08 +08:00
|
|
|
struct mutex vh_mutex;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/* Config options */
|
|
|
|
u32 creator;
|
|
|
|
u32 type;
|
|
|
|
|
|
|
|
umode_t umask;
|
2012-02-08 08:27:17 +08:00
|
|
|
kuid_t uid;
|
|
|
|
kgid_t gid;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
int part, session;
|
|
|
|
unsigned long flags;
|
2012-07-12 22:26:31 +08:00
|
|
|
|
|
|
|
int work_queued; /* non-zero delayed work is queued */
|
|
|
|
struct delayed_work sync_work; /* FS sync delayed work */
|
|
|
|
spinlock_t work_lock; /* protects sync_work and work_queued */
|
2005-04-17 06:20:36 +08:00
|
|
|
};
|
|
|
|
|
2010-10-01 11:45:20 +08:00
|
|
|
#define HFSPLUS_SB_WRITEBACKUP 0
|
|
|
|
#define HFSPLUS_SB_NODECOMPOSE 1
|
|
|
|
#define HFSPLUS_SB_FORCE 2
|
|
|
|
#define HFSPLUS_SB_HFSX 3
|
|
|
|
#define HFSPLUS_SB_CASEFOLD 4
|
2010-11-23 21:38:21 +08:00
|
|
|
#define HFSPLUS_SB_NOBARRIER 5
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2010-11-23 21:38:15 +08:00
|
|
|
static inline struct hfsplus_sb_info *HFSPLUS_SB(struct super_block *sb)
|
|
|
|
{
|
|
|
|
return sb->s_fs_info;
|
|
|
|
}
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
|
|
|
|
struct hfsplus_inode_info {
|
|
|
|
atomic_t opencnt;
|
|
|
|
|
2010-10-01 11:46:31 +08:00
|
|
|
/*
|
|
|
|
* Extent allocation information, protected by extents_lock.
|
|
|
|
*/
|
|
|
|
u32 first_blocks;
|
|
|
|
u32 clump_blocks;
|
|
|
|
u32 alloc_blocks;
|
|
|
|
u32 cached_start;
|
|
|
|
u32 cached_blocks;
|
|
|
|
hfsplus_extent_rec first_extents;
|
|
|
|
hfsplus_extent_rec cached_extents;
|
2010-11-23 21:38:13 +08:00
|
|
|
unsigned int extent_state;
|
2010-10-01 11:46:31 +08:00
|
|
|
struct mutex extents_lock;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2010-10-01 11:46:31 +08:00
|
|
|
/*
|
|
|
|
* Immutable data.
|
|
|
|
*/
|
|
|
|
struct inode *rsrc_inode;
|
2006-01-19 09:43:09 +08:00
|
|
|
__be32 create_date;
|
2010-10-14 21:54:28 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Protected by sbi->vh_mutex.
|
|
|
|
*/
|
|
|
|
u32 linkid;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2010-11-23 21:38:13 +08:00
|
|
|
/*
|
|
|
|
* Accessed using atomic bitops.
|
|
|
|
*/
|
|
|
|
unsigned long flags;
|
|
|
|
|
2010-10-01 11:46:31 +08:00
|
|
|
/*
|
|
|
|
* Protected by i_mutex.
|
|
|
|
*/
|
|
|
|
sector_t fs_blocks;
|
2010-10-14 21:54:33 +08:00
|
|
|
u8 userflags; /* BSD user file flags */
|
2014-03-11 06:49:51 +08:00
|
|
|
u32 subfolders; /* Subfolder count (HFSX only) */
|
2005-04-17 06:20:36 +08:00
|
|
|
struct list_head open_dir_list;
|
2016-05-13 08:02:09 +08:00
|
|
|
spinlock_t open_dir_lock;
|
2005-04-17 06:20:36 +08:00
|
|
|
loff_t phys_size;
|
2010-10-01 11:46:31 +08:00
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
struct inode vfs_inode;
|
|
|
|
};
|
|
|
|
|
2010-11-23 21:38:13 +08:00
|
|
|
#define HFSPLUS_EXT_DIRTY 0x0001
|
|
|
|
#define HFSPLUS_EXT_NEW 0x0002
|
|
|
|
|
|
|
|
#define HFSPLUS_I_RSRC 0 /* represents a resource fork */
|
2010-11-23 21:38:15 +08:00
|
|
|
#define HFSPLUS_I_CAT_DIRTY 1 /* has changes in the catalog tree */
|
|
|
|
#define HFSPLUS_I_EXT_DIRTY 2 /* has changes in the extent tree */
|
|
|
|
#define HFSPLUS_I_ALLOC_DIRTY 3 /* has changes in the allocation file */
|
2013-02-28 09:03:04 +08:00
|
|
|
#define HFSPLUS_I_ATTR_DIRTY 4 /* has changes in the attributes tree */
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2010-11-23 21:38:13 +08:00
|
|
|
#define HFSPLUS_IS_RSRC(inode) \
|
|
|
|
test_bit(HFSPLUS_I_RSRC, &HFSPLUS_I(inode)->flags)
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2010-11-23 21:38:15 +08:00
|
|
|
static inline struct hfsplus_inode_info *HFSPLUS_I(struct inode *inode)
|
|
|
|
{
|
2015-03-19 19:28:04 +08:00
|
|
|
return container_of(inode, struct hfsplus_inode_info, vfs_inode);
|
2010-11-23 21:38:15 +08:00
|
|
|
}
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2010-11-23 21:38:15 +08:00
|
|
|
/*
|
|
|
|
* Mark an inode dirty, and also mark the btree in which the
|
|
|
|
* specific type of metadata is stored.
|
|
|
|
* For data or metadata that gets written back by into the catalog btree
|
|
|
|
* by hfsplus_write_inode a plain mark_inode_dirty call is enough.
|
|
|
|
*/
|
|
|
|
static inline void hfsplus_mark_inode_dirty(struct inode *inode,
|
|
|
|
unsigned int flag)
|
|
|
|
{
|
|
|
|
set_bit(flag, &HFSPLUS_I(inode)->flags);
|
|
|
|
mark_inode_dirty(inode);
|
|
|
|
}
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
struct hfs_find_data {
|
|
|
|
/* filled by caller */
|
|
|
|
hfsplus_btree_key *search_key;
|
|
|
|
hfsplus_btree_key *key;
|
|
|
|
/* filled by find */
|
|
|
|
struct hfs_btree *tree;
|
|
|
|
struct hfs_bnode *bnode;
|
|
|
|
/* filled by findrec */
|
|
|
|
int record;
|
|
|
|
int keyoffset, keylength;
|
|
|
|
int entryoffset, entrylength;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct hfsplus_readdir_data {
|
|
|
|
struct list_head list;
|
|
|
|
struct file *file;
|
|
|
|
struct hfsplus_cat_key key;
|
|
|
|
};
|
|
|
|
|
2011-07-18 23:06:23 +08:00
|
|
|
/*
|
|
|
|
* Find minimum acceptible I/O size for an hfsplus sb.
|
|
|
|
*/
|
|
|
|
static inline unsigned short hfsplus_min_io_size(struct super_block *sb)
|
|
|
|
{
|
|
|
|
return max_t(unsigned short, bdev_logical_block_size(sb->s_bdev),
|
|
|
|
HFSPLUS_SECTOR_SIZE);
|
|
|
|
}
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
#define hfs_btree_open hfsplus_btree_open
|
|
|
|
#define hfs_btree_close hfsplus_btree_close
|
|
|
|
#define hfs_btree_write hfsplus_btree_write
|
2018-10-31 06:06:14 +08:00
|
|
|
#define hfs_bmap_reserve hfsplus_bmap_reserve
|
2005-04-17 06:20:36 +08:00
|
|
|
#define hfs_bmap_alloc hfsplus_bmap_alloc
|
|
|
|
#define hfs_bmap_free hfsplus_bmap_free
|
|
|
|
#define hfs_bnode_read hfsplus_bnode_read
|
|
|
|
#define hfs_bnode_read_u16 hfsplus_bnode_read_u16
|
|
|
|
#define hfs_bnode_read_u8 hfsplus_bnode_read_u8
|
|
|
|
#define hfs_bnode_read_key hfsplus_bnode_read_key
|
|
|
|
#define hfs_bnode_write hfsplus_bnode_write
|
|
|
|
#define hfs_bnode_write_u16 hfsplus_bnode_write_u16
|
|
|
|
#define hfs_bnode_clear hfsplus_bnode_clear
|
|
|
|
#define hfs_bnode_copy hfsplus_bnode_copy
|
|
|
|
#define hfs_bnode_move hfsplus_bnode_move
|
|
|
|
#define hfs_bnode_dump hfsplus_bnode_dump
|
|
|
|
#define hfs_bnode_unlink hfsplus_bnode_unlink
|
|
|
|
#define hfs_bnode_findhash hfsplus_bnode_findhash
|
|
|
|
#define hfs_bnode_find hfsplus_bnode_find
|
|
|
|
#define hfs_bnode_unhash hfsplus_bnode_unhash
|
|
|
|
#define hfs_bnode_free hfsplus_bnode_free
|
|
|
|
#define hfs_bnode_create hfsplus_bnode_create
|
|
|
|
#define hfs_bnode_get hfsplus_bnode_get
|
|
|
|
#define hfs_bnode_put hfsplus_bnode_put
|
|
|
|
#define hfs_brec_lenoff hfsplus_brec_lenoff
|
|
|
|
#define hfs_brec_keylen hfsplus_brec_keylen
|
|
|
|
#define hfs_brec_insert hfsplus_brec_insert
|
|
|
|
#define hfs_brec_remove hfsplus_brec_remove
|
|
|
|
#define hfs_find_init hfsplus_find_init
|
|
|
|
#define hfs_find_exit hfsplus_find_exit
|
2013-02-28 09:03:04 +08:00
|
|
|
#define __hfs_brec_find __hfsplus_brec_find
|
2005-04-17 06:20:36 +08:00
|
|
|
#define hfs_brec_find hfsplus_brec_find
|
|
|
|
#define hfs_brec_read hfsplus_brec_read
|
|
|
|
#define hfs_brec_goto hfsplus_brec_goto
|
|
|
|
#define hfs_part_find hfsplus_part_find
|
|
|
|
|
|
|
|
/*
|
|
|
|
* definitions for ext2 flag ioctls (linux really needs a generic
|
|
|
|
* interface for this).
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* ext2 ioctls (EXT2_IOC_GETFLAGS and EXT2_IOC_SETFLAGS) to support
|
|
|
|
* chattr/lsattr */
|
2006-08-30 02:06:16 +08:00
|
|
|
#define HFSPLUS_IOC_EXT2_GETFLAGS FS_IOC_GETFLAGS
|
|
|
|
#define HFSPLUS_IOC_EXT2_SETFLAGS FS_IOC_SETFLAGS
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
|
2012-02-07 04:14:40 +08:00
|
|
|
/*
|
|
|
|
* hfs+-specific ioctl for making the filesystem bootable
|
|
|
|
*/
|
|
|
|
#define HFSPLUS_IOC_BLESS _IO('h', 0x80)
|
|
|
|
|
2013-02-28 09:03:04 +08:00
|
|
|
typedef int (*search_strategy_t)(struct hfs_bnode *,
|
|
|
|
struct hfs_find_data *,
|
|
|
|
int *, int *, int *);
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
/*
|
|
|
|
* Functions in any *.c used in other files
|
|
|
|
*/
|
|
|
|
|
2013-02-28 09:03:04 +08:00
|
|
|
/* attributes.c */
|
2014-04-04 05:50:35 +08:00
|
|
|
int __init hfsplus_create_attr_tree_cache(void);
|
2013-02-28 09:03:04 +08:00
|
|
|
void hfsplus_destroy_attr_tree_cache(void);
|
2014-06-07 05:36:30 +08:00
|
|
|
int hfsplus_attr_bin_cmp_key(const hfsplus_btree_key *k1,
|
|
|
|
const hfsplus_btree_key *k2);
|
|
|
|
int hfsplus_attr_build_key(struct super_block *sb, hfsplus_btree_key *key,
|
|
|
|
u32 cnid, const char *name);
|
2013-02-28 09:03:04 +08:00
|
|
|
hfsplus_attr_entry *hfsplus_alloc_attr_entry(void);
|
2014-06-07 05:36:30 +08:00
|
|
|
void hfsplus_destroy_attr_entry(hfsplus_attr_entry *entry);
|
|
|
|
int hfsplus_find_attr(struct super_block *sb, u32 cnid, const char *name,
|
|
|
|
struct hfs_find_data *fd);
|
2013-02-28 09:03:04 +08:00
|
|
|
int hfsplus_attr_exists(struct inode *inode, const char *name);
|
2014-06-07 05:36:30 +08:00
|
|
|
int hfsplus_create_attr(struct inode *inode, const char *name,
|
|
|
|
const void *value, size_t size);
|
|
|
|
int hfsplus_delete_attr(struct inode *inode, const char *name);
|
2013-02-28 09:03:04 +08:00
|
|
|
int hfsplus_delete_all_attrs(struct inode *dir, u32 cnid);
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
/* bitmap.c */
|
2014-06-07 05:36:30 +08:00
|
|
|
int hfsplus_block_allocate(struct super_block *sb, u32 size, u32 offset,
|
|
|
|
u32 *max);
|
|
|
|
int hfsplus_block_free(struct super_block *sb, u32 offset, u32 count);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/* btree.c */
|
2014-06-07 05:36:30 +08:00
|
|
|
u32 hfsplus_calc_btree_clump_size(u32 block_size, u32 node_size, u64 sectors,
|
|
|
|
int file_id);
|
|
|
|
struct hfs_btree *hfs_btree_open(struct super_block *sb, u32 id);
|
|
|
|
void hfs_btree_close(struct hfs_btree *tree);
|
|
|
|
int hfs_btree_write(struct hfs_btree *tree);
|
2018-10-31 06:06:14 +08:00
|
|
|
int hfs_bmap_reserve(struct hfs_btree *tree, int rsvd_nodes);
|
2014-06-07 05:36:30 +08:00
|
|
|
struct hfs_bnode *hfs_bmap_alloc(struct hfs_btree *tree);
|
|
|
|
void hfs_bmap_free(struct hfs_bnode *node);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/* bnode.c */
|
2014-06-07 05:36:30 +08:00
|
|
|
void hfs_bnode_read(struct hfs_bnode *node, void *buf, int off, int len);
|
|
|
|
u16 hfs_bnode_read_u16(struct hfs_bnode *node, int off);
|
|
|
|
u8 hfs_bnode_read_u8(struct hfs_bnode *node, int off);
|
|
|
|
void hfs_bnode_read_key(struct hfs_bnode *node, void *key, int off);
|
|
|
|
void hfs_bnode_write(struct hfs_bnode *node, void *buf, int off, int len);
|
|
|
|
void hfs_bnode_write_u16(struct hfs_bnode *node, int off, u16 data);
|
|
|
|
void hfs_bnode_clear(struct hfs_bnode *node, int off, int len);
|
|
|
|
void hfs_bnode_copy(struct hfs_bnode *dst_node, int dst,
|
|
|
|
struct hfs_bnode *src_node, int src, int len);
|
|
|
|
void hfs_bnode_move(struct hfs_bnode *node, int dst, int src, int len);
|
|
|
|
void hfs_bnode_dump(struct hfs_bnode *node);
|
|
|
|
void hfs_bnode_unlink(struct hfs_bnode *node);
|
|
|
|
struct hfs_bnode *hfs_bnode_findhash(struct hfs_btree *tree, u32 cnid);
|
|
|
|
void hfs_bnode_unhash(struct hfs_bnode *node);
|
|
|
|
struct hfs_bnode *hfs_bnode_find(struct hfs_btree *tree, u32 num);
|
|
|
|
void hfs_bnode_free(struct hfs_bnode *node);
|
|
|
|
struct hfs_bnode *hfs_bnode_create(struct hfs_btree *tree, u32 num);
|
|
|
|
void hfs_bnode_get(struct hfs_bnode *node);
|
|
|
|
void hfs_bnode_put(struct hfs_bnode *node);
|
|
|
|
bool hfs_bnode_need_zeroout(struct hfs_btree *tree);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/* brec.c */
|
2014-06-07 05:36:30 +08:00
|
|
|
u16 hfs_brec_lenoff(struct hfs_bnode *node, u16 rec, u16 *off);
|
|
|
|
u16 hfs_brec_keylen(struct hfs_bnode *node, u16 rec);
|
|
|
|
int hfs_brec_insert(struct hfs_find_data *fd, void *entry, int entry_len);
|
|
|
|
int hfs_brec_remove(struct hfs_find_data *fd);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/* bfind.c */
|
2014-06-07 05:36:30 +08:00
|
|
|
int hfs_find_init(struct hfs_btree *tree, struct hfs_find_data *fd);
|
|
|
|
void hfs_find_exit(struct hfs_find_data *fd);
|
|
|
|
int hfs_find_1st_rec_by_cnid(struct hfs_bnode *bnode, struct hfs_find_data *fd,
|
|
|
|
int *begin, int *end, int *cur_rec);
|
|
|
|
int hfs_find_rec_by_key(struct hfs_bnode *bnode, struct hfs_find_data *fd,
|
|
|
|
int *begin, int *end, int *cur_rec);
|
|
|
|
int __hfs_brec_find(struct hfs_bnode *bnode, struct hfs_find_data *fd,
|
|
|
|
search_strategy_t rec_found);
|
|
|
|
int hfs_brec_find(struct hfs_find_data *fd, search_strategy_t do_key_compare);
|
|
|
|
int hfs_brec_read(struct hfs_find_data *fd, void *rec, int rec_len);
|
|
|
|
int hfs_brec_goto(struct hfs_find_data *fd, int cnt);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/* catalog.c */
|
2014-06-07 05:36:30 +08:00
|
|
|
int hfsplus_cat_case_cmp_key(const hfsplus_btree_key *k1,
|
|
|
|
const hfsplus_btree_key *k2);
|
|
|
|
int hfsplus_cat_bin_cmp_key(const hfsplus_btree_key *k1,
|
|
|
|
const hfsplus_btree_key *k2);
|
2014-12-19 08:17:12 +08:00
|
|
|
int hfsplus_cat_build_key(struct super_block *sb, hfsplus_btree_key *key,
|
2016-07-21 04:17:26 +08:00
|
|
|
u32 parent, const struct qstr *str);
|
2014-12-19 08:17:12 +08:00
|
|
|
void hfsplus_cat_build_key_with_cnid(struct super_block *sb,
|
|
|
|
hfsplus_btree_key *key, u32 parent);
|
2010-10-14 21:54:39 +08:00
|
|
|
void hfsplus_cat_set_perms(struct inode *inode, struct hfsplus_perm *perms);
|
2014-06-07 05:36:30 +08:00
|
|
|
int hfsplus_find_cat(struct super_block *sb, u32 cnid,
|
|
|
|
struct hfs_find_data *fd);
|
2016-07-21 04:17:26 +08:00
|
|
|
int hfsplus_create_cat(u32 cnid, struct inode *dir, const struct qstr *str,
|
2014-06-07 05:36:30 +08:00
|
|
|
struct inode *inode);
|
2016-07-21 04:17:26 +08:00
|
|
|
int hfsplus_delete_cat(u32 cnid, struct inode *dir, const struct qstr *str);
|
|
|
|
int hfsplus_rename_cat(u32 cnid, struct inode *src_dir, const struct qstr *src_name,
|
|
|
|
struct inode *dst_dir, const struct qstr *dst_name);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2008-04-29 15:58:52 +08:00
|
|
|
/* dir.c */
|
|
|
|
extern const struct inode_operations hfsplus_dir_inode_operations;
|
|
|
|
extern const struct file_operations hfsplus_dir_operations;
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
/* extents.c */
|
2014-06-07 05:36:30 +08:00
|
|
|
int hfsplus_ext_cmp_key(const hfsplus_btree_key *k1,
|
|
|
|
const hfsplus_btree_key *k2);
|
|
|
|
int hfsplus_ext_write_extent(struct inode *inode);
|
|
|
|
int hfsplus_get_block(struct inode *inode, sector_t iblock,
|
|
|
|
struct buffer_head *bh_result, int create);
|
|
|
|
int hfsplus_free_fork(struct super_block *sb, u32 cnid,
|
|
|
|
struct hfsplus_fork_raw *fork, int type);
|
|
|
|
int hfsplus_file_extend(struct inode *inode, bool zeroout);
|
|
|
|
void hfsplus_file_truncate(struct inode *inode);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/* inode.c */
|
2006-06-28 19:26:44 +08:00
|
|
|
extern const struct address_space_operations hfsplus_aops;
|
|
|
|
extern const struct address_space_operations hfsplus_btree_aops;
|
2009-02-20 13:55:13 +08:00
|
|
|
extern const struct dentry_operations hfsplus_dentry_operations;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2018-02-07 07:49:02 +08:00
|
|
|
struct inode *hfsplus_new_inode(struct super_block *sb, struct inode *dir,
|
|
|
|
umode_t mode);
|
2014-06-07 05:36:30 +08:00
|
|
|
void hfsplus_delete_inode(struct inode *inode);
|
|
|
|
void hfsplus_inode_read_fork(struct inode *inode,
|
|
|
|
struct hfsplus_fork_raw *fork);
|
|
|
|
void hfsplus_inode_write_fork(struct inode *inode,
|
|
|
|
struct hfsplus_fork_raw *fork);
|
|
|
|
int hfsplus_cat_read_inode(struct inode *inode, struct hfs_find_data *fd);
|
|
|
|
int hfsplus_cat_write_inode(struct inode *inode);
|
2019-01-04 07:27:46 +08:00
|
|
|
int hfsplus_getattr(const struct path *path, struct kstat *stat,
|
|
|
|
u32 request_mask, unsigned int query_flags);
|
2011-07-17 08:44:56 +08:00
|
|
|
int hfsplus_file_fsync(struct file *file, loff_t start, loff_t end,
|
|
|
|
int datasync);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/* ioctl.c */
|
2010-04-27 22:24:20 +08:00
|
|
|
long hfsplus_ioctl(struct file *filp, unsigned int cmd, unsigned long arg);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/* options.c */
|
2014-06-07 05:36:30 +08:00
|
|
|
void hfsplus_fill_defaults(struct hfsplus_sb_info *opts);
|
2010-11-08 06:01:17 +08:00
|
|
|
int hfsplus_parse_options_remount(char *input, int *force);
|
2014-06-07 05:36:30 +08:00
|
|
|
int hfsplus_parse_options(char *input, struct hfsplus_sb_info *sbi);
|
|
|
|
int hfsplus_show_options(struct seq_file *seq, struct dentry *root);
|
|
|
|
|
|
|
|
/* part_tbl.c */
|
|
|
|
int hfs_part_find(struct super_block *sb, sector_t *part_start,
|
|
|
|
sector_t *part_size);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2008-02-07 16:15:40 +08:00
|
|
|
/* super.c */
|
2014-06-07 05:36:30 +08:00
|
|
|
struct inode *hfsplus_iget(struct super_block *sb, unsigned long ino);
|
2012-07-12 22:26:31 +08:00
|
|
|
void hfsplus_mark_mdb_dirty(struct super_block *sb);
|
2008-02-07 16:15:40 +08:00
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
/* tables.c */
|
|
|
|
extern u16 hfsplus_case_fold_table[];
|
|
|
|
extern u16 hfsplus_decompose_table[];
|
|
|
|
extern u16 hfsplus_compose_table[];
|
|
|
|
|
|
|
|
/* unicode.c */
|
2014-06-07 05:36:30 +08:00
|
|
|
int hfsplus_strcasecmp(const struct hfsplus_unistr *s1,
|
|
|
|
const struct hfsplus_unistr *s2);
|
|
|
|
int hfsplus_strcmp(const struct hfsplus_unistr *s1,
|
|
|
|
const struct hfsplus_unistr *s2);
|
|
|
|
int hfsplus_uni2asc(struct super_block *sb, const struct hfsplus_unistr *ustr,
|
|
|
|
char *astr, int *len_p);
|
|
|
|
int hfsplus_asc2uni(struct super_block *sb, struct hfsplus_unistr *ustr,
|
|
|
|
int max_unistr_len, const char *astr, int len);
|
2013-05-22 06:22:44 +08:00
|
|
|
int hfsplus_hash_dentry(const struct dentry *dentry, struct qstr *str);
|
2016-08-01 04:37:25 +08:00
|
|
|
int hfsplus_compare_dentry(const struct dentry *dentry, unsigned int len,
|
2014-06-07 05:36:30 +08:00
|
|
|
const char *str, const struct qstr *name);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/* wrapper.c */
|
2014-06-07 05:36:30 +08:00
|
|
|
int hfsplus_submit_bio(struct super_block *sb, sector_t sector, void *buf,
|
2016-06-06 03:31:58 +08:00
|
|
|
void **data, int op, int op_flags);
|
2014-06-07 05:36:30 +08:00
|
|
|
int hfsplus_read_wrapper(struct super_block *sb);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
hfs/hfsplus: use 64-bit inode timestamps
The interpretation of on-disk timestamps in HFS and HFS+ differs
between 32-bit and 64-bit kernels at the moment. Use 64-bit timestamps
consistently so apply the current 64-bit behavior everyhere.
According to the official documentation for HFS+ [1], inode timestamps
are supposed to cover the time range from 1904 to 2040 as originally
used in classic MacOS.
The traditional Linux usage is to convert the timestamps into an unsigned
32-bit number based on the Unix epoch and from there to a time_t. On
32-bit systems, that wraps the time from 2038 to 1902, so the last
two years of the valid time range become garbled. On 64-bit systems,
all times before 1970 get turned into timestamps between 2038 and 2106,
which is more convenient but also different from the documented behavior.
Looking at the Darwin sources [2], it seems that MacOS is inconsistent in
yet another way: all timestamps are wrapped around to a 32-bit unsigned
number when written to the disk, but when read back, all numeric values
lower than 2082844800U are assumed to be invalid, so we cannot represent
the times before 1970 or the times after 2040.
While all implementations seem to agree on the interpretation of values
between 1970 and 2038, they often differ on the exact range they support
when reading back values outside of the common range:
MacOS (traditional): 1904-2040
Apple Documentation: 1904-2040
MacOS X source comments: 1970-2040
MacOS X source code: 1970-2038
32-bit Linux: 1902-2038
64-bit Linux: 1970-2106
hfsfuse: 1970-2040
hfsutils (32 bit, old libc) 1902-2038
hfsutils (32 bit, new libc) 1970-2106
hfsutils (64 bit) 1904-2040
hfsplus-utils 1904-2040
hfsexplorer 1904-2040
7-zip 1904-2040
Out of the above, the range from 1970 to 2106 seems to be the most useful,
as it allows using HFS and HFS+ beyond year 2038, and this matches the
behavior that most users would see today on Linux, as few people run
32-bit kernels any more.
Link: [1] https://developer.apple.com/library/archive/technotes/tn/tn1150.html
Link: [2] https://opensource.apple.com/source/hfs/hfs-407.30.1/core/MacOSStubs.c.auto.html
Link: https://lore.kernel.org/lkml/20180711224625.airwna6gzyatoowe@eaf/
Suggested-by: "Ernesto A. Fernández" <ernesto.mnd.fernandez@gmail.com>
Reviewed-by: Vyacheslav Dubeyko <slava@dubeyko.com>
Reviewed-by: Ernesto A. Fernández <ernesto.mnd.fernandez@gmail.com>
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
v3: revert back to 1970-2106 time range
fix bugs found in review
merge both patches into one
drop cc:stable tag
v2: treat pre-1970 dates as invalid following MacOS X behavior,
reword and expand changelog text
2018-06-20 15:47:26 +08:00
|
|
|
/*
|
|
|
|
* time helpers: convert between 1904-base and 1970-base timestamps
|
|
|
|
*
|
|
|
|
* HFS+ implementations are highly inconsistent, this one matches the
|
|
|
|
* traditional behavior of 64-bit Linux, giving the most useful
|
|
|
|
* time range between 1970 and 2106, by treating any on-disk timestamp
|
|
|
|
* under HFSPLUS_UTC_OFFSET (Jan 1 1970) as a time between 2040 and 2106.
|
|
|
|
*/
|
|
|
|
#define HFSPLUS_UTC_OFFSET 2082844800U
|
|
|
|
|
|
|
|
static inline time64_t __hfsp_mt2ut(__be32 mt)
|
|
|
|
{
|
|
|
|
time64_t ut = (u32)(be32_to_cpu(mt) - HFSPLUS_UTC_OFFSET);
|
|
|
|
|
|
|
|
return ut;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline __be32 __hfsp_ut2mt(time64_t ut)
|
|
|
|
{
|
|
|
|
return cpu_to_be32(lower_32_bits(ut) + HFSPLUS_UTC_OFFSET);
|
|
|
|
}
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/* compatibility */
|
hfs/hfsplus: use 64-bit inode timestamps
The interpretation of on-disk timestamps in HFS and HFS+ differs
between 32-bit and 64-bit kernels at the moment. Use 64-bit timestamps
consistently so apply the current 64-bit behavior everyhere.
According to the official documentation for HFS+ [1], inode timestamps
are supposed to cover the time range from 1904 to 2040 as originally
used in classic MacOS.
The traditional Linux usage is to convert the timestamps into an unsigned
32-bit number based on the Unix epoch and from there to a time_t. On
32-bit systems, that wraps the time from 2038 to 1902, so the last
two years of the valid time range become garbled. On 64-bit systems,
all times before 1970 get turned into timestamps between 2038 and 2106,
which is more convenient but also different from the documented behavior.
Looking at the Darwin sources [2], it seems that MacOS is inconsistent in
yet another way: all timestamps are wrapped around to a 32-bit unsigned
number when written to the disk, but when read back, all numeric values
lower than 2082844800U are assumed to be invalid, so we cannot represent
the times before 1970 or the times after 2040.
While all implementations seem to agree on the interpretation of values
between 1970 and 2038, they often differ on the exact range they support
when reading back values outside of the common range:
MacOS (traditional): 1904-2040
Apple Documentation: 1904-2040
MacOS X source comments: 1970-2040
MacOS X source code: 1970-2038
32-bit Linux: 1902-2038
64-bit Linux: 1970-2106
hfsfuse: 1970-2040
hfsutils (32 bit, old libc) 1902-2038
hfsutils (32 bit, new libc) 1970-2106
hfsutils (64 bit) 1904-2040
hfsplus-utils 1904-2040
hfsexplorer 1904-2040
7-zip 1904-2040
Out of the above, the range from 1970 to 2106 seems to be the most useful,
as it allows using HFS and HFS+ beyond year 2038, and this matches the
behavior that most users would see today on Linux, as few people run
32-bit kernels any more.
Link: [1] https://developer.apple.com/library/archive/technotes/tn/tn1150.html
Link: [2] https://opensource.apple.com/source/hfs/hfs-407.30.1/core/MacOSStubs.c.auto.html
Link: https://lore.kernel.org/lkml/20180711224625.airwna6gzyatoowe@eaf/
Suggested-by: "Ernesto A. Fernández" <ernesto.mnd.fernandez@gmail.com>
Reviewed-by: Vyacheslav Dubeyko <slava@dubeyko.com>
Reviewed-by: Ernesto A. Fernández <ernesto.mnd.fernandez@gmail.com>
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
v3: revert back to 1970-2106 time range
fix bugs found in review
merge both patches into one
drop cc:stable tag
v2: treat pre-1970 dates as invalid following MacOS X behavior,
reword and expand changelog text
2018-06-20 15:47:26 +08:00
|
|
|
#define hfsp_mt2ut(t) (struct timespec64){ .tv_sec = __hfsp_mt2ut(t) }
|
2005-04-17 06:20:36 +08:00
|
|
|
#define hfsp_ut2mt(t) __hfsp_ut2mt((t).tv_sec)
|
hfs/hfsplus: use 64-bit inode timestamps
The interpretation of on-disk timestamps in HFS and HFS+ differs
between 32-bit and 64-bit kernels at the moment. Use 64-bit timestamps
consistently so apply the current 64-bit behavior everyhere.
According to the official documentation for HFS+ [1], inode timestamps
are supposed to cover the time range from 1904 to 2040 as originally
used in classic MacOS.
The traditional Linux usage is to convert the timestamps into an unsigned
32-bit number based on the Unix epoch and from there to a time_t. On
32-bit systems, that wraps the time from 2038 to 1902, so the last
two years of the valid time range become garbled. On 64-bit systems,
all times before 1970 get turned into timestamps between 2038 and 2106,
which is more convenient but also different from the documented behavior.
Looking at the Darwin sources [2], it seems that MacOS is inconsistent in
yet another way: all timestamps are wrapped around to a 32-bit unsigned
number when written to the disk, but when read back, all numeric values
lower than 2082844800U are assumed to be invalid, so we cannot represent
the times before 1970 or the times after 2040.
While all implementations seem to agree on the interpretation of values
between 1970 and 2038, they often differ on the exact range they support
when reading back values outside of the common range:
MacOS (traditional): 1904-2040
Apple Documentation: 1904-2040
MacOS X source comments: 1970-2040
MacOS X source code: 1970-2038
32-bit Linux: 1902-2038
64-bit Linux: 1970-2106
hfsfuse: 1970-2040
hfsutils (32 bit, old libc) 1902-2038
hfsutils (32 bit, new libc) 1970-2106
hfsutils (64 bit) 1904-2040
hfsplus-utils 1904-2040
hfsexplorer 1904-2040
7-zip 1904-2040
Out of the above, the range from 1970 to 2106 seems to be the most useful,
as it allows using HFS and HFS+ beyond year 2038, and this matches the
behavior that most users would see today on Linux, as few people run
32-bit kernels any more.
Link: [1] https://developer.apple.com/library/archive/technotes/tn/tn1150.html
Link: [2] https://opensource.apple.com/source/hfs/hfs-407.30.1/core/MacOSStubs.c.auto.html
Link: https://lore.kernel.org/lkml/20180711224625.airwna6gzyatoowe@eaf/
Suggested-by: "Ernesto A. Fernández" <ernesto.mnd.fernandez@gmail.com>
Reviewed-by: Vyacheslav Dubeyko <slava@dubeyko.com>
Reviewed-by: Ernesto A. Fernández <ernesto.mnd.fernandez@gmail.com>
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
v3: revert back to 1970-2106 time range
fix bugs found in review
merge both patches into one
drop cc:stable tag
v2: treat pre-1970 dates as invalid following MacOS X behavior,
reword and expand changelog text
2018-06-20 15:47:26 +08:00
|
|
|
#define hfsp_now2mt() __hfsp_ut2mt(ktime_get_real_seconds())
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
#endif
|