![Symbian Developer Library](../../../../a_stock/images/mainheading.gif)
![]() |
![]() |
|
Interface status: | externallyDefinedApi |
S_ISDIR (m) (((m) & 0170000) == 0040000)
directory.
|
Interface status: | externallyDefinedApi |
S_ISCHR (m) (((m) & 0170000) == 0020000)
char special.
|
Interface status: | externallyDefinedApi |
S_ISBLK (m) (((m) & 0170000) == 0060000)
block special
|
Interface status: | externallyDefinedApi |
S_ISREG (m) (((m) & 0170000) == 0100000)
regular file
|
Interface status: | externallyDefinedApi |
S_ISFIFO (m) (((m) & 0170000) == 0010000)
fifo or socket
|
Interface status: | externallyDefinedApi |
S_ISLNK (m) (((m) & 0170000) == 0120000)
symbolic link
|
Interface status: | externallyDefinedApi |
typedef __blksize_t blksize_t;
Used for block sizes.
Interface status: | externallyDefinedApi |
typedef __blkcnt_t blkcnt_t;
Used for file block counts.
Interface status: | externallyDefinedApi |
typedef __dev_t dev_t;
device number or struct cdev
Interface status: | externallyDefinedApi |
typedef __ino_t ino_t;
Used for file serial numbers.
Interface status: | externallyDefinedApi |
IMPORT_C int chmod(const char *, mode_t);
#include < sys/stat.h > :
The file permission bits of the file named specified by _path or referenced by the file descriptor fd are changed to _mode. The chmod system call verifies that the process owner (user) either owns the file specified by _path (or fd ), or is the super-user. The chmod system call follows symbolic links to operate on the target of the link rather than the link itself.
The lchmod system call is similar to chmod but does not follow symbolic links.
A mode is created from ored permission bit masks defined in #include <sys/stat.h> :
#define S_IRWXU 0000700 // RWX mask for owner
#define S_IRUSR 0000400 // R for owner
#define S_IWUSR 0000200 // W for owner
#define S_IXUSR 0000100 // X for owner
#define S_IRWXG 0000070 // RWX mask for group
#define S_IRGRP 0000040 // R for group
#define S_IWGRP 0000020 // W for group
#define S_IXGRP 0000010 // X for group
#define S_IRWXO 0000007 // RWX mask for other
#define S_IROTH 0000004 // R for other
#define S_IWOTH 0000002 // W for other
#define S_IXOTH 0000001 // X for other
#define S_ISUID 0004000 // set user id on execution
#define S_ISGID 0002000 // set group id on execution
#ifndef __BSD_VISIBLE
#define S_ISTXT 0001000 // sticky bit
#endif
Notes :
Sticky bit and set id on execution are not supported.
Permission values for group and others are ignored as there is no concept of group and others on the Symbian OS. The flag bits S_IXUSR, S_IXGRP & S_IXOTH are ignored as execute permissions on a file are meaningless on Symbian OS.
An attempt to change file permission to write-only changes the file permission to read-write.
Either or both of S_IRUSR or S_IWUSR bits must be set in the _mode argument, else chmod fails with EINVAL.
Permissions for directories are ignored.
000 mode is treated as invalid mode as Symbian OS cannot have entries with both read and write permissions absent.
Examples:
/*Detailed description: This test code demonstartes usage of chmod system call, it
changes mode of file Example.txt in the current working directory to read-only.
Preconditions: Example.txt file should be present in the current working directory.
*/
int main()
{
if(chmod("Example.txt" , 0444) < 0 )
{
printf("change mode of file Example.txt failed");
return -1;
}
printf("Chmod system call successful");
return 0;
}
Output
Chmod system call successful
/* Detailed description : This sample code demonstrates the usage of fchmod system call, this code
changes mode of file Example.txt using fchmod system call.
*/
# 98 "d:/EPOC/release/9.4/common/generic/openenv/core/include/sys/stat.dosc" 2
# 99 "d:/EPOC/release/9.4/common/generic/openenv/core/include/sys/stat.dosc" 2
# 100 "d:/EPOC/release/9.4/common/generic/openenv/core/include/sys/stat.dosc" 2
int main()
{
int fd = 0;
fd = open("Example.txt" , 0x0200 | 0x0002 , 0666);
if(fd < 0 ) {
printf("Failed to open file Example.txt");
return -1;
}
if(fchmod(fd , 0444) < 0 ) {
printf("fchmod failed to change mode of file Example.txt");
return -1;
}
printf("Fchmod call changed mode of Example.txt");
return 0;
}
Output
Fchmod call changed mode of Example.txt
Limitations:
KErrNotReady of Symbian error code is mapped to ENOENT, which typically means drive not found or filesystem not mounted on the drive.
|
|
chmod(const char *,mode_t)
chmod(const char *,mode_t)
Sets the access permissions for the file whose name is given by pathname to the ...chown(const char *,uid_t,gid_t)
chown(const char *,uid_t,gid_t)
...stat(const char *,struct stat *)
stat(const char *,struct stat *)
Gets the size of a file.Interface status: | externallyDefinedApi |
IMPORT_C int fchmod(int, mode_t);
|
|
chmod(const char *,mode_t)
chmod(const char *,mode_t)
Sets the access permissions for the file whose name is given by pathname to the ...chown(const char *,uid_t,gid_t)
chown(const char *,uid_t,gid_t)
...stat(const char *,struct stat *)
stat(const char *,struct stat *)
Gets the size of a file.Interface status: | externallyDefinedApi |
IMPORT_C int fstat(int, struct stat *);
|
|
access(const char *,int)
access(const char *,int)
...chmod(const char *,mode_t)
chmod(const char *,mode_t)
Sets the access permissions for the file whose name is given by pathname to the ...chown(const char *,uid_t,gid_t)
chown(const char *,uid_t,gid_t)
...utimes(const char *,const struct timeval *)
utimes(const char *,const struct timeval *)
...symlink(const char *,const char *)
symlink(const char *,const char *)
...Interface status: | externallyDefinedApi |
IMPORT_C int lstat(const char *, struct stat *);
|
|
access(const char *,int)
access(const char *,int)
...chmod(const char *,mode_t)
chmod(const char *,mode_t)
Sets the access permissions for the file whose name is given by pathname to the ...chown(const char *,uid_t,gid_t)
chown(const char *,uid_t,gid_t)
...utimes(const char *,const struct timeval *)
utimes(const char *,const struct timeval *)
...symlink(const char *,const char *)
symlink(const char *,const char *)
...IMPORT_C int __xstat(int, const char *file, struct stat *buf);
|
|
access(const char *,int)
access(const char *,int)
...chmod(const char *,mode_t)
chmod(const char *,mode_t)
Sets the access permissions for the file whose name is given by pathname to the ...chown(const char *,uid_t,gid_t)
chown(const char *,uid_t,gid_t)
...utimes(const char *,const struct timeval *)
utimes(const char *,const struct timeval *)
...symlink(const char *,const char *)
symlink(const char *,const char *)
...IMPORT_C int __lxstat(int, const char *file, struct stat *buf);
|
|
access(const char *,int)
access(const char *,int)
...chmod(const char *,mode_t)
chmod(const char *,mode_t)
Sets the access permissions for the file whose name is given by pathname to the ...chown(const char *,uid_t,gid_t)
chown(const char *,uid_t,gid_t)
...utimes(const char *,const struct timeval *)
utimes(const char *,const struct timeval *)
...symlink(const char *,const char *)
symlink(const char *,const char *)
...Interface status: | externallyDefinedApi |
IMPORT_C int mkdir(const char *, mode_t);
The directory _path is created with the access permissions specified by _mode.
Notes:
_mode values and access permissions are ignored in Symbian OS.
The default working directory of a process is initialized to C: \private\U ID (UID of the calling application) and any data written into this directory persists between phone resets.
The parent directory's time stamp is not updated when a new child is created.
The newly created directory will be empty (i.e. it doesn't have "." and ".." entries)
Examples:
/* Detailed description : This test code demonstrates usage of mkdir systemcall,
it creates function a directory Example in current working directory.
*/
int main()
{
if(mkdir("Example" , 0666) < 0 )
{
printf("Directory creation failed");
return -1;
}
printf("Directory Example created");
return 0;
}
Output
Directory Example created
Limitations:
The path parameter in mkdir(const char *,mode_t)
mkdir(const char *,mode_t)
should not exceed 256 characters in length.
KErrNotReady of Symbian error code is mapped to ENOENT, which typically means drive not found or filesystem not mounted on the drive.
The path given to mkdir(const char *,mode_t)
mkdir(const char *,mode_t)
should be complete. Attempting to create a directory my calling mkdir("logs",0400|0200|0100) will pass on emulator but fails
on h/w because the cwd is taken as c: on emulator and z: on h/w. Since Z drive is a rom on h/w, mkdir(const char *,mode_t)
mkdir(const char *,mode_t)
fails by setting errno to 13 on hardware.
|
|
chmod(const char *,mode_t)
chmod(const char *,mode_t)
Sets the access permissions for the file whose name is given by pathname to the ...stat(const char *,struct stat *)
stat(const char *,struct stat *)
Gets the size of a file.umask(mode_t)
umask(mode_t)
...Interface status: | externallyDefinedApi |
IMPORT_C int mkfifo(const char *, mode_t);
The mkfifo system call creates a new FIFO(First In First Out) file with name path. The access permissions are specified by mode and restricted by the umask of the calling process. With the current implementation, the use of umask has no effect.
The FIFO's owner ID and group ID are set to root.
Please note that running stat on a FIFO file does not provide modification time information (it provides the creation time). Use fstat on the fd to retrieve the last modified time.
Examples:
#include <sys/types.h>
#include <sys/stat.h>
#include <stdio.h>
int main(void)
{
char *pathname = "C:\XXX";
mode_t mode = 0666;
if (mkfifo(pathname, mode) == -1) {
printf("mkfifo() failed");
}
return 0;
}
Limitations:
KErrNotReady of Symbian error code is mapped to ENOENT, which typically means drive not found or filesystem not mounted on the drive.
|
|
chmod(const char *,mode_t)
chmod(const char *,mode_t)
Sets the access permissions for the file whose name is given by pathname to the ...stat(const char *,struct stat *)
stat(const char *,struct stat *)
Gets the size of a file.umask(mode_t)
umask(mode_t)
...Interface status: | externallyDefinedApi |
IMPORT_C int stat(const char *, struct stat *);
st_dev The numeric ID of the device containing the file.
st_ino The file's inode number.
st_nlink
The number of hard links to the file.
st_atime Time when file data last accessed.
Changed by the .Xr utimes 2, read and readv system calls.
st_mtime Time when file data last modified.
Changed by the mkdir, mkfifo, mknod, utimes, write and writev system calls.
st_ctime Time when file status was last changed (inode data modification).
Changed by the chmod, chown, creat, link, mkdir, mkfifo, mknod, rename, rmdir, symlink, truncate, unlink, utimes, write and writev system calls.
st_birthtime
Time when the inode was created.
st_size The file size in bytes.
st_blksize
The optimal I/O block size for the file.
st_blocks The actual number of blocks allocated for the file in 512-byte units.
As short symbolic links are stored in the inode, this number may
be zero.
st_uid The user ID of the file's owner.
st_gid The group ID of the file.
st_mode
Status of the file (see below).
Test for a block special file.
Test for a character special file.
Test for a directory.
Test for a pipe or FIFO special file.
Test for a symbolic link. NOTE: Inode structure is not supported by Symbian OS and hence link count updation is not possible.
Check for symbolic link would always fail because of this reason.
Test for a regular file.
Test for a socket.
Test for a whiteout.
The stat system call obtains information about the file pointed to by path. Read, write or execute permission of the named file is not required, but all directories listed in the path name leading to the file must be searchable.
The lstat system call is like stat except in the case where the named file is a symbolic link, in which case lstat returns information about the link, while stat returns information about the file the link references.
The fstat system call obtains the same information about an open file known by the file descriptor fd.
The __xstat and __lxstat system calls are exactly similar to stat and lstat functionality.
The sb argument is a pointer to a stat structure as defined by #include <sys/stat.h> and into which information is placed concerning the file.
The fields of struct stat related to the file system are as follows:
st_dev The numeric ID of the device containing the file.
st_ino The file's inode number.
st_nlink The number of hard links to the file.
The st_dev and st_ino fields together identify the file uniquely within the system.
The time-related fields of struct stat are as follows:
st_atime Time
Time
when file data last accessed. Changed by the .Xr utimes 2, read and readv system calls. st_mtime Time
Time
when file data last modified. Changed by the mkdir, mkfifo, mknod, utimes, write and writev system calls. st_ctime Time
Time
when file status was last changed (inode data modification). Changed by the chmod, chown, creat, link, mkdir, mkfifo, mknod,
rename, rmdir, symlink, truncate, unlink, utimes, write and writev system calls. st_birthtime Time
Time
when the inode was created.
If _POSIX_SOURCE is not defined, the time-related fields are defined as:
#ifndef _POSIX_SOURCE
#define st_atime st_atimespec.tv_sec
#define st_mtime st_mtimespec.tv_sec
#define st_ctime st_ctimespec.tv_sec
#endif
The size-related fields of the struct stat are as follows: st_size The file size in bytes. st_blksize The optimal I/O block size for the file. st_blocks The actual number of blocks allocated for the file in 512-byte units.
As short symbolic links are stored in the inode, this number may be zero.
The access-related fields of struct stat are as follows: st_uid The user ID of the file's owner. st_gid The group ID of the file. st_mode Status of the file (see below).
The status information word st_mode has the following bits:
#define S_IFMT 0170000 // type of file
#define S_IFIFO 0010000 // named pipe (fifo)
#define S_IFCHR 0020000 // character special
#define S_IFDIR 0040000 // directory
#define S_IFBLK 0060000 // block special
#define S_IFREG 0100000 // regular
#define S_IFLNK 0120000 // symbolic link
#define S_IFSOCK 0140000 // socket
#define S_IFWHT 0160000 // whiteout
#define S_ISUID 0004000 // set user id on execution
#define S_ISGID 0002000 // set group id on execution
#define S_ISVTX 0001000 // save swapped text even after use
#define S_IRUSR 0000400 // read permission, owner
#define S_IWUSR 0000200 // write permission, owner
#define S_IXUSR 0000100 // execute/search permission, owner
For a list of access modes, see #include <sys/stat.h> access and chmod The following macros are available to test whether a st_mode value passed in the m argument corresponds to a file of the specified type: S_ISBLK (m); Test for a block special file. S_ISCHR (m); Test for a character special file. S_ISDIR (m); Test for a directory. S_ISFIFO (m); Test for a pipe or FIFO special file. S_ISLNK (m); Test for a symbolic link. NOTE: Inode structure is not supported by Symbian OS and hence link count updation is not possible. Check for symbolic link would always fail because of this reason. S_ISREG (m); Test for a regular file. S_ISSOCK (m); Test for a socket. S_ISWHT (m); Test for a whiteout.
The macros evaluate to a non-zero value if the test is true or to the value 0 if the test is false.
Note: To obtain correct timestamps of FIFOs use fstat instead of stat call.
Examples:
/* Detailed description: Sample usage of stat system call
Preconditions: Example.txt file should be present in working directory
*/
# 509 "d:/EPOC/release/9.4/common/generic/openenv/core/include/sys/stat.dosc" 2
# 510 "d:/EPOC/release/9.4/common/generic/openenv/core/include/sys/stat.dosc" 2
# 511 "d:/EPOC/release/9.4/common/generic/openenv/core/include/sys/stat.dosc" 2
# 512 "d:/EPOC/release/9.4/common/generic/openenv/core/include/sys/stat.dosc" 2
int main()
{
struct stat buf;
if(stat("Example.txt" , &buf;) < 0 )
{
printf("Failed to stat Example.txt");
return -1;
}
printf("Stat system call succeeded");
return 0;
}
/*
Detailed description: Sample usage of fstat system call
*/
# 528 "d:/EPOC/release/9.4/common/generic/openenv/core/include/sys/stat.dosc" 2
# 529 "d:/EPOC/release/9.4/common/generic/openenv/core/include/sys/stat.dosc" 2
# 530 "d:/EPOC/release/9.4/common/generic/openenv/core/include/sys/stat.dosc" 2
# 531 "d:/EPOC/release/9.4/common/generic/openenv/core/include/sys/stat.dosc" 2
int main()
{
struct stat buf;
int fd = open("Example.txt" , 0x0000 | 0x0200 , 0666);
if(fstat(fd , &buf;) < 0 )
{
printf("Failed to stat Example.txt");
return -1;
}
printf("Stat system call succeeded");
close(fd);
return 0;
}
Output
Stat system call succeeded
Output
Stat system call succeeded
Limitations:
The path parameters of the stat(const char *,struct stat *)
stat(const char *,struct stat *)
and lstat(const char *,struct stat *)
lstat(const char *,struct stat *)
functions should not exceed 256 characters each in length.
KErrNotReady of Symbian error code is mapped to ENOENT, which typically means drive not found or filesystem not mounted on the drive.
|
|
access(const char *,int)
access(const char *,int)
...chmod(const char *,mode_t)
chmod(const char *,mode_t)
Sets the access permissions for the file whose name is given by pathname to the ...chown(const char *,uid_t,gid_t)
chown(const char *,uid_t,gid_t)
...utimes(const char *,const struct timeval *)
utimes(const char *,const struct timeval *)
...symlink(const char *,const char *)
symlink(const char *,const char *)
...