os/ossrv/genericopenlibs/openenvcore/include/sys/stat.dosc
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
sl@0
     1
/** @file  ../include/sys/stat.h
sl@0
     2
@internalComponent
sl@0
     3
*/
sl@0
     4
sl@0
     5
/** @fn  chmod(const char *_path, mode_t _mode)
sl@0
     6
@param _path
sl@0
     7
@param _mode
sl@0
     8
sl@0
     9
Note: This description also covers the following functions -
sl@0
    10
 fchmod()  lchmod() 
sl@0
    11
sl@0
    12
@return   Upon successful completion, the value 0 is returned; otherwise the
sl@0
    13
value -1 is returned and the global variable errno is set to indicate the
sl@0
    14
error.
sl@0
    15
sl@0
    16
@code
sl@0
    17
  #include < sys/stat.h > :
sl@0
    18
@endcode
sl@0
    19
  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
sl@0
    20
the file specified by _path (or fd ),
sl@0
    21
or
sl@0
    22
is the super-user.
sl@0
    23
The chmod system call follows symbolic links to operate on the target of the link
sl@0
    24
rather than the link itself.
sl@0
    25
sl@0
    26
 The lchmod system call is similar to chmod but does not follow symbolic links.
sl@0
    27
sl@0
    28
 A mode is created from ored permission bit masks
sl@0
    29
defined in  \#include \<sys/stat.h\> :
sl@0
    30
sl@0
    31
@code
sl@0
    32
#define S_IRWXU 0000700    // RWX mask for owner
sl@0
    33
#define S_IRUSR 0000400    // R for owner 
sl@0
    34
#define S_IWUSR 0000200    // W for owner 
sl@0
    35
#define S_IXUSR 0000100    // X for owner 
sl@0
    36
#define S_IRWXG 0000070    // RWX mask for group
sl@0
    37
#define S_IRGRP 0000040    // R for group
sl@0
    38
#define S_IWGRP 0000020    // W for group
sl@0
    39
#define S_IXGRP 0000010    // X for group
sl@0
    40
#define S_IRWXO 0000007    // RWX mask for other
sl@0
    41
#define S_IROTH 0000004    // R for other
sl@0
    42
#define S_IWOTH 0000002    // W for other
sl@0
    43
#define S_IXOTH 0000001    // X for other
sl@0
    44
#define S_ISUID 0004000    // set user id on execution
sl@0
    45
#define S_ISGID 0002000    // set group id on execution
sl@0
    46
#ifndef __BSD_VISIBLE
sl@0
    47
#define S_ISTXT 0001000    // sticky bit
sl@0
    48
#endif
sl@0
    49
@endcode
sl@0
    50
sl@0
    51
 Notes :
sl@0
    52
sl@0
    53
 Sticky bit and set id on execution are not supported.
sl@0
    54
sl@0
    55
 Permission values for group and others are ignored as there is no concept of 
sl@0
    56
  group and others on the Symbian OS.
sl@0
    57
 The flag bits S_IXUSR, S_IXGRP & S_IXOTH are ignored as execute permissions on a file are meaningless on Symbian OS.
sl@0
    58
 
sl@0
    59
  An attempt to change file permission to write-only changes the file permission 
sl@0
    60
  to read-write.
sl@0
    61
sl@0
    62
Either or both of S_IRUSR or S_IWUSR bits must be set in the _mode argument, else chmod fails with EINVAL. 
sl@0
    63
sl@0
    64
 Permissions for directories are ignored.
sl@0
    65
sl@0
    66
 000 mode is treated as invalid mode as Symbian OS cannot have entries with 
sl@0
    67
  both read and write permissions absent.
sl@0
    68
sl@0
    69
sl@0
    70
sl@0
    71
Examples:
sl@0
    72
@code
sl@0
    73
/*Detailed description: This test code demonstartes usage of chmod system call, it
sl@0
    74
 * changes mode of file Example.txt in the current working directory to read-only.
sl@0
    75
 * Preconditions: Example.txt file should be present in the current working directory.
sl@0
    76
 */
sl@0
    77
int main()
sl@0
    78
{
sl@0
    79
  if(chmod("Example.txt" , 0444) < 0 )  
sl@0
    80
  {
sl@0
    81
     printf("change mode of file Example.txt failed");
sl@0
    82
     return -1;
sl@0
    83
  }
sl@0
    84
  printf("Chmod system call successful");
sl@0
    85
  return 0;
sl@0
    86
}
sl@0
    87
sl@0
    88
@endcode
sl@0
    89
 Output
sl@0
    90
@code
sl@0
    91
Chmod system call successful
sl@0
    92
sl@0
    93
@endcode
sl@0
    94
@code
sl@0
    95
/* Detailed description : This sample code demonstrates the usage of fchmod system call, this code
sl@0
    96
 * changes mode of file Example.txt using fchmod system call.
sl@0
    97
 */
sl@0
    98
#include <sys/types.h>
sl@0
    99
#include <sys/stat.h>
sl@0
   100
#include <fcntl.h>
sl@0
   101
