partclone-user Mailing List for Partclone
Brought to you by:
thomas_tsai
You can subscribe to this list here.
2009 |
Jan
|
Feb
|
Mar
(4) |
Apr
|
May
(2) |
Jun
(4) |
Jul
(5) |
Aug
|
Sep
|
Oct
(2) |
Nov
(1) |
Dec
(1) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2010 |
Jan
(24) |
Feb
|
Mar
|
Apr
(2) |
May
(4) |
Jun
|
Jul
|
Aug
|
Sep
(5) |
Oct
|
Nov
|
Dec
(1) |
2011 |
Jan
(2) |
Feb
|
Mar
(2) |
Apr
|
May
(3) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(1) |
2013 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
(3) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2019 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
(1) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2020 |
Jan
|
Feb
|
Mar
(1) |
Apr
|
May
(1) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2024 |
Jan
|
Feb
(1) |
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: Kevin O'G. <kev...@gm...> - 2024-02-16 19:34:20
|
See my post on AskUbuntu: https://askubuntu.com/questions/1503792/partclone-what-am-i-doing-wrong I wonder what is happening, and if I'll ever be able to use partclone on my RAID. -- *Kevin O'Gorman (he/him/his)* *Explore, enjoy and protect the environment.* |
From: jtharkey <jth...@pr...> - 2020-05-26 16:06:29
|
Hello, I used to use partclone to restore a raw image into an image I could mount as a loop device. Then I would copy files over to that mounted loop device. Finally I'd use partclone to make that back into a raw image. This used to work fine, but now all the files I copy over are zero bytes in size. They do exist, however. Am I relying on something that isn't supported? Dr. Light |
From: Turritopsis D. T. En M. <ce...@te...> - 2020-03-15 04:52:40
|
Subject: How can I make space-saving and reliable backup/clone of Teo En Ming Linux 2020.03 (FINAL)? Good day from Singapore, I have recently *successfully* created my own custom Linux distribution called Teo En Ming Linux 2020.03 (FINAL), which is based on Linux From Scratch (LFS) 20200302-systemd development book and Linux Kernel 5.5.7, on 12 March 2020. Please refer to my redundant blog posts for more information about Teo En Ming Linux 2020.03 (FINAL). Post: "Announcing Teo En Ming Linux 2020.03 (FINAL)" Blogger: https://tdtemcerts.blogspot.com/2020/03/announcing-teo-en-ming-linux-202003.html Wordpress: https://tdtemcerts.wordpress.com/2020/03/12/announcing-teo-en-ming-linux-2020-03-final/ Post: "How to create a Bootable Live CD/DVD from your Linux From Scratch (LFS) build" Blogger: https://tdtemcerts.blogspot.com/2020/03/how-to-create-bootable-live-cddvd-from.html Wordpress: https://tdtemcerts.wordpress.com/2020/03/15/how-to-create-a-bootable-live-cd-dvd-from-your-linux-from-scratch-lfs-build/ The question is, how can I make space-saving and reliable backup/clone of Teo En Ming Linux 2020.03 (FINAL)? If you are able to assist with or solve my Live CD/DVD ISO issues, I will be very grateful indeed. Currently, my Live CD/DVD boots with a Kernel Panic. [ 13.362601 ] ---[end Kernel panic - not syncing: Attempted to kill init! exit code=0x00000200 ]--- Please advise. Thank you very much. -- -----BEGIN EMAIL SIGNATURE----- The Gospel for all Targeted Individuals (TIs): [The New York Times] Microwave Weapons Are Prime Suspect in Ills of U.S. Embassy Workers Link: https://www.nytimes.com/2018/09/01/science/sonic-attack-cuba-microwave.html ******************************************************************************************** Singaporean Mr. Turritopsis Dohrnii Teo En Ming's Academic Qualifications as at 14 Feb 2019 and refugee seeking attempts at the United Nations Refugee Agency Bangkok (21 Mar 2017), in Taiwan (5 Aug 2019) and Australia (25 Dec 2019 to 9 Jan 2020): [1] https://tdtemcerts.wordpress.com/ [2] https://tdtemcerts.blogspot.sg/ [3] https://www.scribd.com/user/270125049/Teo-En-Ming -----END EMAIL SIGNATURE----- |
From: Naoyuki T. <nao...@gm...> - 2019-07-17 16:41:30
|
Hello, First, I have to thank for partclone, as it's vital component of my volunteer work. Well, I have a couple of feature requests. Not sure how well sourceforge's tickets are cared for so I'm trying to send a mail. #1 - Flush out the cache while restoring When I am restoring to USB flash drive, there is a long long long pause between "99%" and "100%". I am looking at the code and I can guess why. "fs_close()" is called after restoring and 100% shows up after fs_close() is done. The machine with a lot of memory these days can hold a lot of dirty pages, and fs_close() forces the dirty cache to be flushed to USB flash drive, and this writing takes longer than actual restoring process. For example, I restore 2.7GB disk image to a USB flash drive, last progress before 100 shows up at 44 seconds from the start. 100% progress shows up after 225 seconds. That means, partclone is running but there is about 180 seconds of silence between <100 and 100% progress. If there is a cache flush after each block is written to the device, the progress would be far more accurate. Looking at the code, I can guess it's probably exfat_flush_nodes or exfat_flush does the job but I obviously don't have the knowledge. If you want me to try something, I'm happy to. #2 - Progress output format. I'm parsing the output of partclone using Python. It would be great if the output is more machine readable. Thanks and have a nice day. -- Tai P.S. Volunteer work is at https://github.com/ntai/wce-triage-v2 https://github.com/ntai/wce-triage-v2/blob/master/wce_triage/bin/restore_volume.py |
From: Ian A. <ab...@me...> - 2013-06-27 11:08:19
|
On 2013-06-27 10:03, detlef oertel wrote: > Hello, > > thanks for this wonderful product. > > I try to create a product which creates an image of a partition and gives two different ways to restore: > 1. copy the whole image back > 2. remove all changes by an unidirectional rsync between the saved image and the productive partition. > > Point 1. is easy. The problem is Point 2. For point 2, do you want to mount the modified partition, mount the saved image and do an rsync from the saved image filesystem to the modified partition filesystem? It may be tricky to do that for NTFS filesystem images on Linux as it doesn't support all the nuances of NTFS that Windows supports. You'd have trouble restoring things like security attributes, for example. > > If I use 'partclone.ntfs --clone ' I get an image which can not be mounted in a usual way. It can be mounted using the > partclone-utils via > imagemount -d /dev/nbd0 -f myimage.img -m /mnt -r -t ntfs > but in this mounted image all ntfs access informations are lost (for example symbolic links to directories you will see > as real directories) Is the mount.ntfs on your system symlinked to mount.ntfs-3g? If not, you might be using the Linux kernel's rather limited ntfs filesystem module instead of the FUSE-based (userspace) ntfs-3g. In that case, you could try passing the -t ntfs-3g option top imagemount. > If I use 'partclone.ntfs -b -s /dev/sda1 -O myimage.img' I get an mountable image with the correct ntfs informations and > this image is only a little bit larger than the '--clone' version. AFAIK, in that mode, the output ends up as a sparse, raw image, with all-zero blocks compressed by the filesystem that stores the image file. The underlying filesystem that stores the image file has to support sparse files in order to store the all-zero blocks efficiently, otherwise they take up the same amount of physical disk space as non-zero blocks. > But if I try to restore such an image with partclone.restore it proceeds until 99.88 % and than stops with an IO error. > As far I could see the restore transfer rate was only about 0,9 GB/min and from the '--clone' image about 1.9 GB/min. That sounds like a bug somewhere (or possibly lack of large file support somewhere), but it should also be possible to restore a raw image using the 'dd' command, or something like GNU ddrescue. What type of filesystem are you using to store the image files? > Using ntfsclone leads to mountable images which have the same size than copied file system and contain all empty spaces. ntfsclone is also supposed to create sparse, raw files unless you use the --save-image to --restore-image options to handle its special image mode. (Presumably, the format of the special image is different to that produced by partclone's --store option.) The special image format produced by ntfsclone --save-image is also supported by imagemount. > So my question is: > Did I miss something ? > Is there any way to get a small read only mountable image with a fast restore ? Since reading is generally faster than writing, you could offer a variant of option 1 that compares the modified partition with the saved image and restores the parts that have changed. Apparently there are patches for rsync that can handle syncing of block devices without excessive writes. These are the "copy-devices.diff" and "write-devices.diff" patches that can be found in the git repository at git://git.samba.org/rsync-patches.git (or http://git.samba.org/?p=rsync-patches.git;a=summary ). -- -=( Ian Abbott @ MEV Ltd. E-mail: <ab...@me...> )=- -=( Tel: +44 (0)161 477 1898 FAX: +44 (0)161 718 3587 )=- |
From: detlef o. <d.o...@ui...> - 2013-06-27 09:03:36
|
Hello, thanks for this wonderful product. I try to create a product which creates an image of a partition and gives two different ways to restore: 1. copy the whole image back 2. remove all changes by an unidirectional rsync between the saved image and the productive partition. Point 1. is easy. The problem is Point 2. If I use 'partclone.ntfs --clone ' I get an image which can not be mounted in a usual way. It can be mounted using the partclone-utils via imagemount -d /dev/nbd0 -f myimage.img -m /mnt -r -t ntfs but in this mounted image all ntfs access informations are lost (for example symbolic links to directories you will see as real directories) If I use 'partclone.ntfs -b -s /dev/sda1 -O myimage.img' I get an mountable image with the correct ntfs informations and this image is only a little bit larger than the '--clone' version. But if I try to restore such an image with partclone.restore it proceeds until 99.88 % and than stops with an IO error. As far I could see the restore transfer rate was only about 0,9 GB/min and from the '--clone' image about 1.9 GB/min. Using ntfsclone leads to mountable images which have the same size than copied file system and contain all empty spaces. So my question is: Did I miss something ? Is there any way to get a small read only mountable image with a fast restore ? Thanks for any help d.oertel opsi - The open source client management system. http://opsi.org -- detlef oertel uib gmbh Firmensitz / Anschrift: Bonifaziusplatz 1B D-55118 Mainz internet: www.uib.de Geschäftsführer: dr. detlef oertel Handelsregister: Amtsgericht Mainz HRB 6942 |
From: pf r. <pfr...@gm...> - 2013-06-11 01:05:46
|
I want to have your feed-back and comments about the features to include in a new image format. The current image format (aka 0001) does not allow the user to choose which features are enabled or not. By example, the image always contains a checksum. We can only ignore it when we are restoring, but we cannot disable it when creating the image. By defining a new image format, we can plan some features who may be implemented in the future and design it to support them. The main feature I want to implement is an option to choose which algorithm to use to generate the checksum used to detect data corruption when restoring the image. These options would be added: - a0 : No checksum (no slowdown, but no corruption detection, smallest image, best compression possible) - a1 : CRC32 (Fast to compute, basic detection) - a2 : MD5 (Slower to compute, detection more resistant to corruption, bigger image) - aX : algo X ... - k0 : add the minimum number of checksum possible (smaller image, mininum memory, better compression) - kN : add a checksum every N block (bigger image, more memory needed, reduced compression) - K : do not reset the checksum before each evaluation (same as version 0001, but is it needed?) It is important to note that the checksum can only detects a corruption. It cannot be used to fix the corruption. These modifications does not change the code specific to each file system, ie the bitmap generation stays unchanged. The change who have the biggest impact on the code (mostly main.c & partclone.c) is the rewrite of image_head as file_signature & fs_desc. After the insertion of fs_desc, most functions will use that struct instead of image_head. file_signature is only used to validate the file's content. Some code will be moved around, generally to put it in a function to make it easier to handle various features. One example is the creation of a write_image_bitmap() who will write the image in the format requested by the user. I propose this file format: (order of the information in the file) struct file_signature struct fs_desc struct image_feature struct usage_bitmap struct data_stream The structs are defined below. The ones with the suffix "_v1" are used to handle image written in format version 0001. The ones with suffix "_v2" are for the format 0002. Here some pseudo code to show how the structs will be used during restoration: read file_signature if (file_signature.version == 0001) read fs_desc_v1 set_image_feature() ie checksum_size=4, blocks_per_checksum=1, ignore_chk=1 read usage_bitmap_v1 else read fs_desc_v2 read image_feature_v2 read usage_bitmap_v2 while read data_stream if ignore_chk || check data_stream write blocks else handle_error If this proposal is accepted, I am going to implement at least the two first algorithms. I personnally want the option "-a0 (no checksum)". I have a lot experience in C++, but I have rarely coded in C (ie without the ++). Do not hesitate to point out any mistakes or over sight who may be present in this proposal. Or suggest features who can be interesting. We will see what goes in. What do you think? Regards, P.Rouleau --- file partclone.h sample - begin --- #define BITS_TO_LONGS(bits) (((bits)+31)/32) // Prevent the compiler from inserting padding to align the fields // Important when compiling in 64 bits. #pragma pack(push, 1) /** * Basic information from image_head. Used to support image * in version 0001. */ struct file_signature_v1 { char magic[IMAGE_MAGIC_SIZE]; char fs[FS_MAGIC_SIZE]; char version[IMAGE_VERSION_SIZE]; }; typedef struct file_signature_v1 file_signature_v1 /** * Keep the same basic information than image_head version 0001 to * allow the older tools to reconize the image. However, since the * existing partclone in the wild does not check the image version, * we use the fs' space to store other information. That way, the * tools will not try to work with an newer image. * The offset of version is the same than in file_signature_v1. */ struct file_signature_v2 { char magic[IMAGE_MAGIC_SIZE+1]; /* endianess detector: 0x00C0DE00 = little-endian; 0x00DEC000 = big-endian uint32_t endianess; /* partclone's version who created the image, ex: "2.61" */ char ptc_version[9]; char version[IMAGE_VERSION_SIZE]; }; typedef struct file_signature file_signature; /** * It contains the file system description, but not the type (because it is * located in file_signature_v1). The fields are in the same order than * version 0001. */ struct fs_desc_v1 { uint32_t block_size; uint16_t padding; uint64_t device_size; uint64_t total_block; uint64_t used_blocks; char padding[4096]; }; typedef struct fs_desc_v1 fs_desc_v1; /** * This struct stores the file system characteristics and will be used in * most functions. */ struct fs_desc_v2 { uint64_t device_size; uint64_t total_blocks; uint64_t used_blocks; uint32_t block_size; char fs[FS_MAGIC_SIZE_V2]; }; typedef struct fs_desc_v2 fs_desc_v2; /** * This struct contains all the details about the informations stored * in the image. It is located almost at the same offset than the padding * of fs_desc_v1. */ struct image_feature_v2 { /* number of byte used by this struct It *may* allow some third party tools to handle the image even if they do not know all the features added, but it will probably serve as a "sub-version" and the tools will refuse to work with the image.*/ uint32_t feature_size; /* partclone's compilation flavor: 32 bits or 64 bits */ uint16_t cpu_bits; /* checksum algorithm used 0x00 = NONE; 0x01 = CRC32; 0x02 = MD5; 0x03 = SHA1 ; etc & 0x8000 = if set, the checksum is NOT reseted before each evaluation */ uint16_t checksum_mode; /* Size of one checksum, in bytes. 0 when NONE, 4 with CRC32, etc. This will allow third parties tools to read the image even if they does not support the checksum_mode. */ uint16_t checksum_size; /* How many consecutive blocks are checksumed together. In version 0001, this is 1, ie one checksum per block. I propose to set it to the size of the read buffer by default. That way we will use 50% less memory for read & write because we will not have to allocate a write buffer. It also make the image file smaller by adding less checksum bytes to it and the compressor gives a better compression ratio because there is less "random" bytes. */ uint32_t blocks_per_checksum; /* Kind of bitmap stored in the image 0 = none; aka "all blocks in use" (partclone.dd) 1 = bitmap 3 = packed (far futur; sequence of 0 or 1 saved as "N*b; smaller image, but less compressible) 8 = byte map (like version 0001; deprecated, for compatibility only) */ uint8_t bitmap_mode; }; typedef image_feature_v2 image_feature_v2; /** * (This struct will not really exist. It is only to describe the file format.) * * bitmap of the block usage, one BYTE per block. * 0x01 = Present; other = NOT present */ struct usage_bitmap_v1 { uint8_t use[total_blocks]; char bitmagic[8]; } /** * (This struct will not really exist. It is only to describe the file format.) * * bitmap of the block usage, one BIT per block. * By using one bit per block, the bitmap uses 8 times less space than * version 0001. */ struct usage_bitmap_v2 { uint32_t use[BITS_TO_LONGS(total_blocks)]; uint8_t checksum[checksum_size]; } /** * (This struct will not really exist. It is only to describe the file format.) * * A block from the file system. */ struct block { uint8_t data[block_size]; }; /** * (This struct will not really exist. It is only to describe the file format.) * * @note * The last data_stream may be shorter and contains less blocks than * blocks_per_checksum. * In that case, the checksum is stored right after the last block. */ struct data_stream { block blocks[blocks_per_checksum]; uint8_t checksum[checksum_size]; }; typedef struct data_stream data_stream; #pragma pack(pop) // Restore the packing for the rest of file --- file partclone.h sample - end --- |
From: 赵春辉 <zha...@gm...> - 2011-12-26 07:08:32
|
Hi, Guys: I've met some problems when I tried to compile the partclone source code. I hope you guys could give me some advice. Here is the problem. I compiled the partclone with the parameter "--enable-ntfs" which will support ntfs. When I executed the "make" command, I only got 4 program files: partclone.chkimg, partclone.dd, partclone.info and partclone.restore. I was expecting "partclone.ntfs" but there was none. So I changed the parameter to "--enable-all", but errors occurred when I executed the "./configure" command. The error messages are: "*configure: error: *** EXT2/3 header files(ext2fs/ext2fs.h) not found*". It seemed some files were missing. I tried several versions of source code: 0.2.38, 0.2.40, 0.2.29, all of them failed. I also compiled the source code on git, which failed either. Will anyone please help me with this? Any advice is appreciated. Thank you! -- ------------------------------------------------- 赵春辉 |
From: Ian A. <ab...@me...> - 2011-05-24 10:53:38
|
On 23/05/11 16:02, thomas wrote: > We are glad of your patch file. There is no problem to apply your patch > and release in next version if it works fine. > > A question about partclone, why not just use partclone to backup your > partition? You can try to use --dev-to-dev and --rescue to clone > partition to another partition directly(or save to row file). If it > possible, I want to know what different in ddrescue and partclone > especially for block read error or for some situation. ddrescue has more options for recovering data. For example, when it encounters bad sectors it skips ahead to try and copy the good areas of the disk as soon as possible, then goes back and tries to recover more data from the bad areas. There are also controls over the number of retries, disk access method (cached or direct). Also, it can use a log file (different to the --domain-log file) to record its progress, so you can restart the program and it knows which areas have already been recovered. It doesn't know anything about filesystems though! It's nice to be able to combine the strengths of different utilities that complement one another. > Thanks for your contribution to partclone. You're welcome! -- -=( Ian Abbott @ MEV Ltd. E-mail: <ab...@me...> )=- -=( Tel: +44 (0)161 477 1898 FAX: +44 (0)161 718 3587 )=- |
From: thomas <th...@nc...> - 2011-05-23 15:22:41
|
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hi, We are glad of your patch file. There is no problem to apply your patch and release in next version if it works fine. A question about partclone, why not just use partclone to backup your partition? You can try to use --dev-to-dev and --rescue to clone partition to another partition directly(or save to row file). If it possible, I want to know what different in ddrescue and partclone especially for block read error or for some situation. Thanks for your contribution to partclone. BR, Thomas. On 05/21/2011 12:25 AM, Ian Abbott wrote: > Hi folks, > > While using GNU ddrescue recently to copy a partition on a disk with > read errors, I realized it would be quicker if it only copied the in-use > areas of the partition. ddrescue has a '--domain-log=FILE' option which > can be used to restrict it to certain areas, so the problem is to create > such a domain log file to cover the areas used by the filesystem on the > partition. > > I modified partclone-0.2.23 to add a new mode '--domain' (-D) which > examines the source device and writes a domain log file to the target. > Please see the attached patch that implements this function. > > I also added an option '--offset_domain=X' to add a fixed offset (in > bytes) to the position values in the domain log file. This is useful if > you are using ddrescue to recover a whole disk and need to specify the > offset (in bytes) to the partition covered by the domain log file. > > Here is an example of how to use it: > > # produce a domain file for NTFS partition on /dev/sda1 > partclone.ntfs -s /dev/sda1 -D -o sda1.domain > # copy /dev/sda1 to /dev/sdb1 using ddrescue with domain log file > ddrescue --domain-log sda1.domain /dev/sda1 /dev/sdb1 rescue.log > > The domain log file contains some comment lines starting with '#', a > status line (which is required but ignored by ddrescue's --domain-log > option), and some lines describing the used and unused sections as follows: > > POSITION LENGTH STATUS > > where 'POSITION' is the offset to the section in bytes, 'LENGTH' is the > length of the section in bytes, and 'STATUS' is a status character for > the section. The status gets set to '+' for used areas and '?' for > unused areas. (ddrescue's --domain-log option only cares if the status > is '+' or not.) The areas listed are consecutive with no gaps or > overlaps, and covers the whole file system on the device. If > '--offset_domain=X' is specified, the value X is added to all the > positions listed in the file. > > Here is an example of a domain log file produced by the modified program > (the part indicated by '[...]' has been edited out for brevity): > > # Domain logfile created by partclone.ntfs v0.2.23 > # Source: /dev/sda1 > # Offset: 0x00000000 > # current_pos current_status > 0x992D57000 ? > # pos size status > 0x00000000 0x000CF000 + > 0x000CF000 0x00002000 ? > 0x000D1000 0x00002000 + > [...] > 0x99174C000 0x0002D000 ? > 0x991779000 0x015DE000 + > > It would be great if this feature could be incorporated into the main > partclone sources. > > (Note that I had a look at the git repository, but it seemed to be > out-of-date and wouldn't compile, so I based the patch on the latest > testing version instead.) > > Suggestions for changes or any questions about the patch are welcome! > > Best regards, > Ian Abbott. > > > > > ------------------------------------------------------------------------------ > What Every C/C++ and Fortran developer Should Know! > Read this article and learn how Intel has extended the reach of its > next-generation tools to help Windows* and Linux* C/C++ and Fortran > developers boost performance applications - including clusters. > http://p.sf.net/sfu/intel-dev2devmay > > > > _______________________________________________ > Partclone-user mailing list > Par...@li... > https://lists.sourceforge.net/lists/listinfo/partclone-user - -- Thomas, 蔡育欽 國家高速網路與計算中心 格網技術組 專案助理研究員 thomas at nchc org tw pub key 46379ACF fingerprint = 7BB2 2103 CADC 59F6 11D5 BCB3 5E97 22B4 4637 9ACF -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAk3adu8ACgkQXpcitEY3ms/GgQCgqDIULpMbpPsncTg0DTcaJFzJ eg4AoJ7dU9h0X3YJZu7TE7C6U35m6D2x =3A2K -----END PGP SIGNATURE----- |
From: Ian A. <ab...@me...> - 2011-05-20 16:25:43
|
Hi folks, While using GNU ddrescue recently to copy a partition on a disk with read errors, I realized it would be quicker if it only copied the in-use areas of the partition. ddrescue has a '--domain-log=FILE' option which can be used to restrict it to certain areas, so the problem is to create such a domain log file to cover the areas used by the filesystem on the partition. I modified partclone-0.2.23 to add a new mode '--domain' (-D) which examines the source device and writes a domain log file to the target. Please see the attached patch that implements this function. I also added an option '--offset_domain=X' to add a fixed offset (in bytes) to the position values in the domain log file. This is useful if you are using ddrescue to recover a whole disk and need to specify the offset (in bytes) to the partition covered by the domain log file. Here is an example of how to use it: # produce a domain file for NTFS partition on /dev/sda1 partclone.ntfs -s /dev/sda1 -D -o sda1.domain # copy /dev/sda1 to /dev/sdb1 using ddrescue with domain log file ddrescue --domain-log sda1.domain /dev/sda1 /dev/sdb1 rescue.log The domain log file contains some comment lines starting with '#', a status line (which is required but ignored by ddrescue's --domain-log option), and some lines describing the used and unused sections as follows: POSITION LENGTH STATUS where 'POSITION' is the offset to the section in bytes, 'LENGTH' is the length of the section in bytes, and 'STATUS' is a status character for the section. The status gets set to '+' for used areas and '?' for unused areas. (ddrescue's --domain-log option only cares if the status is '+' or not.) The areas listed are consecutive with no gaps or overlaps, and covers the whole file system on the device. If '--offset_domain=X' is specified, the value X is added to all the positions listed in the file. Here is an example of a domain log file produced by the modified program (the part indicated by '[...]' has been edited out for brevity): # Domain logfile created by partclone.ntfs v0.2.23 # Source: /dev/sda1 # Offset: 0x00000000 # current_pos current_status 0x992D57000 ? # pos size status 0x00000000 0x000CF000 + 0x000CF000 0x00002000 ? 0x000D1000 0x00002000 + [...] 0x99174C000 0x0002D000 ? 0x991779000 0x015DE000 + It would be great if this feature could be incorporated into the main partclone sources. (Note that I had a look at the git repository, but it seemed to be out-of-date and wouldn't compile, so I based the patch on the latest testing version instead.) Suggestions for changes or any questions about the patch are welcome! Best regards, Ian Abbott. -- -=( Ian Abbott @ MEV Ltd. E-mail: <ab...@me...> )=- -=( Tel: +44 (0)161 477 1898 FAX: +44 (0)161 718 3587 )=- |
From: Thomas T. <th...@nc...> - 2011-03-24 02:23:34
|
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hi, yes, thank you for kernel 2.4 bug report. unfortunately, it is not support. BR, Thomas. On 03/21/2011 07:37 PM, Gabor Z. Papp wrote: > lo lo all, > > while trying to compile partclone 0.2.20 on linux kernel 2.4, glibc > 2.2, getting the following error: > > gcc -DHAVE_CONFIG_H -I. -I.. -DLOCALEDIR=\"/pkg/share/locale\" -g -O2 -MT partclone.o -MD -MP -MF .deps/partclone.Tpo -c -o partclone.o partclone.c > partclone.c: In function 'get_partition_size': > partclone.c:575: error: 'u64' undeclared (first use in this function) > partclone.c:575: error: (Each undeclared identifier is reported only once > partclone.c:575: error: for each function it appears in.) > make[2]: *** [partclone.o] Error 1 > > [kernel] > Linux gzpLinux 2.4.37.11-gzpLinux #1 Tue Dec 21 12:35:39 CET 2010 i686 > GNU/Linux > > [glibc] > GNU C Library stable release version 2.2.5, by Roland McGrath et al. > Compiled by GNU CC version 3.3.6. > Compiled on a Linux 2.4.36.2-gzpLinux system on 2008-03-22. > > [gcc] > gcc (GCC) 4.4.5 > > [binutils] > GNU ld (Linux/GNU Binutils) 2.21.51.0.7.20110306 > > [autoconf] > autoconf (GNU Autoconf) 2.68 > > [automake] > automake (GNU automake) 1.11.1 > > [libtool] > libtool (GNU libtool) 2.4 > > ------------------------------------------------------------------------------ > Enable your software for Intel(R) Active Management Technology to meet the > growing manageability and security demands of your customers. Businesses > are taking advantage of Intel(R) vPro (TM) technology - will your software > be a part of the solution? Download the Intel(R) Manageability Checker > today! http://p.sf.net/sfu/intel-dev2devmar > _______________________________________________ > Partclone-user mailing list > Par...@li... > https://lists.sourceforge.net/lists/listinfo/partclone-user - -- Thomas, 蔡育欽 國家高速網路與計算中心 格網技術組 專案助理研究員 thomas at nchc org tw pub key 46379ACF fingerprint = 7BB2 2103 CADC 59F6 11D5 BCB3 5E97 22B4 4637 9ACF -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.10 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAk2KpIQACgkQXpcitEY3ms/lpQCg0+bEYKs1jrOYx0UmxmmfEcjv +yQAn3Mekanh2hvMBUDKC8rftF0e2p/i =LS+Q -----END PGP SIGNATURE----- |
From: Gabor Z. P. <gz...@pa...> - 2011-03-21 12:00:07
|
lo lo all, while trying to compile partclone 0.2.20 on linux kernel 2.4, glibc 2.2, getting the following error: gcc -DHAVE_CONFIG_H -I. -I.. -DLOCALEDIR=\"/pkg/share/locale\" -g -O2 -MT partclone.o -MD -MP -MF .deps/partclone.Tpo -c -o partclone.o partclone.c partclone.c: In function 'get_partition_size': partclone.c:575: error: 'u64' undeclared (first use in this function) partclone.c:575: error: (Each undeclared identifier is reported only once partclone.c:575: error: for each function it appears in.) make[2]: *** [partclone.o] Error 1 [kernel] Linux gzpLinux 2.4.37.11-gzpLinux #1 Tue Dec 21 12:35:39 CET 2010 i686 GNU/Linux [glibc] GNU C Library stable release version 2.2.5, by Roland McGrath et al. Compiled by GNU CC version 3.3.6. Compiled on a Linux 2.4.36.2-gzpLinux system on 2008-03-22. [gcc] gcc (GCC) 4.4.5 [binutils] GNU ld (Linux/GNU Binutils) 2.21.51.0.7.20110306 [autoconf] autoconf (GNU Autoconf) 2.68 [automake] automake (GNU automake) 1.11.1 [libtool] libtool (GNU libtool) 2.4 |
From: Andreas W. <and...@gm...> - 2011-01-06 16:26:00
|
Hi, On 05.01.2011 13:02, Jeremy Sanders wrote: > Hi - I've tried to configure partclone on Fedora 14 (x86 and x86-64) with ntfs > support, but configure fails. I'm using the latest git repository for > building. This is because the configure script checks for the static version of libntfs, due to the -static switch of gcc. Edit the configure script and remove gcc's -static switch where necessary. Then everything should work just fine. Best regards, Andreas > checking whether -lc should be explicitly linked in... /bin/rm: cannot remove > `conftest*': No such file or directory > no > checking dynamic linker characteristics... GNU/Linux ld.so > checking how to hardcode library paths into programs... immediate > checking whether stripping libraries is possible... yes > checking if libtool supports shared libraries... yes > checking whether to build shared libraries... yes > checking whether to build static libraries... yes > checking for special C compiler options needed for large files... no > checking for _FILE_OFFSET_BITS value needed for large files... 64 > checking for pkg-config... /usr/bin/pkg-config > checking pkg-config is at least version 0.9.0... yes > checking for UUID... yes > configure: checking for NTFS Library and Header files ... ... > checking ntfs/version.h usability... yes > checking ntfs/version.h presence... yes > checking for ntfs/version.h... yes > checking version of libntfs... /usr/bin/ld: cannot find -lntfs > /usr/bin/ld: cannot find -lc > collect2: ld returned 1 exit status > ./configure: line 13957: ./get_lib_version: No such file or directory > ./configure: line 13958: ./get_lib_version: No such file or directory > ./configure: line 13959: ./get_lib_version: No such file or directory > ?:?:?; bad > configure: error: Please check your libntfs! > > ntfsprogs-2.0.0 is installed (Fedora development package also) and libntfs.so > is in /usr/lib or (/usr/lib64). > > Thanks > > Jeremy > |
From: Jeremy S. <je...@je...> - 2011-01-05 12:29:30
|
Hi - I've tried to configure partclone on Fedora 14 (x86 and x86-64) with ntfs support, but configure fails. I'm using the latest git repository for building. checking whether -lc should be explicitly linked in... /bin/rm: cannot remove `conftest*': No such file or directory no checking dynamic linker characteristics... GNU/Linux ld.so checking how to hardcode library paths into programs... immediate checking whether stripping libraries is possible... yes checking if libtool supports shared libraries... yes checking whether to build shared libraries... yes checking whether to build static libraries... yes checking for special C compiler options needed for large files... no checking for _FILE_OFFSET_BITS value needed for large files... 64 checking for pkg-config... /usr/bin/pkg-config checking pkg-config is at least version 0.9.0... yes checking for UUID... yes configure: checking for NTFS Library and Header files ... ... checking ntfs/version.h usability... yes checking ntfs/version.h presence... yes checking for ntfs/version.h... yes checking version of libntfs... /usr/bin/ld: cannot find -lntfs /usr/bin/ld: cannot find -lc collect2: ld returned 1 exit status ./configure: line 13957: ./get_lib_version: No such file or directory ./configure: line 13958: ./get_lib_version: No such file or directory ./configure: line 13959: ./get_lib_version: No such file or directory ?:?:?; bad configure: error: Please check your libntfs! ntfsprogs-2.0.0 is installed (Fedora development package also) and libntfs.so is in /usr/lib or (/usr/lib64). Thanks Jeremy -- Jeremy Sanders <je...@je...> http://jeremysanders.net/ |
From: Andreas F. <in...@pe...> - 2010-12-02 19:03:02
|
Is it possible (despite it's name) to create an image of a whole disk (not just one partition) by simple refering to /dev/sda, instead of sda1 for instance... |
From: Jazz Yao-T. W. <ja...@nc...> - 2010-09-24 01:30:32
|
Hi Mario, > What type of image uses partclone? We define our own image file format referenced from partimage and ntfsclone. > Does the backup saves in a single big file? Yes, by default it's a single big file, but you could pipe to gzip or other tool to split into several files. partclone is more like a administrator tool. You could take a look at Clonezilla (http://www.clonezilla.org) for text user interface which is more easy to use. > Is this file mountable on linux (to check navigate etc)? Yes, thanks to Paul J. Park. He wrote a utilty to mount the partclone image. Check it out at http://www.idealworldinc.com/partclone-utils/ - Jazz |
From: Mario S. <ca...@gm...> - 2010-09-23 18:36:59
|
Hello. I'm new to this and I have a few questions: What type of image uses partclone? Does the backup saves in a single big file? Is this file mountable on linux (to check navigate etc)? Thanks for your information. -- Mario Soto ca...@gm... ..._ |
From: thomas <th...@nc...> - 2010-09-02 14:54:08
|
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Thanks for your effort and contribution. I will check patch file and commit to repository in the next version. BR, Thomas. On 2010年09月02日 21:56, jan Köster wrote: > > > 2010/9/2 jan Köster <tu...@go... <mailto:tu...@go...>> > > Hi I modefied partclone with a gzip out/input but i don't found the > the source file with file operations. Where can i find them ? > > > my patches: > diff -u -r -N partclone-0.2.13/configure.ac <http://configure.ac> > partclone-0.2.13-gzip/configure.ac <http://configure.ac> > --- partclone-0.2.13/configure.ac <http://configure.ac> 2010-07-28 > 12:05:12.000000000 +0200 > +++ partclone-0.2.13-gzip/configure.ac <http://configure.ac> > 2010-09-02 13:11:52.132450071 +0200 > @@ -359,7 +359,14 @@ > AS_HELP_STRING(--enable-ncursesw,enable TEXT User Interface), > enable_ncursesw=yes, > ) > + > +##zlib## > +AC_ARG_ENABLE(gzip, > + AS_HELP_STRING(--enable-gzip,enable GZIP Compression), > + enable_gzip=yes, > +) > + > +AM_CONDITIONAL(ENABLE_ZLIB, test "$enable_ncursesw" = yes) > > if test "$enable_ncursesw" = "yes"; then > > @@ -372,6 +379,16 @@ > AC_MSG_ERROR([*** Ncursesw library (libncursesw5) not found])) > fi > > +if test "$enable_gzip" = "yes"; then > + > +dnl Check for ZLIB > +AC_CHECKING([ for Zlib Library and Header files ... ]) > +AC_CHECK_HEADERS([zlib.h], , > + AC_MSG_ERROR([*** zlib header files (zlib.h) not found]) > +) > +AC_CHECK_LIB(z,compress, , > + AC_MSG_ERROR([*** Zlib library (z) not found])) > +fi > > ##static linking## > AC_ARG_ENABLE(static, > > diff -u -r -N partclone-0.2.13/src/Makefile.am > partclone-0.2.13-gzip/src/Makefile.am > --- partclone-0.2.13/src/Makefile.am 2010-07-28 12:05:12.000000000 +0200 > +++ partclone-0.2.13-gzip/src/Makefile.am 2010-09-02 > 13:48:55.112450881 +0200 > @@ -6,45 +6,49 @@ > version.h: FORCE > $(TOOLBOX) --update-version > > -partclone_info_SOURCES=infoclone.c partclone.c partclone.h fs_common.h > +if ENABLE_ZLIB > + partclone_compress_SOURCES=image_compress.c > +endif > + > +partclone_info_SOURCES=infoclone.c partclone.c partclone.h fs_common.h > ${partclone_compress_SOURCES} > > -partclone_restore_SOURCES=partclone.c partclone.h progress.c progress.h > gettext.h restore.c > +partclone_restore_SOURCES=partclone.c partclone.h progress.c progress.h > gettext.h restore.c ${partclone_compress_SOURCES} > partclone_restore_CFLAGS=-DRESTORE > > -partclone_chkimg_SOURCES=partclone.c partclone.h progress.c progress.h > gettext.h chkimg.c > +partclone_chkimg_SOURCES=partclone.c partclone.h progress.c progress.h > gettext.h chkimg.c ${partclone_compress_SOURCES} > > -partclone_dd_SOURCES=partclone.c partclone.h progress.c progress.h > gettext.h ddclone.c > +partclone_dd_SOURCES=partclone.c partclone.h progress.c progress.h > gettext.h ddclone.c ${partclone_compress_SOURCES} > > if ENABLE_EXTFS > sbin_PROGRAMS += partclone.extfs > -partclone_extfs_SOURCES=main.c partclone.c progress.c extfsclone.c > extfsclone.h partclone.h progress.h gettext.h > +partclone_extfs_SOURCES=main.c partclone.c progress.c extfsclone.c > ${partclone_compress_SOURCES} extfsclone.h partclone.h progress.h gettext.h > partclone_extfs_CFLAGS=-DEXTFS > partclone_extfs_LDADD=-lext2fs -lcom_err -lpthread > endif > > if ENABLE_REISERFS > sbin_PROGRAMS += partclone.reiserfs > -partclone_reiserfs_SOURCES=main.c partclone.c progress.c > reiserfsclone.c reiserfsclone.h partclone.h progress.h gettext.h > +partclone_reiserfs_SOURCES=main.c partclone.c progress.c > reiserfsclone.c ${partclone_compress_SOURCES} reiserfsclone.h > partclone.h progress.h gettext.h > partclone_reiserfs_CFLAGS=-DREISERFS > partclone_reiserfs_LDADD=-lreiserfs -ldal > endif > > if ENABLE_REISER4 > sbin_PROGRAMS += partclone.reiser4 > -partclone_reiser4_SOURCES=main.c partclone.c progress.c reiser4clone.c > reiser4clone.h partclone.h progress.h gettext.h > +partclone_reiser4_SOURCES=main.c partclone.c progress.c reiser4clone.c > ${partclone_compress_SOURCES} reiser4clone.h partclone.h progress.h > gettext.h > partclone_reiser4_CFLAGS=-DREISER4 > partclone_reiser4_LDADD=-lreiser4 -laal > endif > > if ENABLE_HFSP > sbin_PROGRAMS += partclone.hfsp > -partclone_hfsp_SOURCES=main.c partclone.c progress.c hfsplusclone.c > hfsplusclone.h partclone.h progress.h gettext.h > +partclone_hfsp_SOURCES=main.c partclone.c progress.c hfsplusclone.c > ${partclone_compress_SOURCES} hfsplusclone.h partclone.h progress.h > gettext.h > partclone_hfsp_CFLAGS=-DHFSPLUS > endif > > if ENABLE_XFS > sbin_PROGRAMS += partclone.xfs > -partclone_xfs_SOURCES=main.c partclone.c progress.c xfsclone.c > xfsclone.h partclone.h progress.h gettext.h > +partclone_xfs_SOURCES=main.c partclone.c progress.c xfsclone.c > ${partclone_compress_SOURCES} xfsclone.h partclone.h progress.h gettext.h > partclone_xfs_CFLAGS=-DXFS -D_FILE_OFFSET_BITS=64 > partclone_xfs_LDFLAGS= > partclone_xfs_LDADD=-lxfs -lrt -lpthread > @@ -52,13 +56,13 @@ > > if ENABLE_FAT > sbin_PROGRAMS += partclone.fat > -partclone_fat_SOURCES=main.c partclone.c progress.c fatclone.c > fatclone.h partclone.h progress.h gettext.h > +partclone_fat_SOURCES=main.c partclone.c progress.c fatclone.c > ${partclone_compress_SOURCES} fatclone.h partclone.h progress.h gettext.h > partclone_fat_CFLAGS=-DFAT > endif > > if ENABLE_NTFS > sbin_PROGRAMS += partclone.ntfs > -partclone_ntfs_SOURCES=main.c partclone.c progress.c ntfsclone-ng.c > ntfsclone-ng.h partclone.h progress.h gettext.h > +partclone_ntfs_SOURCES=main.c partclone.c progress.c ntfsclone-ng.c > ${partclone_compress_SOURCES} ntfsclone-ng.h partclone.h progress.h > gettext.h > partclone_ntfs_CFLAGS=-DNTFS > partclone_ntfs_LDADD=-lntfs > sbin_PROGRAMS += partclone.ntfsfixboot > @@ -72,14 +76,14 @@ > > if ENABLE_UFS > sbin_PROGRAMS += partclone.ufs > -partclone_ufs_SOURCES=main.c partclone.c progress.c ufsclone.c > ufsclone.h partclone.h progress.h gettext.h > +partclone_ufs_SOURCES=main.c partclone.c progress.c ufsclone.c > ${partclone_compress_SOURCES} ufsclone.h partclone.h progress.h gettext.h > partclone_ufs_CFLAGS=-DUFS -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 > partclone_ufs_LDADD=-lufs -lbsd > endif > > if ENABLE_VMFS > sbin_PROGRAMS += partclone.vmfs > -partclone_vmfs_SOURCES=main.c partclone.c progress.c vmfsclone.c > vmfsclone.h partclone.h progress.h gettext.h > +partclone_vmfs_SOURCES=main.c partclone.c progress.c vmfsclone.c > ${partclone_compress_SOURCES} vmfsclone.h partclone.h progress.h gettext.h > partclone_vmfs_CFLAGS=-DVMFS -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 > $(UUID_CFLAGS) > partclone_vmfs_LDADD=-lvmfs -luuid > > @@ -93,12 +97,11 @@ > if ENABLE_JFS > sbin_PROGRAMS += partclone.jfs > #partclone_jfs_SOURCES=main.c partclone.c progress.c jfs_devices.c > jfs_devices.h jfsclone.c jfsclone.h partclone.h progress.h gettext.h > -partclone_jfs_SOURCES=main.c partclone.c progress.c jfsclone.c > jfsclone.h partclone.h progress.h gettext.h > +partclone_jfs_SOURCES=main.c partclone.c progress.c jfsclone.c > ${partclone_compress_SOURCES} jfsclone.h partclone.h progress.h gettext.h > partclone_jfs_CFLAGS=-DJFS > partclone_jfs_LDADD=-luuid -ljfs > endif > > - > # Extra > install-exec-hook: > $(LN_S) -f partclone.extfs $(DESTDIR)$(sbindir)/partclone.ext2 > > diff -u -r -N partclone-0.2.13/src/image_compress.h > partclone-0.2.13-gzip/src/image_compress.h > --- partclone-0.2.13/src/image_compress.h 1970-01-01 > 01:00:00.000000000 +0100 > +++ partclone-0.2.13-gzip/src/image_compress.h 2010-09-02 > 14:49:25.332450769 +0200 > @@ -0,0 +1,17 @@ > +/** > + * image_compress.h - Part of Partclone project. > + * > + * Copyright (c) 2010~ Jan Koester <jan...@ex... > <mailto:jan...@ex...>> > + * > + * function and structure used by main. > + * > + * This program is free software; you can redistribute it and/or modify > + * it under the terms of the GNU General Public License as published by > + * the Free Software Foundation; either version 2 of the License, or > + * (at your option) any later version. > + */ > + > +extern void compress_image(char *imagegz, char *image); > +extern void uncompress_image(); > +extern long uncompress_size(); > +extern long compress_size(); > \ Kein Zeilenumbruch am Dateiende. > > diff -u -r -N partclone-0.2.13/src/partclone.c > partclone-0.2.13-gzip/src/partclone.c > --- partclone-0.2.13/src/partclone.c 2010-07-28 12:05:12.000000000 +0200 > +++ partclone-0.2.13-gzip/src/partclone.c 2010-09-02 > 14:58:04.953702349 +0200 > @@ -113,6 +113,9 @@ > #ifdef HAVE_LIBNCURSESW > " -N, --ncurses Using Ncurses User Interface\n" > #endif > +#ifdef HAVE_LIBZ > + " -z, --gzip Compress Image with gzip\n" > +#endif > " -X, --dialog Output message as Dialog Format\n" > " -I, --ignore_fschk Ignore filesystem check\n" > " --ignore_crc Ignore crc check error\n" > @@ -153,6 +156,9 @@ > #ifdef HAVE_LIBNCURSESW > { "ncurses", no_argument, NULL, 'N' }, > #endif > +#ifdef HAVE_LIBZ > + { "gzip", no_argument, NULL, 'z' }, > +#endif > { NULL, 0, NULL, 0 } > }; > > @@ -236,6 +242,11 @@ > opt->ncurses = 1; > break; > #endif > +#ifdef HAVE_LIBZ > + case 'z': > + opt->gzip = 1; > + break; > +#endif > case 'C': > opt->check = 0; > break; > @@ -784,7 +795,7 @@ > char *mp; > int flags = O_WRONLY | O_LARGEFILE; > struct stat st_dev; > - > + > log_mesg(1, 0, 0, debug, "open target file/device\n"); > if (opt->clone){ > if (strcmp(target, "-") == 0){ > @@ -795,8 +806,9 @@ > flags |= O_CREAT; /// new file > if (!opt->overwrite) /// overwrite > flags |= O_EXCL; > + > ret = open (target, flags, S_IRUSR); > - > + > if (ret == -1){ > if (errno == EEXIST){ > log_mesg(0, 0, 1, debug, "Output file '%s' already > exists.\nUse option --overwrite if you want to replace its content.\n", > target); > > diff -u -r -N partclone-0.2.13/src/image_compress.c > partclone-0.2.13-gzip/src/image_compress.c > --- partclone-0.2.13/src/image_compress.c 1970-01-01 > 01:00:00.000000000 +0100 > +++ partclone-0.2.13-gzip/src/image_compress.c 2010-09-02 > 14:49:21.143700176 +0200 > @@ -0,0 +1,62 @@ > +/** > + * image_compress.c - Part of Partclone project. > + * > + * Copyright (c) 2010~ Jan Koester <jan...@ex... > <mailto:jan...@ex...>> > + * > + * function and structure used by main. > + * > + * This program is free software; you can redistribute it and/or modify > + * it under the terms of the GNU General Public License as published by > + * the Free Software Foundation; either version 2 of the License, or > + * (at your option) any later version. > + */ > + > +#include <stdio.h> > +#include <string.h> > +#include <zlib.h> > +#include "image_compress.h" > + > +#define Z_BEST_COMPRESSION 9 > + > +void compress_image(char *imagegz, const char *image){ > + Byte *compr; > + uLong comprLen; > + z_stream c_stream; /* compression stream */ > + int err; > + int len = strlen(hello)+1; > + c_stream.zalloc = (alloc_func)0; > + c_stream.zfree = (free_func)0; > + c_stream.opaque = (voidpf)0; > + err = deflateInit(&c_stream, Z_DEFAULT_COMPRESSION); > + CHECK_ERR(err, "deflateInit"); > + c_stream.next_in = (Bytef*)hello; > + c_stream.next_out = compr; > + while (c_stream.total_in != (uLong)len && c_stream.total_out < > comprLen) { > + c_stream.avail_in = c_stream.avail_out = 1; /* force small buffers */ > + err = deflate(&c_stream, Z_NO_FLUSH); > + CHECK_ERR(err, "deflate"); > + } > + /* Finish the stream, still forcing small buffers: */ > + for (;;) { > + c_stream.avail_out = 1; > + err = deflate(&c_stream, Z_FINISH); > + if (err == Z_STREAM_END) break; > + CHECK_ERR(err, "deflate"); > + } > + > + err = deflateEnd(&c_stream); > + CHECK_ERR(err, "deflateEnd"); > + } > +} > + > +void uncompress_image(){ > +// printf("Test Uncompress"); > +} > + > +long uncompress_size(){ > + > +} > + > +long compress_size(){ > + > +} > \ Kein Zeilenumbruch am Dateiende. > > diff -u -r -N partclone-0.2.13/src/partclone.h > partclone-0.2.13-gzip/src/partclone.h > --- partclone-0.2.13/src/partclone.h 2010-07-28 12:05:12.000000000 +0200 > +++ partclone-0.2.13-gzip/src/partclone.h 2010-09-02 > 14:06:41.722450617 +0200 > @@ -79,10 +79,11 @@ > int rescue; > int check; > int ncurses; > + int gzip; > int dialog; > int force; > int ignore_fschk; > - int ignore_crc; > + int ignore_crc; > unsigned long fresh; > }; > typedef struct cmd_opt cmd_opt; > @@ -101,6 +102,7 @@ > int percent; > char data[1024]; > }; > + > typedef struct dialog_mesg p_dialog_mesg; > /** > * debug message > > > > > > > ------------------------------------------------------------------------------ > This SF.net Dev2Dev email is sponsored by: > > Show off your parallel programming skills. > Enter the Intel(R) Threading Challenge 2010. > http://p.sf.net/sfu/intel-thread-sfd > > > > _______________________________________________ > Partclone-user mailing list > Par...@li... > https://lists.sourceforge.net/lists/listinfo/partclone-user - -- Thomas, 蔡育欽 國家高速網路與計算中心 格網技術組 專案助理研究員 thomas at nchc org tw pub key 46379ACF fingerprint = 7BB2 2103 CADC 59F6 11D5 BCB3 5E97 22B4 4637 9ACF -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.10 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAkx/uoQACgkQXpcitEY3ms+jtgCgqIWp0GR3ClS0PH+3y7KXsS2a D30An0f1lcCnGXA9ybHr0N80WR0shFEx =dfoq -----END PGP SIGNATURE----- |
From: jan K. <tu...@go...> - 2010-09-02 13:56:40
|
2010/9/2 jan Köster <tu...@go...> > Hi I modefied partclone with a gzip out/input but i don't found the the > source file with file operations. Where can i find them ? > > > my patches: diff -u -r -N partclone-0.2.13/configure.ac partclone-0.2.13-gzip/ configure.ac --- partclone-0.2.13/configure.ac 2010-07-28 12:05:12.000000000 +0200 +++ partclone-0.2.13-gzip/configure.ac 2010-09-02 13:11:52.132450071 +0200 @@ -359,7 +359,14 @@ AS_HELP_STRING(--enable-ncursesw,enable TEXT User Interface), enable_ncursesw=yes, ) + +##zlib## +AC_ARG_ENABLE(gzip, + AS_HELP_STRING(--enable-gzip,enable GZIP Compression), + enable_gzip=yes, +) + +AM_CONDITIONAL(ENABLE_ZLIB, test "$enable_ncursesw" = yes) if test "$enable_ncursesw" = "yes"; then @@ -372,6 +379,16 @@ AC_MSG_ERROR([*** Ncursesw library (libncursesw5) not found])) fi +if test "$enable_gzip" = "yes"; then + +dnl Check for ZLIB +AC_CHECKING([ for Zlib Library and Header files ... ]) +AC_CHECK_HEADERS([zlib.h], , + AC_MSG_ERROR([*** zlib header files (zlib.h) not found]) +) +AC_CHECK_LIB(z,compress, , + AC_MSG_ERROR([*** Zlib library (z) not found])) +fi ##static linking## AC_ARG_ENABLE(static, diff -u -r -N partclone-0.2.13/src/Makefile.am partclone-0.2.13-gzip/src/Makefile.am --- partclone-0.2.13/src/Makefile.am 2010-07-28 12:05:12.000000000 +0200 +++ partclone-0.2.13-gzip/src/Makefile.am 2010-09-02 13:48:55.112450881 +0200 @@ -6,45 +6,49 @@ version.h: FORCE $(TOOLBOX) --update-version -partclone_info_SOURCES=infoclone.c partclone.c partclone.h fs_common.h +if ENABLE_ZLIB + partclone_compress_SOURCES=image_compress.c +endif + +partclone_info_SOURCES=infoclone.c partclone.c partclone.h fs_common.h ${partclone_compress_SOURCES} -partclone_restore_SOURCES=partclone.c partclone.h progress.c progress.h gettext.h restore.c +partclone_restore_SOURCES=partclone.c partclone.h progress.c progress.h gettext.h restore.c ${partclone_compress_SOURCES} partclone_restore_CFLAGS=-DRESTORE -partclone_chkimg_SOURCES=partclone.c partclone.h progress.c progress.h gettext.h chkimg.c +partclone_chkimg_SOURCES=partclone.c partclone.h progress.c progress.h gettext.h chkimg.c ${partclone_compress_SOURCES} -partclone_dd_SOURCES=partclone.c partclone.h progress.c progress.h gettext.h ddclone.c +partclone_dd_SOURCES=partclone.c partclone.h progress.c progress.h gettext.h ddclone.c ${partclone_compress_SOURCES} if ENABLE_EXTFS sbin_PROGRAMS += partclone.extfs -partclone_extfs_SOURCES=main.c partclone.c progress.c extfsclone.c extfsclone.h partclone.h progress.h gettext.h +partclone_extfs_SOURCES=main.c partclone.c progress.c extfsclone.c ${partclone_compress_SOURCES} extfsclone.h partclone.h progress.h gettext.h partclone_extfs_CFLAGS=-DEXTFS partclone_extfs_LDADD=-lext2fs -lcom_err -lpthread endif if ENABLE_REISERFS sbin_PROGRAMS += partclone.reiserfs -partclone_reiserfs_SOURCES=main.c partclone.c progress.c reiserfsclone.c reiserfsclone.h partclone.h progress.h gettext.h +partclone_reiserfs_SOURCES=main.c partclone.c progress.c reiserfsclone.c ${partclone_compress_SOURCES} reiserfsclone.h partclone.h progress.h gettext.h partclone_reiserfs_CFLAGS=-DREISERFS partclone_reiserfs_LDADD=-lreiserfs -ldal endif if ENABLE_REISER4 sbin_PROGRAMS += partclone.reiser4 -partclone_reiser4_SOURCES=main.c partclone.c progress.c reiser4clone.c reiser4clone.h partclone.h progress.h gettext.h +partclone_reiser4_SOURCES=main.c partclone.c progress.c reiser4clone.c ${partclone_compress_SOURCES} reiser4clone.h partclone.h progress.h gettext.h partclone_reiser4_CFLAGS=-DREISER4 partclone_reiser4_LDADD=-lreiser4 -laal endif if ENABLE_HFSP sbin_PROGRAMS += partclone.hfsp -partclone_hfsp_SOURCES=main.c partclone.c progress.c hfsplusclone.c hfsplusclone.h partclone.h progress.h gettext.h +partclone_hfsp_SOURCES=main.c partclone.c progress.c hfsplusclone.c ${partclone_compress_SOURCES} hfsplusclone.h partclone.h progress.h gettext.h partclone_hfsp_CFLAGS=-DHFSPLUS endif if ENABLE_XFS sbin_PROGRAMS += partclone.xfs -partclone_xfs_SOURCES=main.c partclone.c progress.c xfsclone.c xfsclone.h partclone.h progress.h gettext.h +partclone_xfs_SOURCES=main.c partclone.c progress.c xfsclone.c ${partclone_compress_SOURCES} xfsclone.h partclone.h progress.h gettext.h partclone_xfs_CFLAGS=-DXFS -D_FILE_OFFSET_BITS=64 partclone_xfs_LDFLAGS= partclone_xfs_LDADD=-lxfs -lrt -lpthread @@ -52,13 +56,13 @@ if ENABLE_FAT sbin_PROGRAMS += partclone.fat -partclone_fat_SOURCES=main.c partclone.c progress.c fatclone.c fatclone.h partclone.h progress.h gettext.h +partclone_fat_SOURCES=main.c partclone.c progress.c fatclone.c ${partclone_compress_SOURCES} fatclone.h partclone.h progress.h gettext.h partclone_fat_CFLAGS=-DFAT endif if ENABLE_NTFS sbin_PROGRAMS += partclone.ntfs -partclone_ntfs_SOURCES=main.c partclone.c progress.c ntfsclone-ng.c ntfsclone-ng.h partclone.h progress.h gettext.h +partclone_ntfs_SOURCES=main.c partclone.c progress.c ntfsclone-ng.c ${partclone_compress_SOURCES} ntfsclone-ng.h partclone.h progress.h gettext.h partclone_ntfs_CFLAGS=-DNTFS partclone_ntfs_LDADD=-lntfs sbin_PROGRAMS += partclone.ntfsfixboot @@ -72,14 +76,14 @@ if ENABLE_UFS sbin_PROGRAMS += partclone.ufs -partclone_ufs_SOURCES=main.c partclone.c progress.c ufsclone.c ufsclone.h partclone.h progress.h gettext.h +partclone_ufs_SOURCES=main.c partclone.c progress.c ufsclone.c ${partclone_compress_SOURCES} ufsclone.h partclone.h progress.h gettext.h partclone_ufs_CFLAGS=-DUFS -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 partclone_ufs_LDADD=-lufs -lbsd endif if ENABLE_VMFS sbin_PROGRAMS += partclone.vmfs -partclone_vmfs_SOURCES=main.c partclone.c progress.c vmfsclone.c vmfsclone.h partclone.h progress.h gettext.h +partclone_vmfs_SOURCES=main.c partclone.c progress.c vmfsclone.c ${partclone_compress_SOURCES} vmfsclone.h partclone.h progress.h gettext.h partclone_vmfs_CFLAGS=-DVMFS -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 $(UUID_CFLAGS) partclone_vmfs_LDADD=-lvmfs -luuid @@ -93,12 +97,11 @@ if ENABLE_JFS sbin_PROGRAMS += partclone.jfs #partclone_jfs_SOURCES=main.c partclone.c progress.c jfs_devices.c jfs_devices.h jfsclone.c jfsclone.h partclone.h progress.h gettext.h -partclone_jfs_SOURCES=main.c partclone.c progress.c jfsclone.c jfsclone.h partclone.h progress.h gettext.h +partclone_jfs_SOURCES=main.c partclone.c progress.c jfsclone.c ${partclone_compress_SOURCES} jfsclone.h partclone.h progress.h gettext.h partclone_jfs_CFLAGS=-DJFS partclone_jfs_LDADD=-luuid -ljfs endif - # Extra install-exec-hook: $(LN_S) -f partclone.extfs $(DESTDIR)$(sbindir)/partclone.ext2 diff -u -r -N partclone-0.2.13/src/image_compress.h partclone-0.2.13-gzip/src/image_compress.h --- partclone-0.2.13/src/image_compress.h 1970-01-01 01:00:00.000000000 +0100 +++ partclone-0.2.13-gzip/src/image_compress.h 2010-09-02 14:49:25.332450769 +0200 @@ -0,0 +1,17 @@ +/** + * image_compress.h - Part of Partclone project. + * + * Copyright (c) 2010~ Jan Koester <jan...@ex...> + * + * function and structure used by main. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + */ + +extern void compress_image(char *imagegz, char *image); +extern void uncompress_image(); +extern long uncompress_size(); +extern long compress_size(); \ Kein Zeilenumbruch am Dateiende. diff -u -r -N partclone-0.2.13/src/partclone.c partclone-0.2.13-gzip/src/partclone.c --- partclone-0.2.13/src/partclone.c 2010-07-28 12:05:12.000000000 +0200 +++ partclone-0.2.13-gzip/src/partclone.c 2010-09-02 14:58:04.953702349 +0200 @@ -113,6 +113,9 @@ #ifdef HAVE_LIBNCURSESW " -N, --ncurses Using Ncurses User Interface\n" #endif +#ifdef HAVE_LIBZ + " -z, --gzip Compress Image with gzip\n" +#endif " -X, --dialog Output message as Dialog Format\n" " -I, --ignore_fschk Ignore filesystem check\n" " --ignore_crc Ignore crc check error\n" @@ -153,6 +156,9 @@ #ifdef HAVE_LIBNCURSESW { "ncurses", no_argument, NULL, 'N' }, #endif +#ifdef HAVE_LIBZ + { "gzip", no_argument, NULL, 'z' }, +#endif { NULL, 0, NULL, 0 } }; @@ -236,6 +242,11 @@ opt->ncurses = 1; break; #endif +#ifdef HAVE_LIBZ + case 'z': + opt->gzip = 1; + break; +#endif case 'C': opt->check = 0; break; @@ -784,7 +795,7 @@ char *mp; int flags = O_WRONLY | O_LARGEFILE; struct stat st_dev; - + log_mesg(1, 0, 0, debug, "open target file/device\n"); if (opt->clone){ if (strcmp(target, "-") == 0){ @@ -795,8 +806,9 @@ flags |= O_CREAT; /// new file if (!opt->overwrite) /// overwrite flags |= O_EXCL; + ret = open (target, flags, S_IRUSR); - + if (ret == -1){ if (errno == EEXIST){ log_mesg(0, 0, 1, debug, "Output file '%s' already exists.\nUse option --overwrite if you want to replace its content.\n", target); diff -u -r -N partclone-0.2.13/src/image_compress.c partclone-0.2.13-gzip/src/image_compress.c --- partclone-0.2.13/src/image_compress.c 1970-01-01 01:00:00.000000000 +0100 +++ partclone-0.2.13-gzip/src/image_compress.c 2010-09-02 14:49:21.143700176 +0200 @@ -0,0 +1,62 @@ +/** + * image_compress.c - Part of Partclone project. + * + * Copyright (c) 2010~ Jan Koester <jan...@ex...> + * + * function and structure used by main. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + */ + +#include <stdio.h> +#include <string.h> +#include <zlib.h> +#include "image_compress.h" + +#define Z_BEST_COMPRESSION 9 + +void compress_image(char *imagegz, const char *image){ + Byte *compr; + uLong comprLen; + z_stream c_stream; /* compression stream */ + int err; + int len = strlen(hello)+1; + c_stream.zalloc = (alloc_func)0; + c_stream.zfree = (free_func)0; + c_stream.opaque = (voidpf)0; + err = deflateInit(&c_stream, Z_DEFAULT_COMPRESSION); + CHECK_ERR(err, "deflateInit"); + c_stream.next_in = (Bytef*)hello; + c_stream.next_out = compr; + while (c_stream.total_in != (uLong)len && c_stream.total_out < comprLen) { + c_stream.avail_in = c_stream.avail_out = 1; /* force small buffers */ + err = deflate(&c_stream, Z_NO_FLUSH); + CHECK_ERR(err, "deflate"); + } + /* Finish the stream, still forcing small buffers: */ + for (;;) { + c_stream.avail_out = 1; + err = deflate(&c_stream, Z_FINISH); + if (err == Z_STREAM_END) break; + CHECK_ERR(err, "deflate"); + } + + err = deflateEnd(&c_stream); + CHECK_ERR(err, "deflateEnd"); + } +} + +void uncompress_image(){ +// printf("Test Uncompress"); +} + +long uncompress_size(){ + +} + +long compress_size(){ + +} \ Kein Zeilenumbruch am Dateiende. diff -u -r -N partclone-0.2.13/src/partclone.h partclone-0.2.13-gzip/src/partclone.h --- partclone-0.2.13/src/partclone.h 2010-07-28 12:05:12.000000000 +0200 +++ partclone-0.2.13-gzip/src/partclone.h 2010-09-02 14:06:41.722450617 +0200 @@ -79,10 +79,11 @@ int rescue; int check; int ncurses; + int gzip; int dialog; int force; int ignore_fschk; - int ignore_crc; + int ignore_crc; unsigned long fresh; }; typedef struct cmd_opt cmd_opt; @@ -101,6 +102,7 @@ int percent; char data[1024]; }; + typedef struct dialog_mesg p_dialog_mesg; /** * debug message |
From: jan K. <tu...@go...> - 2010-09-02 13:34:25
|
Hi I modefied partclone with a gzip out/input but i don't found the the source file with file operations. Where can i find them ? |
From: Yavor N. <nik...@gm...> - 2010-05-04 21:22:54
|
Hi, I agree with Andre that there is a problem: actual string lengths don't match (they're often shorter than) FS_MAGIC_SIZE. The random bytes are bad but the more serious issue is that memory out of string ranges is accessed (may lead to errors like access violation & segmentation fault). /It may worth running some valgrind tests - maybe it would be able to catch some errors like that/ Regards, Yavor 2010/5/4 André Przywara <an...@an...> > On Tue, 4 May 2010 20:33:05 +0800 > Jazz Yao-Tsung Wang <jaz...@gm...> wrote: > > > Hi Andre, > > > > Thanks for your contribution. > Thanks for the review. > > After discussed with thomas, we might not able to apply your patch. > > > > 1. for the partclone image backward compatibility > How does this affect backward compatibility? The strings are > zero-terminated, so the \0 byte is both in the file header as well in > the structure in memory. The "specification" of your file structure > only talks about a zero terminated string. > C string functions (not memcpy!) will not go beyond that byte, so from > the program point of view there is no difference. So although you read > the whole 15 bytes, you will never examine bytes behind the \0. > But the bytes are there in the file (see below) and they are at least > needless, if not dangerous. > > 2. we use memset to set zero into array, so it will not be filled with > > random bytes. > You clean it before, but then you use memcpy with the size of the > _target_ buffer to copy the string. For illustration: If you write > "EXTFS" somewhere in you C file, the characters along with the 0 byte > will be put in the data segment of your program. What happens to be > after the \0 byte is compiler dependent. So the memory looks like: > E X T F S \0 r a n d o m f o o b a r > Then you say: memcpy(dest, src, 15), so will copy all the random stuff > right into the structure and then into the file. > The header of a partclone-image file before: > 0000 70 61 72 74 63 6C 6F 6E 65 2D 69 6D 61 67 65 45 > partclone-imageE > 0010 58 54 46 53 00 25 73 3A 20 72 65 61 64 62 30 30 > XTFS.%s: readb00 > 0020 30 31 00 00 00 10 00 00 00 80 C0 3E 00 00 00 00 > 01.........>.... > You see the "%s: readb" garbage behind the EXTFS\0 string. > With my patch the hexdump of the header looks like this: > 0000 70 61 72 74 63 6C 6F 6E 65 2D 69 6D 61 67 65 45 > partclone-imageE > 0010 58 54 46 53 00 00 00 00 00 00 00 00 00 00 30 30 > XTFS..........00 > 0020 30 31 00 00 00 10 00 00 00 80 C0 3E 00 00 00 00 > 01.........>.... > You see that there are only zeros behind the string. > > So please reconsider your decision and apply the patch. > > Thanks! > Andre. > > > On Tue, May 4, 2010 at 6:00 AM, Andre Przywara <os...@an...> wrote: > > > When we copy the filesystem type name into the header, we must not > > > access memory behind the trailing \0 byte, also the buffer should > > > not be filled with random bytes (may leak information). strncpy is > > > the perfect solution to this problem, so replace the usage of memcpy > > > with this function. > > > > > > Signed-off-by: Andre Przywara <os...@an...> > > > --- > > > src/extfsclone.c | 4 ++-- > > > src/fatclone.c | 4 ++-- > > > src/hfsplusclone.c | 4 ++-- > > > src/main.c | 4 ++-- > > > src/ntfsclone-ng.c | 4 ++-- > > > src/partclone.c | 4 ++-- > > > src/reiser4clone.c | 4 ++-- > > > src/reiserfsclone.c | 4 ++-- > > > src/ufsclone.c | 4 ++-- > > > src/vmfsclone.c | 4 ++-- > > > src/xfsclone.c | 4 ++-- > > > 11 files changed, 22 insertions(+), 22 deletions(-) > > > > > > diff --git a/src/extfsclone.c b/src/extfsclone.c > > > index 39ba552..8db81ea 100644 > > > --- a/src/extfsclone.c > > > +++ b/src/extfsclone.c > > > @@ -210,8 +210,8 @@ extern void initial_image_hdr(char* device, > > > image_head* image_hdr) { > > > int fs_type = 0; > > > fs_type = test_extfs_type(device); > > > - memcpy(image_hdr->magic, IMAGE_MAGIC, IMAGE_MAGIC_SIZE); > > > - memcpy(image_hdr->fs, extfs_MAGIC, FS_MAGIC_SIZE); > > > + strncpy(image_hdr->magic, IMAGE_MAGIC, IMAGE_MAGIC_SIZE); > > > + strncpy(image_hdr->fs, extfs_MAGIC, FS_MAGIC_SIZE); > > > fs_open(device); > > > image_hdr->block_size = (int)block_size(); > > > image_hdr->totalblock = (uint64_t)block_count(); > > > diff --git a/src/fatclone.c b/src/fatclone.c > > > index bbcad93..b763204 100644 > > > --- a/src/fatclone.c > > > +++ b/src/fatclone.c > > > @@ -334,8 +334,8 @@ extern void initial_image_hdr(char* device, > > > image_head* image_hdr) > > > > > > bused = get_used_block();//so I need calculate by myself. > > > > > > - memcpy(image_hdr->magic, IMAGE_MAGIC, IMAGE_MAGIC_SIZE); > > > - memcpy(image_hdr->fs, fat_type, FS_MAGIC_SIZE); > > > + strncpy(image_hdr->magic, IMAGE_MAGIC, IMAGE_MAGIC_SIZE); > > > + strncpy(image_hdr->fs, fat_type, FS_MAGIC_SIZE); > > > image_hdr->block_size = (int)fat_sb.sector_size; > > > image_hdr->totalblock = (uint64_t)total_sector; > > > image_hdr->device_size = (uint64_t)(total_sector * > > > image_hdr->block_size); diff --git a/src/hfsplusclone.c > > > b/src/hfsplusclone.c index 245b76d..8914e3b 100644 > > > --- a/src/hfsplusclone.c > > > +++ b/src/hfsplusclone.c > > > @@ -199,8 +199,8 @@ extern void initial_image_hdr(char* device, > > > image_head* image_hdr) { > > > > > > fs_open(device); > > > - memcpy(image_hdr->magic, IMAGE_MAGIC, IMAGE_MAGIC_SIZE); > > > - memcpy(image_hdr->fs, hfsplus_MAGIC, FS_MAGIC_SIZE); > > > + strncpy(image_hdr->magic, IMAGE_MAGIC, IMAGE_MAGIC_SIZE); > > > + strncpy(image_hdr->fs, hfsplus_MAGIC, FS_MAGIC_SIZE); > > > image_hdr->block_size = (int)reverseInt(sb.blockSize); > > > image_hdr->totalblock = (uint64_t)reverseInt(sb.totalBlocks); > > > image_hdr->device_size = (uint64_t)(image_hdr->block_size * > > > image_hdr->totalblock); diff --git a/src/main.c b/src/main.c > > > index ffaf568..5f91b5c 100644 > > > --- a/src/main.c > > > +++ b/src/main.c > > > @@ -207,7 +207,7 @@ int main(int argc, char **argv){ > > > log_mesg(0, 1, 1, debug, "Ther is no enough free > > > memory, partclone suggests you should have %i bytes memory\n", > > > needed_mem); > > > > > > /// set partclone image version > > > - memcpy(image_hdr.version, IMAGE_VERSION, VERSION_SIZE); > > > + strncpy(image_hdr.version, IMAGE_VERSION, VERSION_SIZE); > > > > > > /// alloc a memory to restore bitmap > > > bitmap = initial_bitmap(image_hdr.totalblock, &opt); > > > @@ -279,7 +279,7 @@ int main(int argc, char **argv){ > > > if (check_mem_size(image_hdr, opt, &needed_mem) == -1) > > > log_mesg(0, 1, 1, debug, "Ther is no enough free > > > memory, partclone suggests you should have %i bytes memory\n", > > > needed_mem); > > > > > > - memcpy(image_hdr.version, IMAGE_VERSION, VERSION_SIZE); > > > + strncpy(image_hdr.version, IMAGE_VERSION, VERSION_SIZE); > > > > > > /// alloc a memory to restore bitmap > > > bitmap = initial_bitmap(image_hdr.totalblock, &opt); > > > diff --git a/src/ntfsclone-ng.c b/src/ntfsclone-ng.c > > > index 216d50a..2d887f6 100644 > > > --- a/src/ntfsclone-ng.c > > > +++ b/src/ntfsclone-ng.c > > > @@ -279,8 +279,8 @@ extern void readbitmap(char* device, image_head > > > image_hdr, char* bitmap, int pui extern void > > > initial_image_hdr(char* device, image_head* image_hdr) { > > > fs_open(device); > > > - memcpy(image_hdr->magic, IMAGE_MAGIC, IMAGE_MAGIC_SIZE); > > > - memcpy(image_hdr->fs, ntfs_MAGIC, FS_MAGIC_SIZE); > > > + strncpy(image_hdr->magic, IMAGE_MAGIC, IMAGE_MAGIC_SIZE); > > > + strncpy(image_hdr->fs, ntfs_MAGIC, FS_MAGIC_SIZE); > > > image_hdr->block_size = (int)ntfs->cluster_size; > > > image_hdr->totalblock = (uint64_t)ntfs->nr_clusters; > > > image_hdr->usedblocks = (uint64_t)(ntfs->nr_clusters - > > > ntfs->nr_free_clusters); diff --git a/src/partclone.c > > > b/src/partclone.c index babc3a8..818e139 100644 > > > --- a/src/partclone.c > > > +++ b/src/partclone.c > > > @@ -1061,8 +1061,8 @@ static uint64_t block_count(uint64_t > > > partition_size, int block_size){ /// initial dd hdr > > > extern void initial_dd_hdr(int ret, image_head* image_hdr){ > > > > > > - memset(image_hdr ,(int )NULL, sizeof(image_head)); > > > - memcpy(image_hdr->fs, raw_MAGIC, FS_MAGIC_SIZE); > > > + memset(image_hdr, 0, sizeof(image_head)); > > > + strncpy(image_hdr->fs, raw_MAGIC, FS_MAGIC_SIZE); > > > image_hdr->block_size = 512*2; > > > image_hdr->device_size = get_partition_size(&ret); > > > image_hdr->totalblock = block_count(image_hdr->device_size, > > > image_hdr->block_size); diff --git a/src/reiser4clone.c > > > b/src/reiser4clone.c index fc1dc95..f1d6cb2 100644 > > > --- a/src/reiser4clone.c > > > +++ b/src/reiser4clone.c > > > @@ -147,8 +147,8 @@ extern void initial_image_hdr(char* device, > > > image_head* image_hdr) fs_bitmap = > > > reiser4_bitmap_create(reiser4_format_get_len(fs->format)); > > > reiser4_alloc_extract(fs->alloc, fs_bitmap); free_blocks = > > > reiser4_format_get_free(fs->format); > > > - memcpy(image_hdr->magic, IMAGE_MAGIC, IMAGE_MAGIC_SIZE); > > > - memcpy(image_hdr->fs, reiser4_MAGIC, FS_MAGIC_SIZE); > > > + strncpy(image_hdr->magic, IMAGE_MAGIC, IMAGE_MAGIC_SIZE); > > > + strncpy(image_hdr->fs, reiser4_MAGIC, FS_MAGIC_SIZE); > > > image_hdr->block_size = (int)get_ms_blksize(SUPER(fs->master)); > > > image_hdr->totalblock = > > > (uint64_t)reiser4_format_get_len(fs->format); image_hdr->usedblocks > > > = (uint64_t)(reiser4_format_get_len(fs->format) - free_blocks); > > > diff --git a/src/reiserfsclone.c b/src/reiserfsclone.c index > > > eb4272b..c888bac 100644 --- a/src/reiserfsclone.c > > > +++ b/src/reiserfsclone.c > > > @@ -116,8 +116,8 @@ extern void readbitmap(char* device, image_head > > > image_hdr, char* bitmap, int pui extern void > > > initial_image_hdr(char* device, image_head* image_hdr) { > > > fs_open(device); > > > - memcpy(image_hdr->magic, IMAGE_MAGIC, IMAGE_MAGIC_SIZE); > > > - memcpy(image_hdr->fs, reiserfs_MAGIC, FS_MAGIC_SIZE); > > > + strncpy(image_hdr->magic, IMAGE_MAGIC, IMAGE_MAGIC_SIZE); > > > + strncpy(image_hdr->fs, reiserfs_MAGIC, FS_MAGIC_SIZE); > > > image_hdr->block_size = (int)fs->super->s_v1.sb_block_size; > > > image_hdr->totalblock = > > > (uint64_t)fs->super->s_v1.sb_block_count; image_hdr->usedblocks = > > > (uint64_t)(fs->super->s_v1.sb_block_count - > > > fs->super->s_v1.sb_free_blocks); diff --git a/src/ufsclone.c > > > b/src/ufsclone.c index 7d906df..c4c6375 100644 --- a/src/ufsclone.c > > > +++ b/src/ufsclone.c > > > @@ -155,8 +155,8 @@ extern void initial_image_hdr(char* device, > > > image_head* image_hdr) { > > > > > > fs_open(device); > > > - memcpy(image_hdr->magic, IMAGE_MAGIC, IMAGE_MAGIC_SIZE); > > > - memcpy(image_hdr->fs, ufs_MAGIC, FS_MAGIC_SIZE); > > > + strncpy(image_hdr->magic, IMAGE_MAGIC, IMAGE_MAGIC_SIZE); > > > + strncpy(image_hdr->fs, ufs_MAGIC, FS_MAGIC_SIZE); > > > > > > image_hdr->block_size = afs.fs_fsize; > > > image_hdr->usedblocks = get_used_block(); > > > diff --git a/src/vmfsclone.c b/src/vmfsclone.c > > > index ada9bb8..f03362c 100644 > > > --- a/src/vmfsclone.c > > > +++ b/src/vmfsclone.c > > > @@ -110,8 +110,8 @@ extern void initial_image_hdr(char* device, > > > image_head* image_hdr) uint32_t alloc,total; > > > > > > fs_open(device); > > > - memcpy(image_hdr->magic, IMAGE_MAGIC, IMAGE_MAGIC_SIZE); > > > - memcpy(image_hdr->fs, vmfs_MAGIC, FS_MAGIC_SIZE); > > > + strncpy(image_hdr->magic, IMAGE_MAGIC, IMAGE_MAGIC_SIZE); > > > + strncpy(image_hdr->fs, vmfs_MAGIC, FS_MAGIC_SIZE); > > > > > > total = fs->fbb->bmh.total_items; > > > alloc = vmfs_bitmap_allocated_items(fs->fbb); > > > diff --git a/src/xfsclone.c b/src/xfsclone.c > > > index 1ae3799..f368996 100644 > > > --- a/src/xfsclone.c > > > +++ b/src/xfsclone.c > > > @@ -172,8 +172,8 @@ static void fs_close() > > > extern void initial_image_hdr(char* device, image_head* image_hdr) > > > { > > > fs_open(device); > > > - memcpy(image_hdr->magic, IMAGE_MAGIC, IMAGE_MAGIC_SIZE); > > > - memcpy(image_hdr->fs, xfs_MAGIC, FS_MAGIC_SIZE); > > > + strncpy(image_hdr->magic, IMAGE_MAGIC, IMAGE_MAGIC_SIZE); > > > + strncpy(image_hdr->fs, xfs_MAGIC, FS_MAGIC_SIZE); > > > image_hdr->block_size = mp->m_sb.sb_blocksize; > > > image_hdr->totalblock = mp->m_sb.sb_dblocks; > > > image_hdr->usedblocks = mp->m_sb.sb_dblocks - > > > mp->m_sb.sb_fdblocks; -- > > > 1.6.1.3 > > > > > > > > > > ------------------------------------------------------------------------------ > > > _______________________________________________ > > > Partclone-user mailing list > > > Par...@li... > > > https://lists.sourceforge.net/lists/listinfo/partclone-user > > > > > > ------------------------------------------------------------------------------ > _______________________________________________ > Partclone-user mailing list > Par...@li... > https://lists.sourceforge.net/lists/listinfo/partclone-user > |
From: André P. <an...@an...> - 2010-05-04 20:41:19
|
On Tue, 4 May 2010 20:33:05 +0800 Jazz Yao-Tsung Wang <jaz...@gm...> wrote: > Hi Andre, > > Thanks for your contribution. Thanks for the review. > After discussed with thomas, we might not able to apply your patch. > > 1. for the partclone image backward compatibility How does this affect backward compatibility? The strings are zero-terminated, so the \0 byte is both in the file header as well in the structure in memory. The "specification" of your file structure only talks about a zero terminated string. C string functions (not memcpy!) will not go beyond that byte, so from the program point of view there is no difference. So although you read the whole 15 bytes, you will never examine bytes behind the \0. But the bytes are there in the file (see below) and they are at least needless, if not dangerous. > 2. we use memset to set zero into array, so it will not be filled with > random bytes. You clean it before, but then you use memcpy with the size of the _target_ buffer to copy the string. For illustration: If you write "EXTFS" somewhere in you C file, the characters along with the 0 byte will be put in the data segment of your program. What happens to be after the \0 byte is compiler dependent. So the memory looks like: E X T F S \0 r a n d o m f o o b a r Then you say: memcpy(dest, src, 15), so will copy all the random stuff right into the structure and then into the file. The header of a partclone-image file before: 0000 70 61 72 74 63 6C 6F 6E 65 2D 69 6D 61 67 65 45 partclone-imageE 0010 58 54 46 53 00 25 73 3A 20 72 65 61 64 62 30 30 XTFS.%s: readb00 0020 30 31 00 00 00 10 00 00 00 80 C0 3E 00 00 00 00 01.........>.... You see the "%s: readb" garbage behind the EXTFS\0 string. With my patch the hexdump of the header looks like this: 0000 70 61 72 74 63 6C 6F 6E 65 2D 69 6D 61 67 65 45 partclone-imageE 0010 58 54 46 53 00 00 00 00 00 00 00 00 00 00 30 30 XTFS..........00 0020 30 31 00 00 00 10 00 00 00 80 C0 3E 00 00 00 00 01.........>.... You see that there are only zeros behind the string. So please reconsider your decision and apply the patch. Thanks! Andre. > On Tue, May 4, 2010 at 6:00 AM, Andre Przywara <os...@an...> wrote: > > When we copy the filesystem type name into the header, we must not > > access memory behind the trailing \0 byte, also the buffer should > > not be filled with random bytes (may leak information). strncpy is > > the perfect solution to this problem, so replace the usage of memcpy > > with this function. > > > > Signed-off-by: Andre Przywara <os...@an...> > > --- > > src/extfsclone.c | 4 ++-- > > src/fatclone.c | 4 ++-- > > src/hfsplusclone.c | 4 ++-- > > src/main.c | 4 ++-- > > src/ntfsclone-ng.c | 4 ++-- > > src/partclone.c | 4 ++-- > > src/reiser4clone.c | 4 ++-- > > src/reiserfsclone.c | 4 ++-- > > src/ufsclone.c | 4 ++-- > > src/vmfsclone.c | 4 ++-- > > src/xfsclone.c | 4 ++-- > > 11 files changed, 22 insertions(+), 22 deletions(-) > > > > diff --git a/src/extfsclone.c b/src/extfsclone.c > > index 39ba552..8db81ea 100644 > > --- a/src/extfsclone.c > > +++ b/src/extfsclone.c > > @@ -210,8 +210,8 @@ extern void initial_image_hdr(char* device, > > image_head* image_hdr) { > > int fs_type = 0; > > fs_type = test_extfs_type(device); > > - memcpy(image_hdr->magic, IMAGE_MAGIC, IMAGE_MAGIC_SIZE); > > - memcpy(image_hdr->fs, extfs_MAGIC, FS_MAGIC_SIZE); > > + strncpy(image_hdr->magic, IMAGE_MAGIC, IMAGE_MAGIC_SIZE); > > + strncpy(image_hdr->fs, extfs_MAGIC, FS_MAGIC_SIZE); > > fs_open(device); > > image_hdr->block_size = (int)block_size(); > > image_hdr->totalblock = (uint64_t)block_count(); > > diff --git a/src/fatclone.c b/src/fatclone.c > > index bbcad93..b763204 100644 > > --- a/src/fatclone.c > > +++ b/src/fatclone.c > > @@ -334,8 +334,8 @@ extern void initial_image_hdr(char* device, > > image_head* image_hdr) > > > > bused = get_used_block();//so I need calculate by myself. > > > > - memcpy(image_hdr->magic, IMAGE_MAGIC, IMAGE_MAGIC_SIZE); > > - memcpy(image_hdr->fs, fat_type, FS_MAGIC_SIZE); > > + strncpy(image_hdr->magic, IMAGE_MAGIC, IMAGE_MAGIC_SIZE); > > + strncpy(image_hdr->fs, fat_type, FS_MAGIC_SIZE); > > image_hdr->block_size = (int)fat_sb.sector_size; > > image_hdr->totalblock = (uint64_t)total_sector; > > image_hdr->device_size = (uint64_t)(total_sector * > > image_hdr->block_size); diff --git a/src/hfsplusclone.c > > b/src/hfsplusclone.c index 245b76d..8914e3b 100644 > > --- a/src/hfsplusclone.c > > +++ b/src/hfsplusclone.c > > @@ -199,8 +199,8 @@ extern void initial_image_hdr(char* device, > > image_head* image_hdr) { > > > > fs_open(device); > > - memcpy(image_hdr->magic, IMAGE_MAGIC, IMAGE_MAGIC_SIZE); > > - memcpy(image_hdr->fs, hfsplus_MAGIC, FS_MAGIC_SIZE); > > + strncpy(image_hdr->magic, IMAGE_MAGIC, IMAGE_MAGIC_SIZE); > > + strncpy(image_hdr->fs, hfsplus_MAGIC, FS_MAGIC_SIZE); > > image_hdr->block_size = (int)reverseInt(sb.blockSize); > > image_hdr->totalblock = (uint64_t)reverseInt(sb.totalBlocks); > > image_hdr->device_size = (uint64_t)(image_hdr->block_size * > > image_hdr->totalblock); diff --git a/src/main.c b/src/main.c > > index ffaf568..5f91b5c 100644 > > --- a/src/main.c > > +++ b/src/main.c > > @@ -207,7 +207,7 @@ int main(int argc, char **argv){ > > log_mesg(0, 1, 1, debug, "Ther is no enough free > > memory, partclone suggests you should have %i bytes memory\n", > > needed_mem); > > > > /// set partclone image version > > - memcpy(image_hdr.version, IMAGE_VERSION, VERSION_SIZE); > > + strncpy(image_hdr.version, IMAGE_VERSION, VERSION_SIZE); > > > > /// alloc a memory to restore bitmap > > bitmap = initial_bitmap(image_hdr.totalblock, &opt); > > @@ -279,7 +279,7 @@ int main(int argc, char **argv){ > > if (check_mem_size(image_hdr, opt, &needed_mem) == -1) > > log_mesg(0, 1, 1, debug, "Ther is no enough free > > memory, partclone suggests you should have %i bytes memory\n", > > needed_mem); > > > > - memcpy(image_hdr.version, IMAGE_VERSION, VERSION_SIZE); > > + strncpy(image_hdr.version, IMAGE_VERSION, VERSION_SIZE); > > > > /// alloc a memory to restore bitmap > > bitmap = initial_bitmap(image_hdr.totalblock, &opt); > > diff --git a/src/ntfsclone-ng.c b/src/ntfsclone-ng.c > > index 216d50a..2d887f6 100644 > > --- a/src/ntfsclone-ng.c > > +++ b/src/ntfsclone-ng.c > > @@ -279,8 +279,8 @@ extern void readbitmap(char* device, image_head > > image_hdr, char* bitmap, int pui extern void > > initial_image_hdr(char* device, image_head* image_hdr) { > > fs_open(device); > > - memcpy(image_hdr->magic, IMAGE_MAGIC, IMAGE_MAGIC_SIZE); > > - memcpy(image_hdr->fs, ntfs_MAGIC, FS_MAGIC_SIZE); > > + strncpy(image_hdr->magic, IMAGE_MAGIC, IMAGE_MAGIC_SIZE); > > + strncpy(image_hdr->fs, ntfs_MAGIC, FS_MAGIC_SIZE); > > image_hdr->block_size = (int)ntfs->cluster_size; > > image_hdr->totalblock = (uint64_t)ntfs->nr_clusters; > > image_hdr->usedblocks = (uint64_t)(ntfs->nr_clusters - > > ntfs->nr_free_clusters); diff --git a/src/partclone.c > > b/src/partclone.c index babc3a8..818e139 100644 > > --- a/src/partclone.c > > +++ b/src/partclone.c > > @@ -1061,8 +1061,8 @@ static uint64_t block_count(uint64_t > > partition_size, int block_size){ /// initial dd hdr > > extern void initial_dd_hdr(int ret, image_head* image_hdr){ > > > > - memset(image_hdr ,(int )NULL, sizeof(image_head)); > > - memcpy(image_hdr->fs, raw_MAGIC, FS_MAGIC_SIZE); > > + memset(image_hdr, 0, sizeof(image_head)); > > + strncpy(image_hdr->fs, raw_MAGIC, FS_MAGIC_SIZE); > > image_hdr->block_size = 512*2; > > image_hdr->device_size = get_partition_size(&ret); > > image_hdr->totalblock = block_count(image_hdr->device_size, > > image_hdr->block_size); diff --git a/src/reiser4clone.c > > b/src/reiser4clone.c index fc1dc95..f1d6cb2 100644 > > --- a/src/reiser4clone.c > > +++ b/src/reiser4clone.c > > @@ -147,8 +147,8 @@ extern void initial_image_hdr(char* device, > > image_head* image_hdr) fs_bitmap = > > reiser4_bitmap_create(reiser4_format_get_len(fs->format)); > > reiser4_alloc_extract(fs->alloc, fs_bitmap); free_blocks = > > reiser4_format_get_free(fs->format); > > - memcpy(image_hdr->magic, IMAGE_MAGIC, IMAGE_MAGIC_SIZE); > > - memcpy(image_hdr->fs, reiser4_MAGIC, FS_MAGIC_SIZE); > > + strncpy(image_hdr->magic, IMAGE_MAGIC, IMAGE_MAGIC_SIZE); > > + strncpy(image_hdr->fs, reiser4_MAGIC, FS_MAGIC_SIZE); > > image_hdr->block_size = (int)get_ms_blksize(SUPER(fs->master)); > > image_hdr->totalblock = > > (uint64_t)reiser4_format_get_len(fs->format); image_hdr->usedblocks > > = (uint64_t)(reiser4_format_get_len(fs->format) - free_blocks); > > diff --git a/src/reiserfsclone.c b/src/reiserfsclone.c index > > eb4272b..c888bac 100644 --- a/src/reiserfsclone.c > > +++ b/src/reiserfsclone.c > > @@ -116,8 +116,8 @@ extern void readbitmap(char* device, image_head > > image_hdr, char* bitmap, int pui extern void > > initial_image_hdr(char* device, image_head* image_hdr) { > > fs_open(device); > > - memcpy(image_hdr->magic, IMAGE_MAGIC, IMAGE_MAGIC_SIZE); > > - memcpy(image_hdr->fs, reiserfs_MAGIC, FS_MAGIC_SIZE); > > + strncpy(image_hdr->magic, IMAGE_MAGIC, IMAGE_MAGIC_SIZE); > > + strncpy(image_hdr->fs, reiserfs_MAGIC, FS_MAGIC_SIZE); > > image_hdr->block_size = (int)fs->super->s_v1.sb_block_size; > > image_hdr->totalblock = > > (uint64_t)fs->super->s_v1.sb_block_count; image_hdr->usedblocks = > > (uint64_t)(fs->super->s_v1.sb_block_count - > > fs->super->s_v1.sb_free_blocks); diff --git a/src/ufsclone.c > > b/src/ufsclone.c index 7d906df..c4c6375 100644 --- a/src/ufsclone.c > > +++ b/src/ufsclone.c > > @@ -155,8 +155,8 @@ extern void initial_image_hdr(char* device, > > image_head* image_hdr) { > > > > fs_open(device); > > - memcpy(image_hdr->magic, IMAGE_MAGIC, IMAGE_MAGIC_SIZE); > > - memcpy(image_hdr->fs, ufs_MAGIC, FS_MAGIC_SIZE); > > + strncpy(image_hdr->magic, IMAGE_MAGIC, IMAGE_MAGIC_SIZE); > > + strncpy(image_hdr->fs, ufs_MAGIC, FS_MAGIC_SIZE); > > > > image_hdr->block_size = afs.fs_fsize; > > image_hdr->usedblocks = get_used_block(); > > diff --git a/src/vmfsclone.c b/src/vmfsclone.c > > index ada9bb8..f03362c 100644 > > --- a/src/vmfsclone.c > > +++ b/src/vmfsclone.c > > @@ -110,8 +110,8 @@ extern void initial_image_hdr(char* device, > > image_head* image_hdr) uint32_t alloc,total; > > > > fs_open(device); > > - memcpy(image_hdr->magic, IMAGE_MAGIC, IMAGE_MAGIC_SIZE); > > - memcpy(image_hdr->fs, vmfs_MAGIC, FS_MAGIC_SIZE); > > + strncpy(image_hdr->magic, IMAGE_MAGIC, IMAGE_MAGIC_SIZE); > > + strncpy(image_hdr->fs, vmfs_MAGIC, FS_MAGIC_SIZE); > > > > total = fs->fbb->bmh.total_items; > > alloc = vmfs_bitmap_allocated_items(fs->fbb); > > diff --git a/src/xfsclone.c b/src/xfsclone.c > > index 1ae3799..f368996 100644 > > --- a/src/xfsclone.c > > +++ b/src/xfsclone.c > > @@ -172,8 +172,8 @@ static void fs_close() > > extern void initial_image_hdr(char* device, image_head* image_hdr) > > { > > fs_open(device); > > - memcpy(image_hdr->magic, IMAGE_MAGIC, IMAGE_MAGIC_SIZE); > > - memcpy(image_hdr->fs, xfs_MAGIC, FS_MAGIC_SIZE); > > + strncpy(image_hdr->magic, IMAGE_MAGIC, IMAGE_MAGIC_SIZE); > > + strncpy(image_hdr->fs, xfs_MAGIC, FS_MAGIC_SIZE); > > image_hdr->block_size = mp->m_sb.sb_blocksize; > > image_hdr->totalblock = mp->m_sb.sb_dblocks; > > image_hdr->usedblocks = mp->m_sb.sb_dblocks - > > mp->m_sb.sb_fdblocks; -- > > 1.6.1.3 > > > > > > ------------------------------------------------------------------------------ > > _______________________________________________ > > Partclone-user mailing list > > Par...@li... > > https://lists.sourceforge.net/lists/listinfo/partclone-user > > |
From: Jazz Yao-T. W. <jaz...@gm...> - 2010-05-04 14:41:20
|
Hi Andre, Thanks for your contribution. After discussed with thomas, we might not able to apply your patch. 1. for the partclone image backward compatibility 2. we use memset to set zero into array, so it will not be filled with random bytes. Please feel free to give us more advice if there are any security issue. - Jazz Yao-Tsung Wang On Tue, May 4, 2010 at 6:00 AM, Andre Przywara <os...@an...> wrote: > When we copy the filesystem type name into the header, we must not > access memory behind the trailing \0 byte, also the buffer should > not be filled with random bytes (may leak information). strncpy is > the perfect solution to this problem, so replace the usage of memcpy > with this function. > > Signed-off-by: Andre Przywara <os...@an...> > --- > src/extfsclone.c | 4 ++-- > src/fatclone.c | 4 ++-- > src/hfsplusclone.c | 4 ++-- > src/main.c | 4 ++-- > src/ntfsclone-ng.c | 4 ++-- > src/partclone.c | 4 ++-- > src/reiser4clone.c | 4 ++-- > src/reiserfsclone.c | 4 ++-- > src/ufsclone.c | 4 ++-- > src/vmfsclone.c | 4 ++-- > src/xfsclone.c | 4 ++-- > 11 files changed, 22 insertions(+), 22 deletions(-) > > diff --git a/src/extfsclone.c b/src/extfsclone.c > index 39ba552..8db81ea 100644 > --- a/src/extfsclone.c > +++ b/src/extfsclone.c > @@ -210,8 +210,8 @@ extern void initial_image_hdr(char* device, image_head* image_hdr) > { > int fs_type = 0; > fs_type = test_extfs_type(device); > - memcpy(image_hdr->magic, IMAGE_MAGIC, IMAGE_MAGIC_SIZE); > - memcpy(image_hdr->fs, extfs_MAGIC, FS_MAGIC_SIZE); > + strncpy(image_hdr->magic, IMAGE_MAGIC, IMAGE_MAGIC_SIZE); > + strncpy(image_hdr->fs, extfs_MAGIC, FS_MAGIC_SIZE); > fs_open(device); > image_hdr->block_size = (int)block_size(); > image_hdr->totalblock = (uint64_t)block_count(); > diff --git a/src/fatclone.c b/src/fatclone.c > index bbcad93..b763204 100644 > --- a/src/fatclone.c > +++ b/src/fatclone.c > @@ -334,8 +334,8 @@ extern void initial_image_hdr(char* device, image_head* image_hdr) > > bused = get_used_block();//so I need calculate by myself. > > - memcpy(image_hdr->magic, IMAGE_MAGIC, IMAGE_MAGIC_SIZE); > - memcpy(image_hdr->fs, fat_type, FS_MAGIC_SIZE); > + strncpy(image_hdr->magic, IMAGE_MAGIC, IMAGE_MAGIC_SIZE); > + strncpy(image_hdr->fs, fat_type, FS_MAGIC_SIZE); > image_hdr->block_size = (int)fat_sb.sector_size; > image_hdr->totalblock = (uint64_t)total_sector; > image_hdr->device_size = (uint64_t)(total_sector * image_hdr->block_size); > diff --git a/src/hfsplusclone.c b/src/hfsplusclone.c > index 245b76d..8914e3b 100644 > --- a/src/hfsplusclone.c > +++ b/src/hfsplusclone.c > @@ -199,8 +199,8 @@ extern void initial_image_hdr(char* device, image_head* image_hdr) > { > > fs_open(device); > - memcpy(image_hdr->magic, IMAGE_MAGIC, IMAGE_MAGIC_SIZE); > - memcpy(image_hdr->fs, hfsplus_MAGIC, FS_MAGIC_SIZE); > + strncpy(image_hdr->magic, IMAGE_MAGIC, IMAGE_MAGIC_SIZE); > + strncpy(image_hdr->fs, hfsplus_MAGIC, FS_MAGIC_SIZE); > image_hdr->block_size = (int)reverseInt(sb.blockSize); > image_hdr->totalblock = (uint64_t)reverseInt(sb.totalBlocks); > image_hdr->device_size = (uint64_t)(image_hdr->block_size * image_hdr->totalblock); > diff --git a/src/main.c b/src/main.c > index ffaf568..5f91b5c 100644 > --- a/src/main.c > +++ b/src/main.c > @@ -207,7 +207,7 @@ int main(int argc, char **argv){ > log_mesg(0, 1, 1, debug, "Ther is no enough free memory, partclone suggests you should have %i bytes memory\n", needed_mem); > > /// set partclone image version > - memcpy(image_hdr.version, IMAGE_VERSION, VERSION_SIZE); > + strncpy(image_hdr.version, IMAGE_VERSION, VERSION_SIZE); > > /// alloc a memory to restore bitmap > bitmap = initial_bitmap(image_hdr.totalblock, &opt); > @@ -279,7 +279,7 @@ int main(int argc, char **argv){ > if (check_mem_size(image_hdr, opt, &needed_mem) == -1) > log_mesg(0, 1, 1, debug, "Ther is no enough free memory, partclone suggests you should have %i bytes memory\n", needed_mem); > > - memcpy(image_hdr.version, IMAGE_VERSION, VERSION_SIZE); > + strncpy(image_hdr.version, IMAGE_VERSION, VERSION_SIZE); > > /// alloc a memory to restore bitmap > bitmap = initial_bitmap(image_hdr.totalblock, &opt); > diff --git a/src/ntfsclone-ng.c b/src/ntfsclone-ng.c > index 216d50a..2d887f6 100644 > --- a/src/ntfsclone-ng.c > +++ b/src/ntfsclone-ng.c > @@ -279,8 +279,8 @@ extern void readbitmap(char* device, image_head image_hdr, char* bitmap, int pui > extern void initial_image_hdr(char* device, image_head* image_hdr) > { > fs_open(device); > - memcpy(image_hdr->magic, IMAGE_MAGIC, IMAGE_MAGIC_SIZE); > - memcpy(image_hdr->fs, ntfs_MAGIC, FS_MAGIC_SIZE); > + strncpy(image_hdr->magic, IMAGE_MAGIC, IMAGE_MAGIC_SIZE); > + strncpy(image_hdr->fs, ntfs_MAGIC, FS_MAGIC_SIZE); > image_hdr->block_size = (int)ntfs->cluster_size; > image_hdr->totalblock = (uint64_t)ntfs->nr_clusters; > image_hdr->usedblocks = (uint64_t)(ntfs->nr_clusters - ntfs->nr_free_clusters); > diff --git a/src/partclone.c b/src/partclone.c > index babc3a8..818e139 100644 > --- a/src/partclone.c > +++ b/src/partclone.c > @@ -1061,8 +1061,8 @@ static uint64_t block_count(uint64_t partition_size, int block_size){ > /// initial dd hdr > extern void initial_dd_hdr(int ret, image_head* image_hdr){ > > - memset(image_hdr ,(int )NULL, sizeof(image_head)); > - memcpy(image_hdr->fs, raw_MAGIC, FS_MAGIC_SIZE); > + memset(image_hdr, 0, sizeof(image_head)); > + strncpy(image_hdr->fs, raw_MAGIC, FS_MAGIC_SIZE); > image_hdr->block_size = 512*2; > image_hdr->device_size = get_partition_size(&ret); > image_hdr->totalblock = block_count(image_hdr->device_size, image_hdr->block_size); > diff --git a/src/reiser4clone.c b/src/reiser4clone.c > index fc1dc95..f1d6cb2 100644 > --- a/src/reiser4clone.c > +++ b/src/reiser4clone.c > @@ -147,8 +147,8 @@ extern void initial_image_hdr(char* device, image_head* image_hdr) > fs_bitmap = reiser4_bitmap_create(reiser4_format_get_len(fs->format)); > reiser4_alloc_extract(fs->alloc, fs_bitmap); > free_blocks = reiser4_format_get_free(fs->format); > - memcpy(image_hdr->magic, IMAGE_MAGIC, IMAGE_MAGIC_SIZE); > - memcpy(image_hdr->fs, reiser4_MAGIC, FS_MAGIC_SIZE); > + strncpy(image_hdr->magic, IMAGE_MAGIC, IMAGE_MAGIC_SIZE); > + strncpy(image_hdr->fs, reiser4_MAGIC, FS_MAGIC_SIZE); > image_hdr->block_size = (int)get_ms_blksize(SUPER(fs->master)); > image_hdr->totalblock = (uint64_t)reiser4_format_get_len(fs->format); > image_hdr->usedblocks = (uint64_t)(reiser4_format_get_len(fs->format) - free_blocks); > diff --git a/src/reiserfsclone.c b/src/reiserfsclone.c > index eb4272b..c888bac 100644 > --- a/src/reiserfsclone.c > +++ b/src/reiserfsclone.c > @@ -116,8 +116,8 @@ extern void readbitmap(char* device, image_head image_hdr, char* bitmap, int pui > extern void initial_image_hdr(char* device, image_head* image_hdr) > { > fs_open(device); > - memcpy(image_hdr->magic, IMAGE_MAGIC, IMAGE_MAGIC_SIZE); > - memcpy(image_hdr->fs, reiserfs_MAGIC, FS_MAGIC_SIZE); > + strncpy(image_hdr->magic, IMAGE_MAGIC, IMAGE_MAGIC_SIZE); > + strncpy(image_hdr->fs, reiserfs_MAGIC, FS_MAGIC_SIZE); > image_hdr->block_size = (int)fs->super->s_v1.sb_block_size; > image_hdr->totalblock = (uint64_t)fs->super->s_v1.sb_block_count; > image_hdr->usedblocks = (uint64_t)(fs->super->s_v1.sb_block_count - fs->super->s_v1.sb_free_blocks); > diff --git a/src/ufsclone.c b/src/ufsclone.c > index 7d906df..c4c6375 100644 > --- a/src/ufsclone.c > +++ b/src/ufsclone.c > @@ -155,8 +155,8 @@ extern void initial_image_hdr(char* device, image_head* image_hdr) > { > > fs_open(device); > - memcpy(image_hdr->magic, IMAGE_MAGIC, IMAGE_MAGIC_SIZE); > - memcpy(image_hdr->fs, ufs_MAGIC, FS_MAGIC_SIZE); > + strncpy(image_hdr->magic, IMAGE_MAGIC, IMAGE_MAGIC_SIZE); > + strncpy(image_hdr->fs, ufs_MAGIC, FS_MAGIC_SIZE); > > image_hdr->block_size = afs.fs_fsize; > image_hdr->usedblocks = get_used_block(); > diff --git a/src/vmfsclone.c b/src/vmfsclone.c > index ada9bb8..f03362c 100644 > --- a/src/vmfsclone.c > +++ b/src/vmfsclone.c > @@ -110,8 +110,8 @@ extern void initial_image_hdr(char* device, image_head* image_hdr) > uint32_t alloc,total; > > fs_open(device); > - memcpy(image_hdr->magic, IMAGE_MAGIC, IMAGE_MAGIC_SIZE); > - memcpy(image_hdr->fs, vmfs_MAGIC, FS_MAGIC_SIZE); > + strncpy(image_hdr->magic, IMAGE_MAGIC, IMAGE_MAGIC_SIZE); > + strncpy(image_hdr->fs, vmfs_MAGIC, FS_MAGIC_SIZE); > > total = fs->fbb->bmh.total_items; > alloc = vmfs_bitmap_allocated_items(fs->fbb); > diff --git a/src/xfsclone.c b/src/xfsclone.c > index 1ae3799..f368996 100644 > --- a/src/xfsclone.c > +++ b/src/xfsclone.c > @@ -172,8 +172,8 @@ static void fs_close() > extern void initial_image_hdr(char* device, image_head* image_hdr) > { > fs_open(device); > - memcpy(image_hdr->magic, IMAGE_MAGIC, IMAGE_MAGIC_SIZE); > - memcpy(image_hdr->fs, xfs_MAGIC, FS_MAGIC_SIZE); > + strncpy(image_hdr->magic, IMAGE_MAGIC, IMAGE_MAGIC_SIZE); > + strncpy(image_hdr->fs, xfs_MAGIC, FS_MAGIC_SIZE); > image_hdr->block_size = mp->m_sb.sb_blocksize; > image_hdr->totalblock = mp->m_sb.sb_dblocks; > image_hdr->usedblocks = mp->m_sb.sb_dblocks - mp->m_sb.sb_fdblocks; > -- > 1.6.1.3 > > > ------------------------------------------------------------------------------ > _______________________________________________ > Partclone-user mailing list > Par...@li... > https://lists.sourceforge.net/lists/listinfo/partclone-user > |
From: Andre P. <os...@an...> - 2010-05-03 22:25:54
|
When we copy the filesystem type name into the header, we must not access memory behind the trailing \0 byte, also the buffer should not be filled with random bytes (may leak information). strncpy is the perfect solution to this problem, so replace the usage of memcpy with this function. Signed-off-by: Andre Przywara <os...@an...> --- src/extfsclone.c | 4 ++-- src/fatclone.c | 4 ++-- src/hfsplusclone.c | 4 ++-- src/main.c | 4 ++-- src/ntfsclone-ng.c | 4 ++-- src/partclone.c | 4 ++-- src/reiser4clone.c | 4 ++-- src/reiserfsclone.c | 4 ++-- src/ufsclone.c | 4 ++-- src/vmfsclone.c | 4 ++-- src/xfsclone.c | 4 ++-- 11 files changed, 22 insertions(+), 22 deletions(-) diff --git a/src/extfsclone.c b/src/extfsclone.c index 39ba552..8db81ea 100644 --- a/src/extfsclone.c +++ b/src/extfsclone.c @@ -210,8 +210,8 @@ extern void initial_image_hdr(char* device, image_head* image_hdr) { int fs_type = 0; fs_type = test_extfs_type(device); - memcpy(image_hdr->magic, IMAGE_MAGIC, IMAGE_MAGIC_SIZE); - memcpy(image_hdr->fs, extfs_MAGIC, FS_MAGIC_SIZE); + strncpy(image_hdr->magic, IMAGE_MAGIC, IMAGE_MAGIC_SIZE); + strncpy(image_hdr->fs, extfs_MAGIC, FS_MAGIC_SIZE); fs_open(device); image_hdr->block_size = (int)block_size(); image_hdr->totalblock = (uint64_t)block_count(); diff --git a/src/fatclone.c b/src/fatclone.c index bbcad93..b763204 100644 --- a/src/fatclone.c +++ b/src/fatclone.c @@ -334,8 +334,8 @@ extern void initial_image_hdr(char* device, image_head* image_hdr) bused = get_used_block();//so I need calculate by myself. - memcpy(image_hdr->magic, IMAGE_MAGIC, IMAGE_MAGIC_SIZE); - memcpy(image_hdr->fs, fat_type, FS_MAGIC_SIZE); + strncpy(image_hdr->magic, IMAGE_MAGIC, IMAGE_MAGIC_SIZE); + strncpy(image_hdr->fs, fat_type, FS_MAGIC_SIZE); image_hdr->block_size = (int)fat_sb.sector_size; image_hdr->totalblock = (uint64_t)total_sector; image_hdr->device_size = (uint64_t)(total_sector * image_hdr->block_size); diff --git a/src/hfsplusclone.c b/src/hfsplusclone.c index 245b76d..8914e3b 100644 --- a/src/hfsplusclone.c +++ b/src/hfsplusclone.c @@ -199,8 +199,8 @@ extern void initial_image_hdr(char* device, image_head* image_hdr) { fs_open(device); - memcpy(image_hdr->magic, IMAGE_MAGIC, IMAGE_MAGIC_SIZE); - memcpy(image_hdr->fs, hfsplus_MAGIC, FS_MAGIC_SIZE); + strncpy(image_hdr->magic, IMAGE_MAGIC, IMAGE_MAGIC_SIZE); + strncpy(image_hdr->fs, hfsplus_MAGIC, FS_MAGIC_SIZE); image_hdr->block_size = (int)reverseInt(sb.blockSize); image_hdr->totalblock = (uint64_t)reverseInt(sb.totalBlocks); image_hdr->device_size = (uint64_t)(image_hdr->block_size * image_hdr->totalblock); diff --git a/src/main.c b/src/main.c index ffaf568..5f91b5c 100644 --- a/src/main.c +++ b/src/main.c @@ -207,7 +207,7 @@ int main(int argc, char **argv){ log_mesg(0, 1, 1, debug, "Ther is no enough free memory, partclone suggests you should have %i bytes memory\n", needed_mem); /// set partclone image version - memcpy(image_hdr.version, IMAGE_VERSION, VERSION_SIZE); + strncpy(image_hdr.version, IMAGE_VERSION, VERSION_SIZE); /// alloc a memory to restore bitmap bitmap = initial_bitmap(image_hdr.totalblock, &opt); @@ -279,7 +279,7 @@ int main(int argc, char **argv){ if (check_mem_size(image_hdr, opt, &needed_mem) == -1) log_mesg(0, 1, 1, debug, "Ther is no enough free memory, partclone suggests you should have %i bytes memory\n", needed_mem); - memcpy(image_hdr.version, IMAGE_VERSION, VERSION_SIZE); + strncpy(image_hdr.version, IMAGE_VERSION, VERSION_SIZE); /// alloc a memory to restore bitmap bitmap = initial_bitmap(image_hdr.totalblock, &opt); diff --git a/src/ntfsclone-ng.c b/src/ntfsclone-ng.c index 216d50a..2d887f6 100644 --- a/src/ntfsclone-ng.c +++ b/src/ntfsclone-ng.c @@ -279,8 +279,8 @@ extern void readbitmap(char* device, image_head image_hdr, char* bitmap, int pui extern void initial_image_hdr(char* device, image_head* image_hdr) { fs_open(device); - memcpy(image_hdr->magic, IMAGE_MAGIC, IMAGE_MAGIC_SIZE); - memcpy(image_hdr->fs, ntfs_MAGIC, FS_MAGIC_SIZE); + strncpy(image_hdr->magic, IMAGE_MAGIC, IMAGE_MAGIC_SIZE); + strncpy(image_hdr->fs, ntfs_MAGIC, FS_MAGIC_SIZE); image_hdr->block_size = (int)ntfs->cluster_size; image_hdr->totalblock = (uint64_t)ntfs->nr_clusters; image_hdr->usedblocks = (uint64_t)(ntfs->nr_clusters - ntfs->nr_free_clusters); diff --git a/src/partclone.c b/src/partclone.c index babc3a8..818e139 100644 --- a/src/partclone.c +++ b/src/partclone.c @@ -1061,8 +1061,8 @@ static uint64_t block_count(uint64_t partition_size, int block_size){ /// initial dd hdr extern void initial_dd_hdr(int ret, image_head* image_hdr){ - memset(image_hdr ,(int )NULL, sizeof(image_head)); - memcpy(image_hdr->fs, raw_MAGIC, FS_MAGIC_SIZE); + memset(image_hdr, 0, sizeof(image_head)); + strncpy(image_hdr->fs, raw_MAGIC, FS_MAGIC_SIZE); image_hdr->block_size = 512*2; image_hdr->device_size = get_partition_size(&ret); image_hdr->totalblock = block_count(image_hdr->device_size, image_hdr->block_size); diff --git a/src/reiser4clone.c b/src/reiser4clone.c index fc1dc95..f1d6cb2 100644 --- a/src/reiser4clone.c +++ b/src/reiser4clone.c @@ -147,8 +147,8 @@ extern void initial_image_hdr(char* device, image_head* image_hdr) fs_bitmap = reiser4_bitmap_create(reiser4_format_get_len(fs->format)); reiser4_alloc_extract(fs->alloc, fs_bitmap); free_blocks = reiser4_format_get_free(fs->format); - memcpy(image_hdr->magic, IMAGE_MAGIC, IMAGE_MAGIC_SIZE); - memcpy(image_hdr->fs, reiser4_MAGIC, FS_MAGIC_SIZE); + strncpy(image_hdr->magic, IMAGE_MAGIC, IMAGE_MAGIC_SIZE); + strncpy(image_hdr->fs, reiser4_MAGIC, FS_MAGIC_SIZE); image_hdr->block_size = (int)get_ms_blksize(SUPER(fs->master)); image_hdr->totalblock = (uint64_t)reiser4_format_get_len(fs->format); image_hdr->usedblocks = (uint64_t)(reiser4_format_get_len(fs->format) - free_blocks); diff --git a/src/reiserfsclone.c b/src/reiserfsclone.c index eb4272b..c888bac 100644 --- a/src/reiserfsclone.c +++ b/src/reiserfsclone.c @@ -116,8 +116,8 @@ extern void readbitmap(char* device, image_head image_hdr, char* bitmap, int pui extern void initial_image_hdr(char* device, image_head* image_hdr) { fs_open(device); - memcpy(image_hdr->magic, IMAGE_MAGIC, IMAGE_MAGIC_SIZE); - memcpy(image_hdr->fs, reiserfs_MAGIC, FS_MAGIC_SIZE); + strncpy(image_hdr->magic, IMAGE_MAGIC, IMAGE_MAGIC_SIZE); + strncpy(image_hdr->fs, reiserfs_MAGIC, FS_MAGIC_SIZE); image_hdr->block_size = (int)fs->super->s_v1.sb_block_size; image_hdr->totalblock = (uint64_t)fs->super->s_v1.sb_block_count; image_hdr->usedblocks = (uint64_t)(fs->super->s_v1.sb_block_count - fs->super->s_v1.sb_free_blocks); diff --git a/src/ufsclone.c b/src/ufsclone.c index 7d906df..c4c6375 100644 --- a/src/ufsclone.c +++ b/src/ufsclone.c @@ -155,8 +155,8 @@ extern void initial_image_hdr(char* device, image_head* image_hdr) { fs_open(device); - memcpy(image_hdr->magic, IMAGE_MAGIC, IMAGE_MAGIC_SIZE); - memcpy(image_hdr->fs, ufs_MAGIC, FS_MAGIC_SIZE); + strncpy(image_hdr->magic, IMAGE_MAGIC, IMAGE_MAGIC_SIZE); + strncpy(image_hdr->fs, ufs_MAGIC, FS_MAGIC_SIZE); image_hdr->block_size = afs.fs_fsize; image_hdr->usedblocks = get_used_block(); diff --git a/src/vmfsclone.c b/src/vmfsclone.c index ada9bb8..f03362c 100644 --- a/src/vmfsclone.c +++ b/src/vmfsclone.c @@ -110,8 +110,8 @@ extern void initial_image_hdr(char* device, image_head* image_hdr) uint32_t alloc,total; fs_open(device); - memcpy(image_hdr->magic, IMAGE_MAGIC, IMAGE_MAGIC_SIZE); - memcpy(image_hdr->fs, vmfs_MAGIC, FS_MAGIC_SIZE); + strncpy(image_hdr->magic, IMAGE_MAGIC, IMAGE_MAGIC_SIZE); + strncpy(image_hdr->fs, vmfs_MAGIC, FS_MAGIC_SIZE); total = fs->fbb->bmh.total_items; alloc = vmfs_bitmap_allocated_items(fs->fbb); diff --git a/src/xfsclone.c b/src/xfsclone.c index 1ae3799..f368996 100644 --- a/src/xfsclone.c +++ b/src/xfsclone.c @@ -172,8 +172,8 @@ static void fs_close() extern void initial_image_hdr(char* device, image_head* image_hdr) { fs_open(device); - memcpy(image_hdr->magic, IMAGE_MAGIC, IMAGE_MAGIC_SIZE); - memcpy(image_hdr->fs, xfs_MAGIC, FS_MAGIC_SIZE); + strncpy(image_hdr->magic, IMAGE_MAGIC, IMAGE_MAGIC_SIZE); + strncpy(image_hdr->fs, xfs_MAGIC, FS_MAGIC_SIZE); image_hdr->block_size = mp->m_sb.sb_blocksize; image_hdr->totalblock = mp->m_sb.sb_dblocks; image_hdr->usedblocks = mp->m_sb.sb_dblocks - mp->m_sb.sb_fdblocks; -- 1.6.1.3 |