Forum Replies Created
-
AuthorPosts
-
Humble
KeymasterThis reply has been marked as private.Humble
KeymasterThis reply has been marked as private.Humble
KeymasterThis reply has been marked as private.Humble
KeymasterThis reply has been marked as private.Humble
KeymasterThis reply has been marked as private.Humble
KeymasterThis reply has been marked as private.Humble
KeymasterThis reply has been marked as private.Humble
KeymasterThis reply has been marked as private.Humble
KeymasterThis reply has been marked as private.Humble
KeymasterThis reply has been marked as private.Humble
KeymasterThis reply has been marked as private.Humble
KeymasterThis reply has been marked as private.Humble
KeymasterThis reply has been marked as private.Humble
KeymasterThis reply has been marked as private.Humble
KeymasterThis reply has been marked as private.Humble
KeymasterThis reply has been marked as private.Humble
KeymasterThis reply has been marked as private.Humble
KeymasterThis reply has been marked as private.Humble
KeymasterThis reply has been marked as private.Humble
KeymasterThis reply has been marked as private.Humble
KeymasterThis reply has been marked as private.Humble
KeymasterThis reply has been marked as private.Humble
KeymasterThis reply has been marked as private.Humble
KeymasterThis reply has been marked as private.Humble
KeymasterThis reply has been marked as private.Humble
KeymasterThis reply has been marked as private.Humble
KeymasterThis reply has been marked as private.Humble
KeymasterIf you want to stash the untracked files try
git stash -uHumble
Keymaster#include
int main()
{
int *p = NULL;if (p == NULL)
{
printf (“p is NULL\n”);
}
else
{
printf (“p is not NULL\n”);}
}Above produce below result :
[hchiramm@humbles-lap ]$ ./a.out
p is NULLBut, if we have below code :
#include
int main()
{
int *p = NULL;
if (p)
{
printf (“p is NULL\n”);
}
else
{
printf (“p is not NULL\n”);}
}[hchiramm@humbles-lap ]$ ./a.out
p is not NULLBecause NULL is represented as binary zero in a system, that said, binary zero is treated as “false” in C, so else clause is getting executed..
In standard libike this:
#define NULL ((void*)0)
Dereferencing a NULL pointer will result in ‘segmentation fault” .
Humble
KeymasterThis reply has been marked as private.March 31, 2014 at 7:10 am in reply to: Basic data types ( char, int, float..etc) and qualifiers ( short, long..etc) #2594Humble
KeymasterSee this post as well ..
https://humblec.com/forums/topic/negative-numbers-2s-complement/
February 23, 2014 at 6:42 pm in reply to: getline() is preferred than gets(), fgets(), and scanf().. #2488Humble
KeymasterThis reply has been marked as private.February 21, 2014 at 7:09 pm in reply to: How to list UUID, FSTYPE , LABEL of storage devices in a llinux system ? #2478Humble
KeymasterAlso you can use “blkid” command:
For ex:
[root@humbles-lap ]# blkid /dev/loop0: UUID="Yg52hp-YO2R-7QOr-11PV-fdC6-nqE1-Af0pS1" TYPE="LVM2_member" /dev/sda1: LABEL="WINRE_DRV" UUID="7870EA4270EA06AA" TYPE="ntfs" PARTLABEL="Basic data partition" PARTUUID="e5c49970-3e0d-4d76-b024-766f64258989" /dev/sda2: LABEL="SYSTEM_DRV" UUID="4EEC-B38E" TYPE="vfat" PARTLABEL="EFI system partition" PARTUUID="db3d31b3-05f9-4101-9bbf-1425fd68edb2" /dev/sda3: LABEL="LRS_ESP" UUID="0CED-2AB9" TYPE="vfat" PARTLABEL="Basic data partition" PARTUUID="a56b6cb2-e516-48f3-9adf-35cd11e76e54" /dev/sda4: PARTLABEL="Microsoft reserved partition" PARTUUID="7df2f17d-9751-4a77-828e-2bf7311c3a1f" /dev/sda5: LABEL="Windows8_OS" UUID="429CF07E9CF06E33" TYPE="ntfs" PARTLABEL="Basic data partition" PARTUUID="ad68292e-0517-4bff-b925-899dbe5ab015" /dev/sda6: LABEL="LENOVO" UUID="4228F2B328F2A4D7" TYPE="ntfs" PARTLABEL="Basic data partition" PARTUUID="495f8d21-0a95-4383-86cc-12f6c7d7bbeb" /dev/sda7: LABEL="PBR_DRV" UUID="F63AF44D3AF40BFD" TYPE="ntfs" PARTLABEL="Basic data partition" PARTUUID="368b12c6-c47f-4c1b-acfa-5bcf30f6e214" /dev/sda8: LABEL="/boot" UUID="3ba53f9b-f44b-4c3f-aaa2-0dfbbb75b1e5" TYPE="ext4" PARTUUID="ba3e3a96-a991-401b-a09e-730270d879eb" /dev/sda9: LABEL="/home" UUID="20ad6689-b5a3-4ec3-a9f4-e81d6360ca58" TYPE="ext4" PARTUUID="70ae19be-b309-4939-b236-039acc53718e" /dev/sda10: LABEL="/" UUID="6da5e19a-e9e8-4ad0-a04f-aeaca04035a2" TYPE="ext4" PARTUUID="44f32e05-158d-4535-a5db-40f1b0ded7ca" /dev/sda11: LABEL="swap" UUID="d080a09a-3b45-48d7-9410-ba3b07443388" TYPE="swap" PARTUUID="a61f716e-e187-4f7c-afb9-a44c28cb235f" /dev/sda12: PARTUUID="dc82d2c4-3f74-4b25-9f00-bfb340de03f4" For more information refer man page:
Humble
KeymasterIt can be done by below command ..
tune2fs
tune2fs allows the system administrator to adjust various tunable filesystem parameters on Linux ext2, ext3, or ext4 filesystems.
The current values of these options can be displayed by using the -l option to tune2fs(8) program, or by using the dumpe2fs(8) program.The device specifier can either be a filename (i.e., /dev/sda1), or a LABEL or UUID specifier: “LABEL=volume-name” or “UUID=uuid”. (i.e.,
LABEL=home or UUID=e40486c6-84d5-4f2f-b99c-032281799c9d).Suppose you want to change the journel options as asked above, you can make use of “-J” option.. Please refer man page of tune2fs for more information on this.
-J journal-options Override the default ext3 journal parameters. Journal options are comma separated, and may take an argument using the equals ('=') sign. The following journal options are supported: **February 21, 2014 at 6:49 pm in reply to: [Filesystem] Get/dipsplay ext2/ext3/ext4 filesystem information .. #2472Humble
KeymasterAnswer is simple.. make use of the below command .
dumpe2fs – dump ext2/ext3/ext4 filesystem information
dumpe2fs prints the super block and blocks group information for the filesystem present on device.
For ex: Suppose :
/dev/sda10 on / type ext4 (rw,relatime,seclabel,data=ordered) dumpe2fs gives below information..
[root@humbles-lap ]# dumpe2fs /dev/sda10 dumpe2fs 1.42.7 (21-Jan-2013) Filesystem volume name: / Last mounted on: / Filesystem UUID: 6da5e19a-e9e8-4ad0-a04f-aeaca04035a2 Filesystem magic number: 0xEF53 Filesystem revision #: 1 (dynamic) Filesystem features: has_journal ext_attr resize_inode dir_index filetype needs_recovery extent flex_bg sparse_super large_file huge_file uninit_bg dir_nlink extra_isize Filesystem flags: signed_directory_hash Default mount options: user_xattr acl Filesystem state: clean Errors behavior: Continue Filesystem OS type: Linux Inode count: 3203072 Block count: 12800000 Reserved block count: 640000 Free blocks: 7857714 Free inodes: 2829010 First block: 0 Block size: 4096 Fragment size: 4096 Reserved GDT blocks: 1020 Blocks per group: 32768 Fragments per group: 32768 Inodes per group: 8192 Inode blocks per group: 512 Flex block group size: 16 Filesystem created: Fri Mar 1 13:39:59 2013 Last mount time: Mon Feb 3 00:34:29 2014 Last write time: Mon Feb 3 00:34:28 2014 Mount count: 71 Maximum mount count: -1 Last checked: Fri Mar 1 13:39:59 2013 Check interval: 0 (<none>) Lifetime writes: 23 GB Reserved blocks uid: 0 (user root) Reserved blocks gid: 0 (group root) First inode: 11 Inode size: 256 Required extra isize: 28 Desired extra isize: 28 Journal inode: 8 First orphan inode: 395012 Default directory hash: half_md4 Directory Hash Seed: cd01fa16-ab8d-422e-9701-33ea367c3df2 Journal backup: inode blocks Journal features: journal_incompat_revoke Journal size: 128M Journal length: 32768 Journal sequence: 0x001c06a6 Journal start: 31366 Group 0: (Blocks 0-32767) [ITABLE_ZEROED] Checksum 0xa877, unused inodes 8123 Primary superblock at 0, Group descriptors at 1-4 Reserved GDT blocks at 5-1024 Block bitmap at 1025 (+1025), Inode bitmap at 1041 (+1041) Inode table at 1057-1568 (+1057) 1076 free blocks, 8123 free inodes, 39 directories, 8123 unused inodes Free blocks: 24012-24575, 32256-32767 Free inodes: 70-8192 Group 1: (Blocks 32768-65535) [INODE_UNINIT, ITABLE_ZEROED] ****************************** If you pass "-h" option it will display only SUPERBLOCK information.
Humble
KeymasterThis reply has been marked as private.Humble
KeymasterThis reply has been marked as private.Humble
KeymasterThis reply has been marked as private.Humble
KeymasterThis reply has been marked as private.Humble
KeymasterWell, common thing.. but let me put it in this way..
As everyone says, it comes into category of “link” files..
Hardlink:
Well, hard links point to the same INODE .. but the file names are different and both filenames point to the same inode..
You can create hardlink with ln command as shown below:
[root@humbles-lap ]# ln foo.bar foo1.bar1 [root@humbles-lap ]# ls -li foo* 9443948 -rw-rw-r--. 2 hchiramm hchiramm 0 Jul 14 2013 foo1.bar1 9443948 -rw-rw-r--. 2 hchiramm hchiramm 0 Jul 14 2013 foo.bar [root@humbles-lap ]# In first line, we created "hardlink" to the file called "foo.bar" in name of "foo1.bar1".. How-ever you can see both have same INODE number.. You can only have hardlinks within same filesystem. Also directories can not be hard linked.. Symlinks: symlinks are actually a special file containing a path to another file. When you operate on 'symlinked' filename , it actually access the file which is pointed inside symlink file. In short, symlinks store the path of the file it points too. Unlike hardlinks, symlinks can be on different filesystems.. With "-s" option of "ln" command you can create symlinks.. Please note that symlinks will have different inode numbers..
[root@humbles-lap ]# ln -s foo.bar foo.soft [root@humbles-lap ]# ls -li foo* 9443948 -rw-rw-r--. 2 hchiramm hchiramm 0 Jul 14 2013 foo1.bar1 9443948 -rw-rw-r--. 2 hchiramm hchiramm 0 Jul 14 2013 foo.bar 9449878 lrwxrwxrwx. 1 root root 7 Feb 21 00:16 foo.soft -> foo.bar [root@humbles-lap ]# Please note, l in lrwxrwxrwx ..
Humble
Keymaster[root@humbles-lap]# ls -li foo.bar 9443948 -rw-rw-r--. 1 hchiramm hchiramm 0 Jul 14 2013 foo.bar [root@humbles-lap ]# You can use ls command as shown above to list INODE of a file..
Humble
KeymasterWell.. I can give some idea about inodes..
Obviously this comes under filsystems.. In simple terms filesystems are where the files and directories are structured.. Isnt it? .. When we think about filesystems there are mainly 2 parts..1) The data and 2) The metadata..
What I mean by metadata ? metadata is the data about the data..
Lets take a “file” as an example.. The information about this file can be treated as metadata.. but whats that ?
*) File modification data
*) Owner of the file
*) File permission ..etcI can show an example of a file called “foo.bar” from my filesystem and some information about it.
[hchiramm@humbles-lap ~]$ stat foo.bar File: ‘foo.bar’ Size: 0 Blocks: 0 IO Block: 4096 regular empty file Device: 809h/2057d Inode: 9443948 Links: 1 Access: (0664/-rw-rw-r--) Uid: ( 1000/hchiramm) Gid: ( 1000/hchiramm) Context: unconfined_u:object_r:user_home_t:s0 Access: 2013-07-14 17:35:05.996075662 +0530 Modify: 2013-07-14 17:35:00.799979118 +0530 Change: 2013-07-14 17:35:00.799979118 +0530 Birth: - Inodes store this metadata information and typically they also store information about where the data is located on the storage media. Inodes are represented as an integer called inode number. In above example, the inode number of the file is "9443948 ".. Each file and directory in a filesystem is associated with an inode.. Also refer #http://en.wikipedia.org/wiki/Inode
February 8, 2014 at 10:37 am in reply to: negative numbers, 2’s complement, signed/unsigned int/char .. #2358Humble
KeymasterIts always a doubt that whats default type for int and char . The default type for int is taken as signed.
How-ever char can be unsigned or signed .
/* Minimum and maximum values achar' can hold. */ # ifdef __CHAR_UNSIGNED__ # define CHAR_MIN 0 # define CHAR_MAX UCHAR_MAX # else # define CHAR_MIN SCHAR_MIN # define CHAR_MAX SCHAR_MAX # endif ` If you are with gcc compiler, the default is signed.. You can modify that with -funsigned-char option of gcc..
-funsigned-char Let the type "char" be unsigned, like "unsigned char". Each kind of machine has a default for what "char" should be. It is either like "unsigned char" by default or like "signed char" by default. Ideally, a portable program should always use "signed char" or "unsigned char" when it depends on the signedness of an object. But many programs have been written to use plain "char" and expect it to be signed, or expect it to be unsigned, depending on the machines they were written for. This option, and its inverse, let you make such a program work with the opposite default. The type "char" is always a distinct type from each of "signed char" or "unsigned char", even though its behavior is always just like one of those two. -fsigned-char Let the type "char" be signed, like "signed char". Note that this is equivalent to -fno-unsigned-char, which is the negative form of -funsigned-char. Likewise, the option -fno-signed-char is equivalent to -funsigned-char.
February 8, 2014 at 10:03 am in reply to: negative numbers, 2’s complement, signed/unsigned int/char .. #2357Humble
KeymasterThis reply has been marked as private.Humble
KeymasterThis reply has been marked as private.Humble
KeymasterThis reply has been marked as private.Humble
KeymasterThis reply has been marked as private.Humble
KeymasterThe order in which operators are evaluated is called operator precedence or the order of operations.
Unary operators ( ++ — + – ) order of evaluation is from right to left, so an expression like:
*p++;
would perform the ++ before the *
The comma operator (,) works almost like the semicolon ; that separates one C statement from another. The comma-separated expressions are evaluated from left to right.
Humble
KeymasterThis reply has been marked as private.Humble
KeymasterThis reply has been marked as private. -
AuthorPosts