int main()
sl@0
   102
{
sl@0
   103
 int fd = 0;
sl@0
   104
 fd = open("Example.txt" , O_CREAT | O_RDWR , 0666);
sl@0
   105
 if(fd < 0 )   {
sl@0
   106
    printf("Failed to open file Example.txt");
sl@0
   107
    return -1;
sl@0
   108
 }
sl@0
   109
 if(fchmod(fd , 0444) < 0 )  {
sl@0
   110
    printf("fchmod failed to change mode of file Example.txt");
sl@0
   111
    return -1;
sl@0
   112
 }
sl@0
   113
 printf("Fchmod call changed mode of Example.txt");
sl@0
   114
 return 0;
sl@0
   115
}
sl@0
   116
sl@0
   117
@endcode
sl@0
   118
 Output
sl@0
   119
@code
sl@0
   120
Fchmod call changed mode of Example.txt
sl@0
   121
sl@0
   122
@endcode
sl@0
   123
sl@0
   124
Limitations:
sl@0
   125
sl@0
   126
KErrNotReady of Symbian error code is mapped to ENOENT, which typically means drive
sl@0
   127
not found or filesystem not mounted on the drive.
sl@0
   128
sl@0
   129
@see chmod()
sl@0
   130
@see chown()
sl@0
   131
@see open()
sl@0
   132
@see stat()
sl@0
   133
sl@0
   134
sl@0
   135
sl@0
   136
@capability Deferred @ref RFs::SetAtt(const TDesC16&, unsigned, unsigned)
sl@0
   137
sl@0
   138
@publishedAll
sl@0
   139
@externallyDefinedApi
sl@0
   140
*/
sl@0
   141
sl@0
   142
/** @fn  fchmod(int fd, mode_t _mode)
sl@0
   143
@param fd
sl@0
   144
@param _mode
sl@0
   145
sl@0
   146
Refer to  chmod() for the documentation
sl@0
   147
sl@0
   148
@see chmod()
sl@0
   149
@see chown()
sl@0
   150
@see open()
sl@0
   151
@see stat()
sl@0
   152
sl@0
   153
sl@0
   154
 
sl@0
   155
sl@0
   156
@publishedAll
sl@0
   157
@externallyDefinedApi
sl@0
   158
*/
sl@0
   159
sl@0
   160
/** @fn  fstat(int fd, struct stat *st)
sl@0
   161
@param fd
sl@0
   162
@param st
sl@0
   163
sl@0
   164
Refer to  stat() for the documentation
sl@0
   165
sl@0
   166
Notes:
sl@0
   167
sl@0
   168
If 'fd' refers to a shared memory object, the implementation updates only the st_uid, st_gid, st_size, 
sl@0
   169
and st_mode fields in the stat structure pointed to by the 'st' argument .
sl@0
   170
sl@0
   171
@see access()
sl@0
   172
@see chmod()
sl@0
   173
@see chown()
sl@0
   174
@see utimes()
sl@0
   175
@see symlink()
sl@0
   176
sl@0
   177
sl@0
   178
 
sl@0
   179
sl@0
   180
@publishedAll
sl@0
   181
@externallyDefinedApi
sl@0
   182
*/
sl@0
   183
sl@0
   184
/** @fn  fstat64(int fd, struct stat64 *st)
sl@0
   185
@param fd
sl@0
   186
@param st
sl@0
   187
sl@0
   188
For full documentation see: http://www.unix.org/version2/whatsnew/lfs20mar.html#3.0
sl@0
   189
sl@0
   190
@see fstat()
sl@0
   191
sl@0
   192
@publishedAll
sl@0
   193
@externallyDefinedApi
sl@0
   194
*/
sl@0
   195
sl@0
   196
sl@0
   197
/** @fn  lstat(const char *file_name, struct stat *buf)
sl@0
   198
@param file_name
sl@0
   199
@param buf
sl@0
   200
sl@0
   201
Refer to  stat() for the documentation
sl@0
   202
sl@0
   203
@see access()
sl@0
   204
@see chmod()
sl@0
   205
@see chown()
sl@0
   206
@see utimes()
sl@0
   207
@see symlink()
sl@0
   208
sl@0
   209
sl@0
   210
sl@0
   211
@capability Deferred @ref RFs::Entry(const TDesC16&, TEntry&)
sl@0
   212
sl@0
   213
@publishedAll
sl@0
   214
@externallyDefinedApi
sl@0
   215
*/
sl@0
   216
sl@0
   217
/** @fn  lstat64(const char *file_name, struct stat64 *buf)
sl@0
   218
@param file_name
sl@0
   219
@param buf
sl@0
   220
sl@0
   221
For full documentation see: http://www.unix.org/version2/whatsnew/lfs20mar.html#3.0
sl@0
   222
sl@0
   223
@see lstat()
sl@0
   224
sl@0
   225
@publishedAll
sl@0
   226
@externallyDefinedApi
sl@0
   227
*/
sl@0
   228
sl@0
   229
/** @fn  __xstat(int, const char *file, struct stat *buf)
sl@0
   230
@param file
sl@0
   231
@param buf
sl@0
   232
sl@0
   233
Refer to  stat() for the documentation
sl@0
   234
sl@0
   235
@see access()
sl@0
   236
@see chmod()
sl@0
   237
@see chown()
sl@0
   238
@see utimes()
sl@0
   239
@see symlink()
sl@0
   240
sl@0
   241
sl@0
   242
 
sl@0
   243
sl@0
   244
@publishedAll
sl@0
   245
@released
sl@0
   246
*/
sl@0
   247
