#include <sys/stat.h> int QlgChmod(Qlg_Path_Name_T *path, mode_t mode);Service Program Name: QP0LLIB1
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 on the path parameter is provided here. For more information on the path parameter and for a discussion of other parameters, authorities required, return values, and related information, see chmod()--Change File Authorizations.
See Code disclaimer information for information pertaining to code examples.
The following example changes the permissions for a file:
#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
| Top | UNIX-Type APIs | APIs by category |