ubd_kern.c (942e6f8a8314e5550e254519dfba4ccd5170421d) ubd_kern.c (853bc0ab341b0c99619f83f4060dedcccad77b2a)
1// SPDX-License-Identifier: GPL-2.0
2/*
3 * Copyright (C) 2018 Cambridge Greys Ltd
4 * Copyright (C) 2015-2016 Anton Ivanov (aivanov@brocade.com)
5 * Copyright (C) 2000 Jeff Dike (jdike@karaya.com)
6 */
7
8/* 2001-09-28...2002-04-17

--- 547 unchanged lines hidden (view full) ---

556{
557 char *file;
558 int fd;
559 int err;
560
561 __u32 version;
562 __u32 align;
563 char *backing_file;
1// SPDX-License-Identifier: GPL-2.0
2/*
3 * Copyright (C) 2018 Cambridge Greys Ltd
4 * Copyright (C) 2015-2016 Anton Ivanov (aivanov@brocade.com)
5 * Copyright (C) 2000 Jeff Dike (jdike@karaya.com)
6 */
7
8/* 2001-09-28...2002-04-17

--- 547 unchanged lines hidden (view full) ---

556{
557 char *file;
558 int fd;
559 int err;
560
561 __u32 version;
562 __u32 align;
563 char *backing_file;
564 time_t mtime;
564 time64_t mtime;
565 unsigned long long size;
566 int sector_size;
567 int bitmap_offset;
568
569 if (ubd_dev->file && ubd_dev->cow.file) {
570 file = ubd_dev->cow.file;
571
572 goto out;

--- 22 unchanged lines hidden (view full) ---

595
596 err = os_pread_file(fd, buf, len, offset);
597 if (err < 0)
598 return err;
599
600 return 0;
601}
602
565 unsigned long long size;
566 int sector_size;
567 int bitmap_offset;
568
569 if (ubd_dev->file && ubd_dev->cow.file) {
570 file = ubd_dev->cow.file;
571
572 goto out;

--- 22 unchanged lines hidden (view full) ---

595
596 err = os_pread_file(fd, buf, len, offset);
597 if (err < 0)
598 return err;
599
600 return 0;
601}
602
603static int backing_file_mismatch(char *file, __u64 size, time_t mtime)
603static int backing_file_mismatch(char *file, __u64 size, time64_t mtime)
604{
604{
605 unsigned long modtime;
605 time64_t modtime;
606 unsigned long long actual;
607 int err;
608
609 err = os_file_modtime(file, &modtime);
610 if (err < 0) {
611 printk(KERN_ERR "Failed to get modification time of backing "
612 "file \"%s\", err = %d\n", file, -err);
613 return err;

--- 9 unchanged lines hidden (view full) ---

623 if (actual != size) {
624 /*__u64 can be a long on AMD64 and with %lu GCC complains; so
625 * the typecast.*/
626 printk(KERN_ERR "Size mismatch (%llu vs %llu) of COW header "
627 "vs backing file\n", (unsigned long long) size, actual);
628 return -EINVAL;
629 }
630 if (modtime != mtime) {
606 unsigned long long actual;
607 int err;
608
609 err = os_file_modtime(file, &modtime);
610 if (err < 0) {
611 printk(KERN_ERR "Failed to get modification time of backing "
612 "file \"%s\", err = %d\n", file, -err);
613 return err;

--- 9 unchanged lines hidden (view full) ---

623 if (actual != size) {
624 /*__u64 can be a long on AMD64 and with %lu GCC complains; so
625 * the typecast.*/
626 printk(KERN_ERR "Size mismatch (%llu vs %llu) of COW header "
627 "vs backing file\n", (unsigned long long) size, actual);
628 return -EINVAL;
629 }
630 if (modtime != mtime) {
631 printk(KERN_ERR "mtime mismatch (%ld vs %ld) of COW header vs "
631 printk(KERN_ERR "mtime mismatch (%lld vs %lld) of COW header vs "
632 "backing file\n", mtime, modtime);
633 return -EINVAL;
634 }
635 return 0;
636}
637
638static int path_requires_switch(char *from_cmdline, char *from_cow, char *cow)
639{

--- 26 unchanged lines hidden (view full) ---

666 return 1;
667}
668
669static int open_ubd_file(char *file, struct openflags *openflags, int shared,
670 char **backing_file_out, int *bitmap_offset_out,
671 unsigned long *bitmap_len_out, int *data_offset_out,
672 int *create_cow_out)
673{
632 "backing file\n", mtime, modtime);
633 return -EINVAL;
634 }
635 return 0;
636}
637
638static int path_requires_switch(char *from_cmdline, char *from_cow, char *cow)
639{

--- 26 unchanged lines hidden (view full) ---

666 return 1;
667}
668
669static int open_ubd_file(char *file, struct openflags *openflags, int shared,
670 char **backing_file_out, int *bitmap_offset_out,
671 unsigned long *bitmap_len_out, int *data_offset_out,
672 int *create_cow_out)
673{
674 time_t mtime;
674 time64_t mtime;
675 unsigned long long size;
676 __u32 version, align;
677 char *backing_file;
678 int fd, err, sectorsize, asked_switch, mode = 0644;
679
680 fd = os_open_file(file, *openflags, mode);
681 if (fd < 0) {
682 if ((fd == -ENOENT) && (create_cow_out != NULL))

--- 938 unchanged lines hidden ---
675 unsigned long long size;
676 __u32 version, align;
677 char *backing_file;
678 int fd, err, sectorsize, asked_switch, mode = 0644;
679
680 fd = os_open_file(file, *openflags, mode);
681 if (fd < 0) {
682 if ((fd == -ENOENT) && (create_cow_out != NULL))

--- 938 unchanged lines hidden ---