sl@0
   248
/** @fn  __xstat64(int, const char *file, struct stat64 *buf)
sl@0
   249
@param file
sl@0
   250
@param buf
sl@0
   251
sl@0
   252
For full documentation see: http://www.unix.org/version2/whatsnew/lfs20mar.html#3.0
sl@0
   253
sl@0
   254
@see __xstat()
sl@0
   255
sl@0
   256
@publishedAll
sl@0
   257
@released
sl@0
   258
*/
sl@0
   259
sl@0
   260
/** @fn  __lxstat(int, const char *file, struct stat *buf)
sl@0
   261
@param file
sl@0
   262
@param buf
sl@0
   263
sl@0
   264
Refer to  stat() for the documentation
sl@0
   265
sl@0
   266
@see access()
sl@0
   267
@see chmod()
sl@0
   268
@see chown()
sl@0
   269
@see utimes()
sl@0
   270
@see symlink()
sl@0
   271
sl@0
   272
sl@0
   273
 
sl@0
   274
sl@0
   275
@publishedAll
sl@0
   276
@released
sl@0
   277
*/
sl@0
   278
sl@0
   279
/** @fn  __lxstat64(int, const char *file, struct stat64 *buf)
sl@0
   280
@param file
sl@0
   281
@param buf
sl@0
   282
sl@0
   283
For full documentation see: http://www.unix.org/version2/whatsnew/lfs20mar.html#3.0
sl@0
   284
sl@0
   285
@see __lxstat()
sl@0
   286
sl@0
   287
@publishedAll
sl@0
   288
@released
sl@0
   289
*/
sl@0
   290
sl@0
   291
sl@0
   292
/** @fn  mkdir(const char *_path, mode_t _mode)
sl@0
   293
@param _path
sl@0
   294
@param _mode
sl@0
   295
@return   The mkdir() function returns the value 0 if successful; otherwise the
sl@0
   296
value -1 is returned and the global variable errno is set to indicate the
sl@0
   297
error.
sl@0
   298
sl@0
   299
  The directory _path is created with the access permissions specified by _mode.
sl@0
   300
sl@0
   301
 Notes:
sl@0
   302
sl@0
   303
 _mode values and access permissions are ignored in Symbian OS.
sl@0
   304
sl@0
   305
 The default working directory of a process is initialized to C: \\private\\U ID 
sl@0
   306
  (UID of the calling application) and any data written into this directory persists between phone resets.
sl@0
   307
sl@0
   308
 The parent directory's time stamp is not updated when a new child is created.
sl@0
   309
sl@0
   310
 The newly created directory will be empty (i.e. it doesn't have "." and 
sl@0
   311
  ".." entries)
sl@0
   312
sl@0
   313
Examples:
sl@0
   314
@code
sl@0
   315
/* Detailed description : This test code demonstrates usage of mkdir systemcall,
sl@0
   316
 * it creates function a  directory Example in current working directory.
sl@0
   317
 */
sl@0
   318
int main()
sl@0
   319
{
sl@0
   320
  if(mkdir("Example" , 0666) < 0 )  
sl@0
   321
  {
sl@0
   322
      printf("Directory creation failed");
sl@0
   323
      return -1;
sl@0
   324
  }
sl@0
   325
  printf("Directory Example created");
sl@0
   326
  return 0;
sl@0
   327
}
sl@0
   328
sl@0
   329
@endcode
sl@0
   330
 Output
sl@0
   331
@code
sl@0
   332
Directory Example created
sl@0
   333
sl@0
   334
@endcode
sl@0
   335
sl@0
   336
Limitations:
sl@0
   337
sl@0
   338
The path parameter in mkdir() should not exceed 256 characters in length. 
sl@0
   339
sl@0
   340
KErrNotReady of Symbian error code is mapped to ENOENT, which typically means drive
sl@0
   341
not found or filesystem not mounted on the drive.
sl@0
   342
sl@0
   343
The path given to mkdir() should be complete. Attempting to create a directory my calling mkdir("logs",0400|0200|0100) 
sl@0
   344
will pass on emulator but fails on h/w because the cwd is taken as c:\private\uid3 on emulator and
sl@0
   345
z:\private\uid3 on h/w. Since Z drive is a rom on h/w, mkdir() fails by setting errno to 13 on hardware.
sl@0
   346
sl@0
   347
@see chmod()
sl@0
   348
@see stat()
sl@0
   349
@see umask()
sl@0
   350
sl@0
   351
sl@0
   352
sl@0
   353
@capability Deferred @ref RFs::MkDir(const TDesC16&)
sl@0
   354
sl@0
   355
@publishedAll
sl@0
   356
@externallyDefinedApi
sl@0
   357
*/
sl@0
   358
sl@0
   359
sl@0
   360
