Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 13 Jun 2007 08:37:46 -0700
From:      Gregory Shapiro <gshapiro@freebsd.org>
To:        Garrett Cooper <youshi10@u.washington.edu>
Cc:        hackers@freebsd.org
Subject:   Re: Using shell commands versus C equivalents
Message-ID:  <20070613153745.GF27029@monkeyboy.local>
In-Reply-To: <46700CAE.6020902@u.washington.edu>
References:  <466F86C6.7010006@u.washington.edu> <20070613123213.GE98927@bunrab.catwhisker.org> <E1HySxb-000PIg-89@cs1.cs.huji.ac.il> <46700CAE.6020902@u.washington.edu>

next in thread | previous in thread | raw e-mail | index | archive | help
>  Sorry -- actually I meant that (along similar lines), there was a program 
>  with the following lines:
> 
>  vsystem("/bin/chmod +x %s", filename);
> 
>  and I replaced it with:
> 
>  chmod(filename, (mode_t) ( S_IXUSR | S_IXGRP | S_IXOTH ));

Those two lines have different effects.  The first adds the execute bit
to the file.  The second replaces the current permissions with only the
execute bit.  To have the same affect, you need to stat() the file,
and then use bitwise-or to add the S_IXUSR | S_IXGRP | S_IXOTH bits to
st_mode and use that new st_mode with chmod().



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20070613153745.GF27029>