| 1 |
/*********************************************************************** |
| 2 |
* Code listing from "Advanced Linux Programming," by CodeSourcery LLC * |
| 3 |
* Copyright (C) 2001 by New Riders Publishing * |
| 4 |
* See COPYRIGHT for license information. * |
| 5 |
***********************************************************************/ |
| 6 |
|
| 7 |
#include <stdio.h> |
| 8 |
#include <sys/stat.h> |
| 9 |
|
| 10 |
int main (int argc, char* argv[]) |
| 11 |
{ |
| 12 |
const char* const filename = argv[1]; |
| 13 |
struct stat buf; |
| 14 |
/* Get file information. */ |
| 15 |
stat (filename, &buf); |
| 16 |
/* If the permissions are set such that the file's owner can write |
| 17 |
to it, print a message. */ |
| 18 |
if (buf.st_mode & S_IWUSR) |
| 19 |
printf ("Owning user can write `%s'.\n", filename); |
| 20 |
return 0; |
| 21 |
} |