/** @fn  mkfifo(const char *pathname, mode_t mode)
sl@0
   361
@param pathname
sl@0
   362
@param mode
sl@0
   363
@return   The mkfifo function returns the value 0 if successful; otherwise the
sl@0
   364
value -1 is returned and errno is set to indicate the error.
sl@0
   365
sl@0
   366
  The mkfifo system call
sl@0
   367
creates a new FIFO(First In First Out) file with name path. The access permissions are
sl@0
   368
specified by mode and restricted by the umask of the calling process.
sl@0
   369
With the current implementation, the use of umask has no effect.
sl@0
   370
sl@0
   371
 The FIFO's owner ID and group ID are set to root.
sl@0
   372
sl@0
   373
 Please note that running stat on a FIFO file does not provide modification 
sl@0
   374
  time information (it provides the creation time). Use fstat on the fd to retrieve the last modified 
sl@0
   375
  time.
sl@0
   376
sl@0
   377
Examples:
sl@0
   378
@code
sl@0
   379
#include <sys/types.h>
sl@0
   380
#include <sys/stat.h>
sl@0
   381
#include <stdio.h>
sl@0
   382
sl@0
   383
int main(void)
sl@0
   384
{
sl@0
   385
    char *pathname = "C:\XXX";
sl@0
   386
    mode_t mode = 0666;
sl@0
   387
    if (mkfifo(pathname, mode) == -1) {
sl@0
   388
        printf("mkfifo() failed");
sl@0
   389
    }
sl@0
   390
    return 0;
sl@0
   391
}
sl@0
   392
sl@0
   393
@endcode
sl@0
   394
@see chmod()
sl@0
   395
@see stat()
sl@0
   396
@see umask()
sl@0
   397
sl@0
   398
Limitations:
sl@0
   399
sl@0
   400
KErrNotReady of Symbian error code is mapped to ENOENT, which typically means drive
sl@0
   401
not found or filesystem not mounted on the drive.
sl@0
   402
sl@0
   403
@capability Deferred @ref RFs::Delete(const TDesC16&)
sl@0
   404
sl@0
   405
@publishedAll
sl@0
   406
@externallyDefinedApi
sl@0
   407
*/
sl@0
   408
sl@0
   409
