Thread: A bit offtopic: slack space sanitizers, byte blocks

  1. #1
    Registered User
    Join Date
    Nov 2015
    Posts
    54

    A bit offtopic: slack space sanitizers, byte blocks

    Hi!

    Please, help me to understand the following (my question is after
    the quotation; I am new to all this, and will be grateful for the help):

    Slack space sanitizers sanitize disk blocks (and portions of
    disk blocks) that are not part of any file and do not contain
    valid file system meta-information. For example, if a 512-
    byte block holds a file’s last 100 bytes and nothing else, a
    slack-space sanitizer reads the block, leaves bytes 1–100 untouched,
    and zeros bytes 101–512.
    I am not sure I understand the numbers:
    if a 512- byte block holds a file’s last 100 bytes
    does it mean that there was some file of some size, and only
    its last 100 bytes still exist (say, the file had 300 bytes, so the only
    ones seen now are from 200 byte to 300 byte, i.e. last 100 bytes),

    and these 100 bytes now occupy 1 - 100 of 512 byte block?

    If so, why sanitizer doesn't zero these 1-100 bytes; aren't these
    considered as important ones that hold the information?

    Thank you!

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    *Moved to Tech Board*

    Quote Originally Posted by Ducol
    If so, why sanitizer doesn't zero these 1-100 bytes; aren't these
    considered as important ones that hold the information?
    Presumably they are still in use, and so they will be overwritten later. The point is to overwrite currently unused storage that may have been used to store important data earlier, but now is slacking away with the data still stored.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #3
    Registered User
    Join Date
    Nov 2015
    Posts
    54
    Thank you )

  4. #4
    Ticked and off
    Join Date
    Oct 2011
    Location
    La-la land
    Posts
    1,728
    Ducol, files are allocated in blocks. If you have a very small file, say containing just text "Hello, world!", it would still occupy a full block in storage. If the file is larger than one block, only the last one may be partially used. Block size of 512 bytes is probably the most common nowadays, but it does vary a lot.

    Some filesystems do use tail packing, where such partially used "blocks", containing the "tails" of files, are combined.

    Slack space sanitizers simply seek to find partially used blocks, and write zeroes to the unused parts, without modifying the actual information stored. That's what their name comes from: "slack space", because it is not used to store any useful information right now, and "sanitizer", because the intent is to clear it to zeros (just in case it at some point in the past contained some information).

  5. #5
    Registered User
    Join Date
    Nov 2015
    Posts
    54
    Quote Originally Posted by Nominal Animal View Post
    Ducol, files are allocated in blocks. If you have a very small file, say containing just text "Hello, world!", it would still occupy a full block in storage. If the file is larger than one block, only the last one may be partially used. Block size of 512 bytes is probably the most common nowadays, but it does vary a lot.

    Some filesystems do use tail packing, where such partially used "blocks", containing the "tails" of files, are combined.

    Slack space sanitizers simply seek to find partially used blocks, and write zeroes to the unused parts, without modifying the actual information stored. That's what their name comes from: "slack space", because it is not used to store any useful information right now, and "sanitizer", because the intent is to clear it to zeros (just in case it at some point in the past contained some information).
    Thank you very much for this explanation! Now I understand it.

  6. #6
    Registered User
    Join Date
    Nov 2015
    Posts
    54
    Quote Originally Posted by Nominal Animal View Post
    Ducol, files are allocated in blocks. If you have a very small file, say containing just text "Hello, world!", it would still occupy a full block in storage. If the file is larger than one block, only the last one may be partially used. Block size of 512 bytes is probably the most common nowadays, but it does vary a lot.

    Some filesystems do use tail packing, where such partially used "blocks", containing the "tails" of files, are combined.

    Slack space sanitizers simply seek to find partially used blocks, and write zeroes to the unused parts, without modifying the actual information stored. That's what their name comes from: "slack space", because it is not used to store any useful information right now, and "sanitizer", because the intent is to clear it to zeros (just in case it at some point in the past contained some information).
    Just one more question, if I may. Based on your last paragraph, I am confused on how sanitizers work:
    if they overwrite with zeros only unused parts of blocks, and leave the original file information untouched, then how does that
    "cleans" the disk and "erases" (overwrites, thus hides) the information? It seems that it is still there. Thank you!

  7. #7
    Ticked and off
    Join Date
    Oct 2011
    Location
    La-la land
    Posts
    1,728
    Quote Originally Posted by Ducol View Post
    I am confused on how sanitizers work:
    if they overwrite with zeros only unused parts of blocks, and leave the original file information untouched, then how does that
    "cleans" the disk and "erases" (overwrites, thus hides) the information?
    It does not. Slack space sanitizers scrub only the unused parts of the disk, so that any deleted information is really gone.

    For example, when you edit a file, most programs actually write the data to a new file, then rename it over the old file; they do not overwrite the blocks containing the data for the old file. This means that wheneve you modify a file, there's most likely a "ghost" of the data left on the disk, in the unused blocks.

    To erase all information on the disk, you do a security wipe: just overwrite the drive with random data over and over. (Overwriting with zeroes usually leaves a slight residual magnetization on typical hard drives, which is technically recoverable. It's really expensive, though.)

  8. #8
    Registered User
    Join Date
    Nov 2015
    Posts
    54
    Quote Originally Posted by Nominal Animal View Post
    It does not. Slack space sanitizers scrub only the unused parts of the disk, so that any deleted information is really gone.

    For example, when you edit a file, most programs actually write the data to a new file, then rename it over the old file; they do not overwrite the blocks containing the data for the old file. This means that wheneve you modify a file, there's most likely a "ghost" of the data left on the disk, in the unused blocks.

    To erase all information on the disk, you do a security wipe: just overwrite the drive with random data over and over. (Overwriting with zeroes usually leaves a slight residual magnetization on typical hard drives, which is technically recoverable. It's really expensive, though.)
    Thank you very much!

  9. #9
    Registered User
    Join Date
    Oct 2006
    Posts
    3,445
    Quote Originally Posted by Ducol View Post
    Just one more question, if I may. Based on your last paragraph, I am confused on how sanitizers work:
    if they overwrite with zeros only unused parts of blocks, and leave the original file information untouched, then how does that
    "cleans" the disk and "erases" (overwrites, thus hides) the information? It seems that it is still there. Thank you!
    I think you're slightly misunderstanding the concept. In your example, we're talking about the last 100 bytes of a file that still exists. Not one that has been deleted. We absolutely don't want to wipe the contents of a file that still exists, because we would lose data that we want to keep. We want to wipe the unused space in the block after the end of the allocated portion, in case another file previously occupied that block, and left behind some data when it was deleted.

    An example:

    Let's say we have a text file called file.txt, which is 612 bytes long, and our blocks are 512 bytes wide. We can't store the whole file in one block, so we store the first 512 bytes in one block, and the last 100 bytes in a second block. The remaining 412 bytes of that second block are called "slack space," and are not used by any other file. The job of the slack space sanitizer is to wipe the 412 bytes in the second block, which are not occupied by file.txt data.
    What can this strange device be?
    When I touch it, it gives forth a sound
    It's got wires that vibrate and give music
    What can this thing be that I found?

  10. #10
    Registered User
    Join Date
    Nov 2015
    Posts
    54
    Quote Originally Posted by Elkvis View Post
    I think you're slightly misunderstanding the concept. In your example, we're talking about the last 100 bytes of a file that still exists. Not one that has been deleted. We absolutely don't want to wipe the contents of a file that still exists, because we would lose data that we want to keep. We want to wipe the unused space in the block after the end of the allocated portion, in case another file previously occupied that block, and left behind some data when it was deleted.

    An example:

    Let's say we have a text file called file.txt, which is 612 bytes long, and our blocks are 512 bytes wide. We can't store the whole file in one block, so we store the first 512 bytes in one block, and the last 100 bytes in a second block. The remaining 412 bytes of that second block are called "slack space," and are not used by any other file. The job of the slack space sanitizer is to wipe the 412 bytes in the second block, which are not occupied by file.txt data.
    Thank you very much! Yes, I see my mistake )

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 5
    Last Post: 01-22-2016, 03:20 AM
  2. File Comparision byte by byte
    By anusha2489 in forum C Programming
    Replies: 12
    Last Post: 05-16-2011, 06:58 AM
  3. reading files byte by byte
    By cpsc in forum C++ Programming
    Replies: 12
    Last Post: 01-07-2011, 03:54 PM
  4. TIFF IFD byte by byte
    By ghostcoder in forum C++ Programming
    Replies: 4
    Last Post: 12-21-2010, 04:33 PM

Tags for this Thread