SFS for­mat for a real par­ti­tion

OpenSource For You - - DEVELOPERS LET’S TRY -

There­after, Pugs took the lead and slightly mod­i­fied Sh­weta's for­mat_sfs.c and sf­s_ds.h files to for­mat a real pen drive's par­ti­tion. The key change was that in­stead of cre­at­ing the de­fault reg­u­lar file .sfsf to for­mat, it would now be oper­at­ing on an ex­ist­ing block de­vice file cor­re­spond­ing to an un­der­ly­ing par­ti­tion, say, some­thing like /dev/sdb1. So: ,t would get the par­ti­tion's size from the par­ti­tion's block de­vice file it­self, rather than tak­ing it as a com­mand-line ar­gu­ment. Ac­cord­ingly, it would now ex­pect the par­ti­tion's block de­vice file name in­stead of size, as main()'s first ar­gu­ment. Also, it would not need mark_­data_block() to grow the file to eT­ual the par­ti­tion’s size. The ioctl com­mand BLKGETSIZE64 gets the 64-bit size of the un­der­ly­ing block de­vice par­ti­tion, in bytes. Then, it is di­vided by the block size ( SIMULA_FS_BLOCK_SIZE) to get the par­ti­tion's size in block units. Here is the cor­re­spond­ing mod­i­fied snip­pet of the main() func­tion in for­mat_sfs.c, along with the reTuired type­def in sf­s_ds.h: type­def un­signed long long uin­t8_t; ... uin­t8_t size; sf­s_han­dle = open(argv[1], O_RDWR); if (sf­s_han­dle == -1) {

Fig­ure 1 demon­strates all of the above, ex­cept the backup steps, at the root prompt (#). ,nstead, you may use sudo, as well. Note that Pugs got his pen drive par­ti­tion mounted at / me­dia/10AC-BF1C, and the cor­re­spond­ing de­vice file is / dev/sdb1 (/dev/sdb be­ing the com­plete pen drive). Both these may be dif­fer­ent in your case, so take the sub­seTuent steps ac­cord­ingly. Also, note that the SFS for­mat­ting is then started us­ing the fol­low­ing com­mand:

# ./for­mat_sfs /dev/sdb1

Newspapers in English

Newspapers from India

© PressReader. All rights reserved.