/** @fn  stat(const char *name, struct stat *st)
sl@0
   410
@param name
sl@0
   411
@param st
sl@0
   412
sl@0
   413
Note: This description also covers the following functions -
sl@0
   414
 lstat()  fstat()  __xstat()  __lxstat() 
sl@0
   415
sl@0
   416
@return   Upon successful completion, the value 0 is returned; otherwise the
sl@0
   417
value -1 is returned and the global variable errno is set to indicate the error.
sl@0
   418
sl@0
   419
@code
sl@0
   420
 st_dev The numeric ID of the device containing the file.
sl@0
   421
 st_ino The file's inode number.
sl@0
   422
 st_nlink
sl@0
   423
  The number of hard links to the file.
sl@0
   424
sl@0
   425
@endcode
sl@0
   426
@code
sl@0
   427
 st_atime Time when file data last accessed.
sl@0
   428
 Changed by the .Xr utimes 2, read and readv system calls.
sl@0
   429
 st_mtime Time when file data last modified.
sl@0
   430
 Changed by the mkdir, mkfifo, mknod, utimes, write and writev system calls.
sl@0
   431
 st_ctime Time when file status was last changed (inode data modification).
sl@0
   432
 Changed by the chmod, chown, creat, link, mkdir, mkfifo, mknod, rename, rmdir, symlink, truncate, unlink, utimes, write and writev system calls.
sl@0
   433
 st_birthtime
sl@0
   434
  Time when the inode was created.
sl@0
   435
sl@0
   436
@endcode
sl@0
   437
@code
sl@0
   438
 st_size The file size in bytes.
sl@0
   439
 st_blksize
sl@0
   440
  The optimal I/O block size for the file.
sl@0
   441
 st_blocks The actual number of blocks allocated for the file in 512-byte units.
sl@0
   442
 As short symbolic links are stored in the inode, this number may
sl@0
   443
 be zero.
sl@0
   444
sl@0
   445
@endcode
sl@0
   446
@code
sl@0
   447
 st_uid The user ID of the file's owner.
sl@0
   448
 st_gid The group ID of the file.
sl@0
   449
 st_mode
sl@0
   450
  Status of the file (see below).
sl@0
   451
sl@0
   452
@endcode
sl@0
   453
@code
sl@0
   454
 Test for a block special file.
sl@0
   455
 Test for a character special file.
sl@0
   456
 Test for a directory.
sl@0
   457
 Test for a pipe or FIFO special file.
sl@0
   458
 Test for a symbolic link. NOTE: Inode structure is not supported by Symbian OS and hence link count updation is not possible.
sl@0
   459
 Check for symbolic link would always fail because of this reason.
sl@0
   460
 Test for a regular file.
sl@0
   461
 Test for a socket.
sl@0
   462
 Test for a whiteout.
sl@0
   463
sl@0
   464
@endcode
sl@0
   465
  The stat system call obtains information about the file pointed to by path. Read, write or execute
sl@0
   466
permission of the named file is not required, but all directories
sl@0
   467
listed in the path name leading to the file must be searchable.
sl@0
   468
sl@0
   469
 The lstat system call is like stat except in the case where the named file is a symbolic link,
sl@0
   470
in which case lstat returns information about the link,
sl@0
   471
while stat returns information about the file the link references.
sl@0
   472
sl@0
   473
 The fstat system call obtains the same information about an open file
sl@0
   474
known by the file descriptor fd.
sl@0
   475
sl@0
   476
 The __xstat and __lxstat system calls are exactly similar to stat and lstat functionality.
sl@0
   477
sl@0
   478
 The sb argument is a pointer to a stat structure as defined by \#include \<sys/stat.h\> and into which information is 
sl@0
   479
  placed concerning the file.
sl@0
   480
sl@0
   481
 The fields of struct stat
sl@0
   482
related to the file system are as follows: 
sl@0
   483
sl@0
   484
@code
sl@0
   485
sl@0
   486
st_dev The numeric ID of the device containing the file. 
sl@0
   487
st_ino The file's inode number. 
sl@0
   488
st_nlink  The number of hard links to the file.
sl@0
   489
sl@0
   490
@endcode
sl@0
   491
sl@0
   492
 The st_dev and st_ino fields together identify the file uniquely within the system.
sl@0
   493
sl@0
   494
 The time-related fields of struct stat
sl@0
   495
are as follows: 
sl@0
   496
sl@0
   497
st_atime Time when file data last accessed.
sl@0
   498
Changed by the .Xr utimes 2, read and readv system calls. 
sl@0
   499
st_mtime Time when file data last modified.
sl@0
   500
Changed by the mkdir, mkfifo, mknod, utimes, write and writev system calls. 
sl@0
   501
st_ctime Time when file status was last changed (inode data modification).
sl@0
   502
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.
sl@0
   503
sl@0
   504
 If _POSIX_SOURCE is not defined, the time-related fields are defined as: 
sl@0
   505
sl@0
   506
@code
sl@0
   507
#ifndef _POSIX_SOURCE
sl@0
   508
#define st_atime st_atimespec.tv_sec
sl@0
   509
#define st_mtime st_mtimespec.tv_sec
sl@0
   510
#define st_ctime st_ctimespec.tv_sec
sl@0
   511
#endif
sl@0
   512
@endcode
sl@0
   513
sl@0
   514
 The size-related fields of the struct stat
sl@0
   515
are as follows: 
sl@0
   516
st_size The file size in bytes. 
sl@0
   517
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.
sl@0
   518
sl@0
   519
As short symbolic links are stored in the inode, this number may
sl@0
   520
be zero.
sl@0
   521
sl@0
   522
 The access-related fields of struct stat
sl@0
   523
are as follows: 
sl@0
   524
st_uid The user ID of the file's owner. 
sl@0
   525
st_gid The group ID of the file. 
sl@0
   526
st_mode  Status of the file (see below).
sl@0
   527
sl@0
   528
 The status information word st_mode has the following bits: 
sl@0
   529
@code
sl@0
   530
#define S_IFMT   0170000  // type of file
sl@0
   531
#define S_IFIFO  0010000  // named pipe (fifo) 
sl@0
   532
#define S_IFCHR  0020000  // character special 
sl@0
   533
#define S_IFDIR  0040000  // directory 
sl@0
   534
#define S_IFBLK  0060000  // block special 
sl@0
   535
#define S_IFREG  0100000  // regular 
sl@0
   536
#define S_IFLNK  0120000  // symbolic link 
sl@0
   537
#define S_IFSOCK 0140000  // socket 
sl@0
   538
#define S_IFWHT  0160000  // whiteout 
sl@0
   539
#define S_ISUID  0004000  // set user id on execution 
sl@0
   540
#define S_ISGID  0002000  // set group id on execution 
sl@0
   541
#define S_ISVTX  0001000  // save swapped text even after use 
sl@0
   542
#define S_IRUSR  0000400  // read permission, owner 
sl@0
   543
#define S_IWUSR  0000200  // write permission, owner 
sl@0
   544
#define S_IXUSR  0000100  // execute/search permission, owner 
sl@0
   545
@endcode
sl@0
   546
sl@0
   547
sl@0
   548
 For a list of access modes, see \#include \<sys/stat.h\> access and chmod The following macros are available to 
sl@0
   549
  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.
sl@0
   550
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.
sl@0
   551
sl@0
   552
 The macros evaluate to a non-zero value if the test is true
sl@0
   553
or to the value 0 if the test is false.
sl@0
   554
sl@0
   555
 Note: To obtain correct timestamps of FIFOs use fstat instead of stat call.
sl@0
   556
sl@0
   557
Examples:
sl@0
   558
@code
sl@0
   559
/* Detailed description: Sample usage of stat system call
sl@0
   560
 * Preconditions: Example.txt file should be present in working directory 
sl@0
   561
 */
sl@0
   562
#include <fcntl.h>
sl@0
   563
#include <unistd.h>
sl@0
   564
#include <sys/types.h>
sl@0
   565
#include <sys/stat.h>
sl@0
   566
int main()
sl@0
   567
{
sl@0
   568
  struct stat buf;
sl@0
   569
   if(stat("Example.txt"  , &buf;) < 0 )
sl@0
   570
   {
sl@0
   571
      printf("Failed to stat Example.txt");
sl@0
   572
      return -1;
sl@0
   573
   }
sl@0
   574
   printf("Stat system call succeeded");
sl@0
   575
   return 0;
sl@0
   576
 }
sl@0
   577
/*
sl@0
   578
 * Detailed description: Sample usage of fstat system call
sl@0
   579
 *
sl@0
   580
 */
sl@0
   581
