| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * linux/fs/isofs/inode.c |
|---|
| 3 | 4 | * |
|---|
| .. | .. |
|---|
| 28 | 29 | |
|---|
| 29 | 30 | #include "isofs.h" |
|---|
| 30 | 31 | #include "zisofs.h" |
|---|
| 32 | + |
|---|
| 33 | +/* max tz offset is 13 hours */ |
|---|
| 34 | +#define MAX_TZ_OFFSET (52*15*60) |
|---|
| 31 | 35 | |
|---|
| 32 | 36 | #define BEQUIET |
|---|
| 33 | 37 | |
|---|
| .. | .. |
|---|
| 72 | 76 | return &ei->vfs_inode; |
|---|
| 73 | 77 | } |
|---|
| 74 | 78 | |
|---|
| 75 | | -static void isofs_i_callback(struct rcu_head *head) |
|---|
| 79 | +static void isofs_free_inode(struct inode *inode) |
|---|
| 76 | 80 | { |
|---|
| 77 | | - struct inode *inode = container_of(head, struct inode, i_rcu); |
|---|
| 78 | 81 | kmem_cache_free(isofs_inode_cachep, ISOFS_I(inode)); |
|---|
| 79 | | -} |
|---|
| 80 | | - |
|---|
| 81 | | -static void isofs_destroy_inode(struct inode *inode) |
|---|
| 82 | | -{ |
|---|
| 83 | | - call_rcu(&inode->i_rcu, isofs_i_callback); |
|---|
| 84 | 82 | } |
|---|
| 85 | 83 | |
|---|
| 86 | 84 | static void init_once(void *foo) |
|---|
| .. | .. |
|---|
| 122 | 120 | |
|---|
| 123 | 121 | static const struct super_operations isofs_sops = { |
|---|
| 124 | 122 | .alloc_inode = isofs_alloc_inode, |
|---|
| 125 | | - .destroy_inode = isofs_destroy_inode, |
|---|
| 123 | + .free_inode = isofs_free_inode, |
|---|
| 126 | 124 | .put_super = isofs_put_super, |
|---|
| 127 | 125 | .statfs = isofs_statfs, |
|---|
| 128 | 126 | .remount_fs = isofs_remount, |
|---|
| .. | .. |
|---|
| 547 | 545 | |
|---|
| 548 | 546 | static unsigned int isofs_get_last_session(struct super_block *sb, s32 session) |
|---|
| 549 | 547 | { |
|---|
| 550 | | - struct cdrom_multisession ms_info; |
|---|
| 551 | | - unsigned int vol_desc_start; |
|---|
| 552 | | - struct block_device *bdev = sb->s_bdev; |
|---|
| 553 | | - int i; |
|---|
| 548 | + struct cdrom_device_info *cdi = disk_to_cdi(sb->s_bdev->bd_disk); |
|---|
| 549 | + unsigned int vol_desc_start = 0; |
|---|
| 554 | 550 | |
|---|
| 555 | | - vol_desc_start=0; |
|---|
| 556 | | - ms_info.addr_format=CDROM_LBA; |
|---|
| 557 | 551 | if (session > 0) { |
|---|
| 558 | | - struct cdrom_tocentry Te; |
|---|
| 559 | | - Te.cdte_track=session; |
|---|
| 560 | | - Te.cdte_format=CDROM_LBA; |
|---|
| 561 | | - i = ioctl_by_bdev(bdev, CDROMREADTOCENTRY, (unsigned long) &Te); |
|---|
| 562 | | - if (!i) { |
|---|
| 552 | + struct cdrom_tocentry te; |
|---|
| 553 | + |
|---|
| 554 | + if (!cdi) |
|---|
| 555 | + return 0; |
|---|
| 556 | + |
|---|
| 557 | + te.cdte_track = session; |
|---|
| 558 | + te.cdte_format = CDROM_LBA; |
|---|
| 559 | + if (cdrom_read_tocentry(cdi, &te) == 0) { |
|---|
| 563 | 560 | printk(KERN_DEBUG "ISOFS: Session %d start %d type %d\n", |
|---|
| 564 | | - session, Te.cdte_addr.lba, |
|---|
| 565 | | - Te.cdte_ctrl&CDROM_DATA_TRACK); |
|---|
| 566 | | - if ((Te.cdte_ctrl&CDROM_DATA_TRACK) == 4) |
|---|
| 567 | | - return Te.cdte_addr.lba; |
|---|
| 561 | + session, te.cdte_addr.lba, |
|---|
| 562 | + te.cdte_ctrl & CDROM_DATA_TRACK); |
|---|
| 563 | + if ((te.cdte_ctrl & CDROM_DATA_TRACK) == 4) |
|---|
| 564 | + return te.cdte_addr.lba; |
|---|
| 568 | 565 | } |
|---|
| 569 | 566 | |
|---|
| 570 | 567 | printk(KERN_ERR "ISOFS: Invalid session number or type of track\n"); |
|---|
| 571 | 568 | } |
|---|
| 572 | | - i = ioctl_by_bdev(bdev, CDROMMULTISESSION, (unsigned long) &ms_info); |
|---|
| 573 | | - if (session > 0) |
|---|
| 574 | | - printk(KERN_ERR "ISOFS: Invalid session number\n"); |
|---|
| 575 | | -#if 0 |
|---|
| 576 | | - printk(KERN_DEBUG "isofs.inode: CDROMMULTISESSION: rc=%d\n",i); |
|---|
| 577 | | - if (i==0) { |
|---|
| 578 | | - printk(KERN_DEBUG "isofs.inode: XA disk: %s\n",ms_info.xa_flag?"yes":"no"); |
|---|
| 579 | | - printk(KERN_DEBUG "isofs.inode: vol_desc_start = %d\n", ms_info.addr.lba); |
|---|
| 580 | | - } |
|---|
| 581 | | -#endif |
|---|
| 582 | | - if (i==0) |
|---|
| 569 | + |
|---|
| 570 | + if (cdi) { |
|---|
| 571 | + struct cdrom_multisession ms_info; |
|---|
| 572 | + |
|---|
| 573 | + ms_info.addr_format = CDROM_LBA; |
|---|
| 574 | + if (cdrom_multisession(cdi, &ms_info) == 0) { |
|---|
| 583 | 575 | #if WE_OBEY_THE_WRITTEN_STANDARDS |
|---|
| 584 | | - if (ms_info.xa_flag) /* necessary for a valid ms_info.addr */ |
|---|
| 576 | + /* necessary for a valid ms_info.addr */ |
|---|
| 577 | + if (ms_info.xa_flag) |
|---|
| 585 | 578 | #endif |
|---|
| 586 | | - vol_desc_start=ms_info.addr.lba; |
|---|
| 579 | + vol_desc_start = ms_info.addr.lba; |
|---|
| 580 | + } |
|---|
| 581 | + } |
|---|
| 582 | + |
|---|
| 587 | 583 | return vol_desc_start; |
|---|
| 588 | 584 | } |
|---|
| 589 | 585 | |
|---|
| .. | .. |
|---|
| 617 | 613 | |
|---|
| 618 | 614 | /* |
|---|
| 619 | 615 | * Initialize the superblock and read the root inode. |
|---|
| 620 | | - * |
|---|
| 621 | | - * Note: a check_disk_change() has been done immediately prior |
|---|
| 622 | | - * to this call, so we don't need to check again. |
|---|
| 623 | 616 | */ |
|---|
| 624 | 617 | static int isofs_fill_super(struct super_block *s, void *data, int silent) |
|---|
| 625 | 618 | { |
|---|
| .. | .. |
|---|
| 806 | 799 | * size of a file system, which is 8 TB. |
|---|
| 807 | 800 | */ |
|---|
| 808 | 801 | s->s_maxbytes = 0x80000000000LL; |
|---|
| 802 | + |
|---|
| 803 | + /* ECMA-119 timestamp from 1900/1/1 with tz offset */ |
|---|
| 804 | + s->s_time_min = mktime64(1900, 1, 1, 0, 0, 0) - MAX_TZ_OFFSET; |
|---|
| 805 | + s->s_time_max = mktime64(U8_MAX+1900, 12, 31, 23, 59, 59) + MAX_TZ_OFFSET; |
|---|
| 809 | 806 | |
|---|
| 810 | 807 | /* Set this for reference. Its not currently used except on write |
|---|
| 811 | 808 | which we don't have .. */ |
|---|
| .. | .. |
|---|
| 1040 | 1037 | buf->f_bavail = 0; |
|---|
| 1041 | 1038 | buf->f_files = ISOFS_SB(sb)->s_ninodes; |
|---|
| 1042 | 1039 | buf->f_ffree = 0; |
|---|
| 1043 | | - buf->f_fsid.val[0] = (u32)id; |
|---|
| 1044 | | - buf->f_fsid.val[1] = (u32)(id >> 32); |
|---|
| 1040 | + buf->f_fsid = u64_to_fsid(id); |
|---|
| 1045 | 1041 | buf->f_namelen = NAME_MAX; |
|---|
| 1046 | 1042 | return 0; |
|---|
| 1047 | 1043 | } |
|---|
| .. | .. |
|---|
| 1182 | 1178 | return mpage_readpage(page, isofs_get_block); |
|---|
| 1183 | 1179 | } |
|---|
| 1184 | 1180 | |
|---|
| 1185 | | -static int isofs_readpages(struct file *file, struct address_space *mapping, |
|---|
| 1186 | | - struct list_head *pages, unsigned nr_pages) |
|---|
| 1181 | +static void isofs_readahead(struct readahead_control *rac) |
|---|
| 1187 | 1182 | { |
|---|
| 1188 | | - return mpage_readpages(mapping, pages, nr_pages, isofs_get_block); |
|---|
| 1183 | + mpage_readahead(rac, isofs_get_block); |
|---|
| 1189 | 1184 | } |
|---|
| 1190 | 1185 | |
|---|
| 1191 | 1186 | static sector_t _isofs_bmap(struct address_space *mapping, sector_t block) |
|---|
| .. | .. |
|---|
| 1195 | 1190 | |
|---|
| 1196 | 1191 | static const struct address_space_operations isofs_aops = { |
|---|
| 1197 | 1192 | .readpage = isofs_readpage, |
|---|
| 1198 | | - .readpages = isofs_readpages, |
|---|
| 1193 | + .readahead = isofs_readahead, |
|---|
| 1199 | 1194 | .bmap = _isofs_bmap |
|---|
| 1200 | 1195 | }; |
|---|
| 1201 | 1196 | |
|---|
| .. | .. |
|---|
| 1617 | 1612 | module_init(init_iso9660_fs) |
|---|
| 1618 | 1613 | module_exit(exit_iso9660_fs) |
|---|
| 1619 | 1614 | MODULE_LICENSE("GPL"); |
|---|
| 1615 | +MODULE_IMPORT_NS(ANDROID_GKI_VFS_EXPORT_ONLY); |
|---|