QlgChmod()--Change File Authorizations (using NLS-enabled path name)
Syntax
#include <sys/stat.h> int QlgChmod(Qlg_Path_Name_T *path, mode_t mode);Service Program Name: QP0LLIB1
Default Public Authority: *USE
Threadsafe: Conditional; see Usage Notes for chmod().
The QlgChmod() function, like the chmod() function, changes S_ISUID, S_ISGID, S_ISVTX, and the permission bits of the file or directory specified in path to the corresponding bits specified in mode. The difference is that the QlgChmod() function takes a pointer to a Qlg_Path_Name_T structure, while chmod() takes a pointer to a character string.
Limited information about the path parameter is provided here. For more information about the path parameter and for a discussion of other parameters, authorities required, return values, and related information, see chmod()--Change File Authorizations.
Parameters
- path
- (Input) A pointer to a Qlg_Path_Name_T structure that contains the path name or a pointer to the path name of the file whose mode is being changed. For more information about the Qlg_Path_Name_T structure, see Path name format.
Related Information
- chmod()--Change File Authorizations
- QlgChown()--Change Owner and Group of File (using
NLS-enabled path name)
- QlgMkdir()--Make Directory (using NLS-enabled path
name)
- QlgStat()--Get File Information (using NLS-enabled path name)
Example
The following example changes the permissions for a file.
Note: By using the code examples, you agree to the terms of the Code license and disclaimer information.
#include <stdio.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <fcntl.h>
#include <Qp0lstdi.h>
main() {
int file_descriptor;
struct stat info;
#define mypath "temp.file"
const char US_const[3]= "US";
const char Language_const[4] ="ENU";
typedef struct pnstruct
{
Qlg_Path_Name_T qlg_struct;
char pn[100]; /* This array size must be >= the */
/* length of the path name or this must */
/* be a pointer to the path name. */
};
struct pnstruct path;
/***************************************************************/
/* Initialize Qlg_Path_Name_T parameters */
/***************************************************************/
memset((void*)&path, 0x00, sizeof(struct pnstruct));
path.qlg_struct.CCSID = 37;
memcpy(path.qlg_struct.Country_ID,US_const,2);
memcpy(path.qlg_struct.Language_ID,Language_const,3);
path.qlg_struct.Path_Type = QLG_CHAR_SINGLE;
path.qlg_struct.Path_Length = sizeof(mypath)-1;
path.qlg_struct.Path_Name_Delimiter[0] = '/';
memcpy(path.pn,mypath,sizeof(mypath)-1);
if ((file_descriptor = QlgCreat((Qlg_Path_Name_T *)&path, S_IWUSR)) == -1)
perror("QlgCreat() error");
else {
close(file_descriptor);
QlgStat((Qlg_Path_Name_T *)&path, &info);
printf("original permissions were: %08o\n", info.st_mode);
if (QlgChmod((Qlg_Path_Name_T *)&path, S_IRWXU|S_IRWXG) != 0)
perror("QlgChmod() error");
else {
QlgStat((Qlg_Path_Name_T *)&path, &info);
printf("after QlgChmod(), permissions are: %08o\n", info.st_mode);
}
QlgUnlink((Qlg_Path_Name_T *)&path);
}
}
Output:
original permissions were: 00100200 after QlgChmod(), permissions are: 00100770
API introduced: V5R1