#include <fcntl.h>
sl@0
   582
#include <unistd.h>
sl@0
   583
#include <sys/types.h>
sl@0
   584
#include <sys/stat.h>
sl@0
   585
int main()
sl@0
   586
{
sl@0
   587
  struct stat buf;
sl@0
   588
   int fd = open("Example.txt" , O_RDONLY | O_CREAT  , 0666);
sl@0
   589
   if(fstat(fd  , &buf;) < 0 ) 
sl@0
   590
   {
sl@0
   591
      printf("Failed to stat Example.txt");
sl@0
   592
      return -1;
sl@0
   593
   }
sl@0
   594
   printf("Stat system call succeeded");
sl@0
   595
   close(fd);
sl@0
   596
   return 0;
sl@0
   597
 }
sl@0
   598
sl@0
   599
@endcode
sl@0
   600
 Output
sl@0
   601
@code
sl@0
   602
Stat system call succeeded
sl@0
   603
sl@0
   604
@endcode
sl@0
   605
 Output
sl@0
   606
@code
sl@0
   607
Stat system call succeeded
sl@0
   608
sl@0
   609
@endcode
sl@0
   610
sl@0
   611
Limitations:
sl@0
   612
sl@0
   613
The path parameters of the stat() and lstat() functions should not exceed 256 characters each in length. 
sl@0
   614
sl@0
   615
KErrNotReady of Symbian error code is mapped to ENOENT, which typically means drive
sl@0
   616
not found or filesystem not mounted on the drive.
sl@0
   617
sl@0
   618
@see access()
sl@0
   619
@see chmod()
sl@0
   620
@see chown()
sl@0
   621
@see utimes()
sl@0
   622
@see symlink()
sl@0
   623
sl@0
   624
sl@0
   625
sl@0
   626
@capability Deferred @ref RFs::Entry(const TDesC16&, TEntry&)
sl@0
   627
sl@0
   628
@publishedAll
sl@0
   629
@externallyDefinedApi
sl@0
   630
*/
sl@0
   631
sl@0
   632
/** @fn  stat64(const char *name, struct stat64 *st)
sl@0
   633
@param name
sl@0
   634
@param st
sl@0
   635
@return   Upon successful completion, the value 0 is returned; otherwise the
sl@0
   636
value -1 is returned and the global variable errno is set to indicate the error.
sl@0
   637
sl@0
   638
For full documentation see: http://www.unix.org/version2/whatsnew/lfs20mar.html#3.0
sl@0
   639
sl@0
   640
@see stat()
sl@0
   641
sl@0
   642
@publishedAll
sl@0
   643
@externallyDefinedApi
sl@0
   644
*/
sl@0
   645
sl@0
   646
/** @fn  umask(mode_t cmask)
sl@0
   647
@param cmask
sl@0
   648
@return   This function always returns MASK_RWUSR.
sl@0
   649
sl@0
   650
  This function is build supported but not available functionally. Symbian 
sl@0
   651
OS does not support multiple users and groups
sl@0
   652
sl@0
   653
sl@0
   654
sl@0
   655
 
sl@0
   656
sl@0
   657
@publishedAll
sl@0
   658
@externallyDefinedApi
sl@0
   659
*/
sl@0
   660
sl@0
   661
sl@0
   662
/** @struct stat 
sl@0
   663
sl@0
   664
This structure provides detailed information about a file. The information returned depends on the type of file and/or the file system on which the file resides.
sl@0
   665
Includes following members,
sl@0
   666
sl@0
   667
@publishedAll
sl@0
   668
@externallyDefinedApi
sl@0
   669
*/
sl@0
   670
sl@0
   671
/** @var stat::st_dev
sl@0
   672
inode's device
sl@0
   673
*/
sl@0
   674
sl@0
   675
/** @var stat::st_ino
sl@0
   676
inode's number
sl@0
   677
*/
sl@0
   678
sl@0
   679
/** @var stat::st_mode
sl@0
   680
inode protection mode
sl@0
   681
*/
sl@0
   682
sl@0
   683
/** @var stat::st_nlink
sl@0
   684
number of hard links
sl@0
   685
*/
sl@0
   686
sl@0
   687
/** @var stat::st_uid
sl@0
   688
user ID of the file's owner
sl@0
   689
*/
sl@0
   690
sl@0
   691
/** @var stat::st_gid
sl@0
   692
group ID of the file's group
sl@0
   693
*/
sl@0
   694
sl@0
   695
/** @var stat::st_rdev
sl@0
   696
device type
sl@0
   697
*/
sl@0
   698
sl@0
   699
/** @var stat::st_atimespec
sl@0
   700
time of last access
sl@0
   701
*/
sl@0
   702
sl@0
   703
/** @var stat::st_mtimespec
sl@0
   704
time of last data modification
sl@0
   705
*/
sl@0
   706
sl@0
   707
/** @var stat::st_ctimespec
sl@0
   708
time of last file status change
sl@0
   709
*/
sl@0
   710
sl@0
   711
/** @var stat::st_size
sl@0
   712
file size, in bytes
sl@0
   713
*/
sl@0
   714
sl@0
   715
/** @var stat::st_blocks
sl@0
   716
blocks allocated for file 
sl@0
   717
*/
sl@0
   718
sl@0
   719
