mkdir - solaris 10

This is a discussion on mkdir - solaris 10 within the C Programming forums, part of the General Programming Boards category; We are moving to solaris 10, so I have been given the task of validating lots of programs to check ...

  1. #1
    Registered User
    Join Date
    Aug 2006
    Posts
    3

    mkdir - solaris 10

    We are moving to solaris 10, so I have been given the task of validating lots of programs to check that they work.

    I have come up with an oddity in a program that is run by root which creates a directory.

    Code:
    mkdir(directory, S_IRWXU | S_IRWXG | S_IRWXO)
    On a machine running solaris 2.6 it create the directory with the expected permissions of 777 but on the solaris 10 machine it creates it 755, if code amended to do a subsequent call to

    Code:
    chmod(directory, S_IRWXU | S_IRWXG | S_IRWXO)
    this then works on the solaris 10 machine.

    Any idea why mkdir would work differently on solaris 10.

    I am new to this, this is my first posting, and any help would be gratefully received.

    Cheers.

  2. #2
    Gawking at stupidity
    Join Date
    Jul 2004
    Location
    Oregon, USA
    Posts
    3,175
    Sounds like a umask issue:
    NAME
    mkdir - create a directory

    SYNOPSIS
    #include <sys/stat.h>
    #include <sys/types.h>

    int mkdir(const char *pathname, mode_t mode);

    DESCRIPTION
    mkdir attempts to create a directory named pathname.

    mode specifies the permissions to use. It is modified by the process's
    umask in the usual way: the permissions of the created file are (mode &
    ~umask).
    If you understand what you're doing, you're not learning anything.

  3. #3
    Registered User
    Join Date
    Aug 2006
    Posts
    3
    The umasks are set differently for root on the different machines, but if umask on solaris 10 machine is changed to be the same in root's .cshrc the problem still occurs.

    The code is compiled on a solaris 2.6 machine using gcc 2.95.3

    Cheers

  4. #4
    Gawking at stupidity
    Join Date
    Jul 2004
    Location
    Oregon, USA
    Posts
    3,175
    I'm wondering, what if you add umask(0); just before the mkdir() call?
    If you understand what you're doing, you're not learning anything.

  5. #5
    Registered User
    Join Date
    Aug 2006
    Posts
    3
    We have solved the problem.

    The program is run as a daemon via init and apparently prior to Solaris 8 all daemons inherited the umask 0 from init, but in Solaris 8 the default was changed from 0 to 022.

    The value can now be set in /etc/default/init (CMASK=value), but we intend to amend the program to fix the problem.

    Sorry for not mentioning that the program was being run as a daemon, if this information would have helped.

    Cheers
    Last edited by StevieT; 08-17-2006 at 04:39 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. reading a file
    By nhubred in forum C++ Programming
    Replies: 3
    Last Post: 05-21-2009, 12:34 PM
  2. A-Star Pathfinding
    By mike_g in forum General AI Programming
    Replies: 1
    Last Post: 08-05-2007, 05:18 PM
  3. Solaris 10
    By anirban in forum Tech Board
    Replies: 4
    Last Post: 07-27-2007, 01:31 AM
  4. Segmentation Fault
    By Lost__Soul in forum C Programming
    Replies: 46
    Last Post: 04-28-2003, 05:24 AM
  5. Scheduling Algo
    By BigDaddyDrew in forum C++ Programming
    Replies: 41
    Last Post: 03-08-2003, 11:00 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21