Friday, January 9, 2015

Why do we need an executable stack with nested functions in GCC

  • The stack needs to be writable because the trampoline code is written on the stack which needs to be executed (to jump to the nested function). 
A nested function has no linkage by itself. So the trampoline code actually ensures two things:
  1. The outer () functions stack frame is available in the nested function
  2. Jump and execute code from the nested function.
Some other notes:
  • Nested functions are not a part of ANSI C, however, they are part of Gnu C.
  • The only reason nested functions are possibly useful because they use common stack variables.

Wednesday, January 7, 2015

Apple IOS: How to backup health data to windows or MAC

Before starting you need to have email correctly configured on your phone.
  1. Start the health app
  2. Navigate through "Health Data (folder with heart on it)" -> "All" -> Share icon in top right corner (the square box with the arrow on it).
  3. When you do that you will be prompted for confirmation as below:
    Health app prompting for confirmation before backing up
  4. Check your email. You should have the exported data in XML format.
Making sense of the XML data:
I found a note on an apple forum that neatly summarizes how you can view this information:
1) Open a blank Excel Workbook.
2) For Excel 2007 or more recent, choose the Data tab on the top.
3) On the left side there is a 'Get External Data' block of choices, click the dropdown arrow on 'From Other Sources'.
4) Click on the third choice 'From XML Data Import'.
5) Find your downloaded XML file and click 'Open'.
6) Excel will likely display a message that the source does not refer to a schema. Choose 'OK'.
7) If you click 'OK' with the default choice 'XML table in existing worksheet', data will be displayed in Excel table format, which will let you sort and filter data. The other choices only displays the data in columns.

You will likely need to create an additional column for dates, as the 'startDate' and 'endDate' times are in a format that Excel won't recognize, if you need any date to your data anyway. If you need a conversion formula you can reply to this message stating as much. You probably already found that the export zip file shows detailed logs for every day on an hourly basis for the last week only, prior records at least in the export are summarized by day.

Known issues:
I do not have a solution for any of these and I ran into them when I was backing up from my phone. So if you find something please comment.
  • Health app crashes (on startup)
  • Health app crashes while creating a backup.
  • Export is unsuccessful with the following screen seen below (could not export health data):
    Health app fails saying could not export data

Tuesday, January 6, 2015

How to Apply a Patch to the Linux Kernel Stable Tree

A nice small tutorial of how patching is done to the linux kernel tree by the LinuxFoundation.


Monday, January 5, 2015

Why would you always choose ext3 over ext2 filesystem?

The answer in one word would be: JOURNALING.


ext2 does not support journaling while ext3 does. So does ext4 (if you are ok with an in-the-works kind of a filesystem).

What does journaling do?
Excerpt from the ubuntu help page:
A journaling file system is more reliable when it comes to data storage. Journaling file systems do not necessarily prevent corruption, but they do prevent inconsistency and are much faster at file system checks than non-journaled file systems. If a power failure happens while you are saving a file, the save will not complete and you end up with corrupted data and an inconsistent file system. Instead of actually writing directly to the part of the disk where the file is stored, a journaling file system first writes it to another part of the hard drive and notes the necessary changes to a log, then in the background it goes through each entry to the journal and begins to complete the task, and when the task is complete, it checks it off on the list. Thus the file system is always in a consistent state (the file got saved, the journal reports it as not completely saved, or the journal is inconsistent (but can be rebuilt from the file system)). Some journaling file systems can prevent corruption as well by writing data twice.
A more elaborate comparison of the filesystems from the same page is as below:

File System
Max File Size
Max Partition Size
Journaling
Notes
Fat16
2 GB
2 GB
No
Legacy
Fat32
4 GB
8 TB
No
Legacy
NTFS
2 TB
256 TB
Yes
(For Windows Compatibility) NTFS-3g is installed by default in Ubuntu, allowing Read/Write support
ext2
2 TB
32 TB
No
Legacy
ext3
2 TB
32 TB
Yes
Standard linux filesystem for many years. Best choice for super-standard installation.
ext4
16 TB
1 EB
Yes
Modern iteration of ext3. Best choice for new installations where super-standard isn't necessary.
reiserFS
8 TB
16 TB
Yes
No longer well-maintained.
JFS
4PB
32PB
Yes (metadata)
Created by IBM - Not well maintained.
XFS
8 EB
8 EB
Yes (metadata)
Created by SGI. Best choice for a mix of stability and advanced journaling.
GB = Gigabyte (1024 MB) :: TB = Terabyte (1024 GB) :: PB = Petabyte (1024 TB) :: EB = Exabyte (1024 PB)
Above you'll see a brief comparison of two main attributes of different filesystems, the max file size and the largest a partition of that data can be.
Of the above file systems the only one you cannot install Linux on is the NTFS. It is not recommended to install Linux on any type of FAT file system, because FAT does not have any of the permissions of a true Unix FS.