Need some C help... v.this is driving me nuts

Discussion in 'OT Technology' started by suprropmp, May 16, 2007.

  1. suprropmp

    suprropmp New Member

    Joined:
    Nov 28, 2004
    Messages:
    5,326
    Likes Received:
    0
    Location:
    Los Angeles
    So for some reason I cannot get information about a file in C.. this is what I am using:

    Code:
        uid_t uid; //users id
        gid_t gid; //users group id
        uid_t fileuid; //file id
        gid_t filegid; //file's group id
        mode_t filemode;
        struct stat fileinfo;
    
        uid=getuid();
        gid=getgid();
    
        strcpy(fullpath, homedir);
        strcat(fullpath, "/");
        strcat(fullpath, argv[1]);
    
        stat(fullpath, &fileinfo);
        fileuid=fileinfo.st_uid;
        filemode=fileinfo.st_mode;
        filegid=fileinfo.st_gid;
    
    Thats a piece of the program I am working on. If I try to print out the fileuid or filegid I keep getting 0. Can anybody tell me whats wrong?
     
  2. skinjob

    skinjob Active Member

    Joined:
    Jan 6, 2001
    Messages:
    2,337
    Likes Received:
    0
    Location:
    Aztlán
    Check if stat() is failing, and errno for a reason why.
     
  3. suprropmp

    suprropmp New Member

    Joined:
    Nov 28, 2004
    Messages:
    5,326
    Likes Received:
    0
    Location:
    Los Angeles
    Ok, figured it out.. thank you :)
     

Share This Page