Monday, December 31, 2007

Mask Me...!?!!!

echo "2007" > /dev/null
Years are going by... so does my age...! wish i could execute "chage -E never mj0vy"
In a way, 2007 was good for me...! Atleast i have started blogging. This year i could really catch up with linux to some extend...! Nothing more to say..!

Lets get into the matter,
Last week me and my friend Gigith were checking the mask flag in setfacl command...! we did some experimentation and finally came up with a good solution.

I assume you all know how to do basic things with setfacl.

i am starting by creating an empty file

#touch /myfile
Note: touch is used to update the timestamp of a file.
#chmod 750 /myfile
I have given the permission for group as read and write ( 4 + 1 )
I am granting full permission for the user tux in that file.

#setfacl -m u:redhat:rwx /myfile
Now the mask of the file would be assigned the maximum value , is rwx(7), but still the owning group's permission would still be read and write only.

#chmod 700 /myfile
Now i negated the permission of group from that file, resulting in the change of mask value from rw to null. But the important thing to note here is that, the owning groups permission would still be 5(r-x), as it was the permission given at the beginning of this setfacl testing operation. But the effective permission of the owning group and the named user would be the permission common between the owning group and the mask. So here, the effective permission would be - - - for both the owning group and named user.
Here the owning group is the group affiliated to /myfile and the named user is the user tux.

Note: whenever the setfacl command is invoked on the file /myfile, the mask is again changed to its maximum value.

Monday, December 3, 2007

file: DRAG me into CD/RW :)

Its high time we must bid bye-byes to cdrecord and growisofs...!

Until yesterday were were using the ISO9660 filesystem for burning the CDs and DVDs. But from now, its an oblivion.... welcome UDF.. Universal Disk Format..!
UDF lets us write datas incrementally to a mounted filessytem.

For this to work you should have the udftools package installed on your system, one blank cdrw, distribution of linux with a 2.6 kernel ( i tested in RHEL 5.0 ).

you can get the udftools package from here

here we goooooooo

Step 1:
Insert the blank cdrw into the drive and using the cdrwtool command which
we got from the udftools package, we are doing to blank the cdrw first..
Assuming your cd-burner is connected as secondary master..(/dev/hdc)

#cdrwtool -d /dev/hdc -t 4 -l 3 -q
( man cdrwtool )
this would blank the cdrw. Please be patient, it might take SOME time..!

Step 2:
We need to associate the blank formatted media with a packet device using the command pktsetup.

#pktsetup dragme /dev/hdc

Step 3:
Now we need to format the media with the udf filesystem,

#mkudffs --media-type=cdrw --udfrev=0x0150 /dev/pktcdvd/dragme

Step 4:
Now we need to make a mountpoint, let me give it as /drag-n-drop
#mkdir /drag-n-drop

#mount -t udf -o rw /dev/pktcdvd/dragme /drag-n-drop

#chmod 777 /drag-n-drop
(If you want local uses also to drag-n-drop something into it)

Now try some drag and dropping into that mountpoint

Now about the unmounting,

Its always safe to sync before unmouting,
So,
#sync
#umount /dev/pktcdvd/dragme

Then we can release the device /dev/pktcdvd/dragme from the packet device association.

#pktsetup -d /dev/pktcdvd/dragme

NOTE: Its always good to mount the packet device with noatime mount option if you want to ignore the number of rewrites in your media.

Now if you want to mount this media in other machine,
make a packet device with pktsetup and associate it with the device of your cd-drive

#pktsetup dragger /dev/hdd

This will map /dev/pktcdvd/dragger with /dev/hdd
Now you can mount the packet device and use it
#mount -t udf /dev/pktcdvd/dragger /mnt

~mj0vy