/** @var stat::st_blksize
sl@0
   720
optimal blocksize for IO
sl@0
   721
*/
sl@0
   722
sl@0
   723
/** @var stat::st_flags
sl@0
   724
user defined flags for file
sl@0
   725
*/
sl@0
   726
sl@0
   727
/** @var stat::st_gen
sl@0
   728
file generation number
sl@0
   729
*/
sl@0
   730
sl@0
   731
/** @struct stat64 
sl@0
   732
sl@0
   733
The stat64 structure is similar to the stat structure, except that it is capable of returning information about files that are larger than 2 gigabytes.
sl@0
   734
This structure provides detailed information about a file. The information returned depends on the type of file and/or the file system on which the file resides.
sl@0
   735
Includes following members,
sl@0
   736
sl@0
   737
@publishedAll
sl@0
   738
@externallyDefinedApi
sl@0
   739
*/
sl@0
   740
sl@0
   741
/** @var stat64::st_dev
sl@0
   742
inode's device
sl@0
   743
*/
sl@0
   744
sl@0
   745
/** @var stat64::st_ino
sl@0
   746
inode's number
sl@0
   747
*/
sl@0
   748
sl@0
   749
/** @var stat64::st_mode
sl@0
   750
inode protection mode
sl@0
   751
*/
sl@0
   752
sl@0
   753
/** @var stat64::st_nlink
sl@0
   754
number of hard links
sl@0
   755
*/
sl@0
   756
sl@0
   757
/** @var stat64::st_uid
sl@0
   758
user ID of the file's owner
sl@0
   759
*/
sl@0
   760
sl@0
   761
/** @var stat64::st_gid
sl@0
   762
group ID of the file's group
sl@0
   763
*/
sl@0
   764
sl@0
   765
/** @var stat64::st_rdev
sl@0
   766
device type
sl@0
   767
*/
sl@0
   768
sl@0
   769
/** @var stat64::st_atimespec
sl@0
   770
time of last access
sl@0
   771
*/
sl@0
   772
sl@0
   773
/** @var stat64::st_mtimespec
sl@0
   774
time of last data modification
sl@0
   775
*/
sl@0
   776
sl@0
   777
/** @var stat64::st_ctimespec
sl@0
   778
time of last file status change
sl@0
   779
*/
sl@0
   780
sl@0
   781
/** @var stat64::st_size
sl@0
   782
file size, in bytes
sl@0
   783
*/
sl@0
   784
sl@0
   785
/** @var stat64::st_blocks
sl@0
   786
blocks allocated for file 
sl@0
   787
*/
sl@0
   788
sl@0
   789
/** @var stat64::st_blksize
sl@0
   790
optimal blocksize for IO
sl@0
   791
*/
sl@0
   792
sl@0
   793
/** @var stat64::st_flags
sl@0
   794
user defined flags for file
sl@0
   795
*/
sl@0
   796
sl@0
   797
/** @var stat64::st_gen
sl@0
   798
file generation number
sl@0
   799
*/
sl@0
   800
sl@0
   801
sl@0
   802
/** @def S_IRWXU	
sl@0
   803
sl@0
   804
RWX mask for owner
sl@0
   805
sl@0
   806
@publishedAll
sl@0
   807
@externallyDefinedApi
sl@0
   808
*/
sl@0
   809
sl@0
   810
/** @def S_IRUSR
sl@0
   811
sl@0
   812
R for owner
sl@0
   813
sl@0
   814
@publishedAll
sl@0
   815
@externallyDefinedApi
sl@0
   816
*/
sl@0
   817
sl@0
   818
/** @def S_IWUSR
sl@0
   819
sl@0
   820
W for owner
sl@0
   821
sl@0
   822
@publishedAll
sl@0
   823
@externallyDefinedApi
sl@0
   824
*/
sl@0
   825
sl@0
   826
/** @def S_IXUSR
sl@0
   827
sl@0
   828
X for owner
sl@0
   829
sl@0
   830
@publishedAll
sl@0
   831
@externallyDefinedApi
sl@0
   832
*/
sl@0
   833
sl@0
   834
sl@0
   835
/** @def S_IFMT
sl@0
   836
sl@0
   837
type of file mask
sl@0
   838
sl@0
   839
@publishedAll
sl@0
   840
@externallyDefinedApi
sl@0
   841
*/
sl@0
   842
sl@0
   843
/** @def S_IFIFO
sl@0
   844
sl@0
   845
named pipe (fifo)
sl@0
   846
sl@0
   847
@publishedAll
sl@0
   848
@externallyDefinedApi
sl@0
   849
*/
sl@0
   850
sl@0
   851
/** @def S_IFCHR
sl@0
   852
sl@0
   853
character special 
sl@0
   854
sl@0
   855
@publishedAll
sl@0
   856
@externallyDefinedApi
sl@0
   857
*/
sl@0
   858
sl@0
   859
/** @def S_IFDIR
sl@0
   860
sl@0
   861
directory
sl@0
   862
sl@0
   863
@publishedAll
sl@0
   864
@externallyDefinedApi
sl@0
   865
*/
sl@0
   866
sl@0
   867
/** @def S_IFBLK
sl@0
   868
sl@0
   869
block special
sl@0
   870
sl@0
   871
@publishedAll
sl@0
   872
@externallyDefinedApi
sl@0
   873
*/
sl@0
   874
