#include <sys/stat.h> int QlgLstat(Qlg_Path_Name_T *path,struct stat *buf);Service Program Name: QP0LLIB1
The QlgLstat() function, like the lstat() function, gets status information about a specified file and places it in the area of memory pointed to by buf. The difference is that the QlgLstat() function takes a pointer to a Qlg_Path_Name_T structure, while lstat() 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 lstat()--Get File or Link Information.
See Code disclaimer information for information pertaining to code examples.
The following example provides status information for a file:
#include <sys/types.h>
#include <sys/stat.h>
#include <stdio.h>
#include <fcntl.h>
#include <unistd.h>
#include <time.h>
#include <stdio.h>
#include <Qp0lstdi.h>
main() {
struct stat info;
int file_descriptor;
#define mypath_fn "temp.file"
#define mypath_ln "temp.link"
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_fn;
struct pnstruct path_ln;
/***************************************************************/
/* Initialize Qlg_Path_Name_T parameters */
/***************************************************************/
memset((void*)&path_fn, 0x00, sizeof(struct pnstruct));
path_fn.qlg_struct.CCSID = 37;
memcpy(path_fn.qlg_struct.Country_ID,US_const,2);
memcpy(path_fn.qlg_struct.Language_ID,Language_const,3);
path_fn.qlg_struct.Path_Type = QLG_CHAR_SINGLE;
path_fn.qlg_struct.Path_Length = sizeof(mypath_fn)-1;
path_fn.qlg_struct.Path_Name_Delimiter[0] = '/';
memcpy(path_fn.pn,mypath_fn,sizeof(mypath_fn)-1);
memset((void*)&path_ln, 0x00, sizeof(struct pnstruct));
path_ln.qlg_struct.CCSID = 37;
memcpy(path_ln.qlg_struct.Country_ID,US_const,2);
memcpy(path_ln.qlg_struct.Language_ID,Language_const,3);
path_ln.qlg_struct.Path_Type = QLG_CHAR_SINGLE;
path_ln.qlg_struct.Path_Length = sizeof(mypath_ln)-1;
path_ln.qlg_struct.Path_Name_Delimiter[0] = '/';
memcpy(path_ln.pn,mypath_ln,sizeof(mypath_ln)-1);
if ((file_descriptor = QlgCreat((Qlg_Path_Name_T *)&path_fn, S_IWUSR)) < 0)
perror("QlgCreat() error");
else {
close(file_descriptor);
if (QlgLink((Qlg_Path_Name_T *)&path_fn,
(Qlg_Path_Name_T *)&path_ln)
!=0
perror("QlgLink() error");
else {
if (QlgLstat((Qlg_Path_Name_T *)&path_ln, &info) != 0)
perror("QlgLstat() error");
else {
puts("QlgLstat() returned:");
printf(" inode: %d\n", (int) info.st_ino);
printf(" dev id: %d\n", (int) info.st_dev);
printf(" mode: %08x\n", info.st_mode);
printf(" links: %d\n", info.st_nlink);
printf(" uid: %d\n", (int) info.st_uid);
printf(" gid: %d\n", (int) info.st_gid);
}
QlgUnlink((Qlg_Path_Name_T *)&path_ln);
}
QlgUnlink((Qlg_Path_Name_T *)&path_fn);
}
}
Output:
QlgLstat() returned:
inode: 8477
dev id: 0
mode: 00008080
links: 2
uid: 1782
gid: 0
| Top | UNIX-Type APIs | APIs by category |