User Tools

Site Tools


blog:spring2016:kdarling:journal

This is an old revision of the document!


Systems Programming Journal

January-Feb, ALL, 2016

For the entire month of January, we covered the idea of using the manual pages efficiently by using more includes and understanding the unistd.h include.

Other cool new features that we have learned by using the Linux Manual pages on C and other cool C functions was the stat struct and I believe the group struct.

The stat struct contains many useful functions such as it helped in the chmod project in setting file permissions. In order to setup the stat struct and obtain all it's members, an allocation must take place in order for it to properly work. To do so simply state,

struct stat *name = (struct stat*) malloc(sizeof(struct stat));

WALLA! You have obtained all of stat's secret's including the st_mode which helps set file permissions, for example

name → st_mode = 0777;

int chmod(FILE_NAME(I used argv[1], name → st_mode);

BAM! Permissions have been set.

Inside group it gets a little… Strange.

Using name's st_gid, we can set that to groups, another struct so malloc up bois.

groups = getgrgid(name → st_gid); Then now you have access to usernames and unsecured passwords that someone hasn't taken care of, scary stuff.

Overall we have covered

cat.c ls.c who.c and our very own chmod.c for those who did it and attempted it. Other cool features will be listed later inside the blog.

blog/spring2016/kdarling/journal.1455247229.txt.gz · Last modified: 2016/02/12 03:20 by kdarling