sl@0
   875
/** @def S_IFREG	
sl@0
   876
sl@0
   877
regular
sl@0
   878
sl@0
   879
@publishedAll
sl@0
   880
@externallyDefinedApi
sl@0
   881
*/
sl@0
   882
sl@0
   883
/** @def S_IFLNK
sl@0
   884
sl@0
   885
symbolic link 
sl@0
   886
sl@0
   887
@publishedAll
sl@0
   888
@externallyDefinedApi
sl@0
   889
*/
sl@0
   890
sl@0
   891
/** @def S_ISDIR(m)
sl@0
   892
sl@0
   893
directory.
sl@0
   894
sl@0
   895
@publishedAll
sl@0
   896
@externallyDefinedApi
sl@0
   897
*/
sl@0
   898
sl@0
   899
/** @def S_ISCHR(m)
sl@0
   900
sl@0
   901
char special.
sl@0
   902
sl@0
   903
@publishedAll
sl@0
   904
@externallyDefinedApi
sl@0
   905
*/
sl@0
   906
sl@0
   907
/** @def S_ISLNK(m)
sl@0
   908
sl@0
   909
symbolic link
sl@0
   910
sl@0
   911
@publishedAll
sl@0
   912
@externallyDefinedApi
sl@0
   913
*/
sl@0
   914
sl@0
   915
/** @def S_ISBLK(m)
sl@0
   916
sl@0
   917
block special
sl@0
   918
sl@0
   919
@publishedAll
sl@0
   920
@externallyDefinedApi
sl@0
   921
*/
sl@0
   922
sl@0
   923
/** @def S_ISREG(m)
sl@0
   924
sl@0
   925
regular file 
sl@0
   926
sl@0
   927
@publishedAll
sl@0
   928
@externallyDefinedApi
sl@0
   929
*/
sl@0
   930
sl@0
   931
/** @def S_ISFIFO(m)
sl@0
   932
sl@0
   933
fifo or socket
sl@0
   934
sl@0
   935
@publishedAll
sl@0
   936
@externallyDefinedApi
sl@0
   937
*/
sl@0
   938
sl@0
   939
/** @def S_ISUID
sl@0
   940
sl@0
   941
set user id on execution
sl@0
   942
sl@0
   943
@publishedAll
sl@0
   944
@externallyDefinedApi
sl@0
   945
*/
sl@0
   946
sl@0
   947
/** @def S_ISGID
sl@0
   948
sl@0
   949
set group id on execution
sl@0
   950
sl@0
   951
@publishedAll
sl@0
   952
@externallyDefinedApi
sl@0
   953
*/
sl@0
   954
sl@0
   955
/** @def S_IRWXG
sl@0
   956
sl@0
   957
RWX mask for group
sl@0
   958
sl@0
   959
@publishedAll
sl@0
   960
@externallyDefinedApi
sl@0
   961
*/
sl@0
   962
sl@0
   963
/** @def S_IRGRP
sl@0
   964
sl@0
   965
R for group
sl@0
   966
sl@0
   967
@publishedAll
sl@0
   968
@externallyDefinedApi
sl@0
   969
*/
sl@0
   970
sl@0
   971
sl@0
   972
/** @def S_IWGRP
sl@0
   973
sl@0
   974
W for group
sl@0
   975
sl@0
   976
@publishedAll
sl@0
   977
@externallyDefinedApi
sl@0
   978
*/
sl@0
   979
sl@0
   980
sl@0
   981
/** @def S_IXGRP
sl@0
   982
sl@0
   983
X for group
sl@0
   984
sl@0
   985
@publishedAll
sl@0
   986
@externallyDefinedApi
sl@0
   987
*/
sl@0
   988
sl@0
   989
/** @def S_IRWXO
sl@0
   990
sl@0
   991
RWX mask for other
sl@0
   992
sl@0
   993
@publishedAll
sl@0
   994
@externallyDefinedApi
sl@0
   995
*/
sl@0
   996
sl@0
   997
sl@0
   998
/** @def S_IROTH
sl@0
   999
sl@0
  1000
R for other
sl@0
  1001
sl@0
  1002
@publishedAll
sl@0
  1003
@externallyDefinedApi
sl@0
  1004
*/
sl@0
  1005
sl@0
  1006
sl@0
  1007
/** @def S_IWOTH
sl@0
  1008
sl@0
  1009
W for other
sl@0
  1010
sl@0
  1011
@publishedAll
sl@0
  1012
@externallyDefinedApi
sl@0
  1013
*/
sl@0
  1014
sl@0
  1015
sl@0
  1016
/** @def S_IXOTH
sl@0
  1017
sl@0
  1018
X for other
sl@0
  1019
sl@0
  1020
@publishedAll
sl@0
  1021
@externallyDefinedApi
sl@0
  1022
*/
sl@0
  1023
sl@0
  1024
/** @def S_ISVTX
sl@0
  1025
sl@0
  1026
save swapped text even after use 
sl@0
  1027
sl@0
  1028
@publishedAll
sl@0
  1029
@externallyDefinedApi
sl@0
  1030
*/
sl@0
  1031
sl@0
  1032
sl@0
  1033
sl@0
  1034