Форум программистов, компьютерный форум, киберфорум
С++ для начинающих
Войти
Регистрация
Восстановить пароль
Карта форума Темы раздела Блоги Сообщество Поиск Заказать работу  
 
Рейтинг 4.66/35: Рейтинг темы: голосов - 35, средняя оценка - 4.66
0 / 0 / 0
Регистрация: 04.04.2010
Сообщений: 22
1

Для чего подключаются sys/stat.h?

29.08.2012, 10:25. Показов 6532. Ответов 4
Метки нет (Все метки)

Author24 — интернет-сервис помощи студентам
для чего мы его подключаем?
0
Programming
Эксперт
94731 / 64177 / 26122
Регистрация: 12.04.2006
Сообщений: 116,782
29.08.2012, 10:25
Ответы с готовыми решениями:

Для чего нужно писать в int main() в скобках всякие args потом объявлять переменные, и прочее. Для чего если можно в сборках это все обьявлять.
Для чего нужно писать в int main() в скобках всякие args потом объявлять переменные, и прочее. Для...

SEG_FAULT при проверка struct stat* из <sys/stat.h>
#include &lt;stdio.h&gt; #include &lt;string.h&gt; #include &lt;dirent.h&gt; // opendir, closedir, readdir,...

Не подключаются USB устройства . Ошибка iusb3xhc.sys
Доброго времени суток! Подскажите кто сталкивался с такой ошибкой, при подключении любого USB...

Swapfile.sys Что это такое и для чего оно?
Я считаю что этот файл занимает много места. Реально ли удалить. Я знаю как уменьшить...

4
Псевдослучайный
1946 / 1145 / 98
Регистрация: 13.09.2011
Сообщений: 3,215
29.08.2012, 10:34 2
Откуда нам знать, зачем вы его подключаете? Закомментируйте строку с включением и посмотрите, что на это скажет компилятор.
0
5231 / 3204 / 362
Регистрация: 12.12.2009
Сообщений: 8,116
Записей в блоге: 2
29.08.2012, 12:25 3
man stat.h
<sys/stat.h>(0P) POSIX Programmer's Manual <sys/stat.h>(0P)



NAME
sys/stat.h - data returned by the stat() function

SYNOPSIS
#include <sys/stat.h>

DESCRIPTION
The <sys/stat.h> header shall define the structure of the data returned by the functions fstat(), lstat(), and stat().

The stat structure shall contain at least the following members:


dev_t st_dev Device ID of device containing file.
ino_t st_ino File serial number.
mode_t st_mode Mode of file (see below).
nlink_t st_nlink Number of hard links to the file.
uid_t st_uid User ID of file.
gid_t st_gid Group ID of file.

dev_t st_rdev Device ID (if file is character or block special).

off_t st_size For regular files, the file size in bytes.
For symbolic links, the length in bytes of the
pathname contained in the symbolic link.

For a shared memory object, the length in bytes.


For a typed memory object, the length in bytes.

For other file types, the use of this field is
unspecified.
time_t st_atime Time of last access.
time_t st_mtime Time of last data modification.
time_t st_ctime Time of last status change.

blksize_t st_blksize A file system-specific preferred I/O block size for
this object. In some file system types, this may
vary from file to file.
blkcnt_t st_blocks Number of blocks allocated for this object.


The st_ino and st_dev fields taken together uniquely identify the file within the system. The blkcnt_t, blksize_t, dev_t, ino_t, mode_t,
nlink_t, uid_t, gid_t, off_t, and time_t types shall be defined as described in <sys/types.h> . Times shall be given in seconds since the
Epoch.

Unless otherwise specified, the structure members st_mode, st_ino, st_dev, st_uid, st_gid, st_atime, st_ctime, and st_mtime shall have mean‐
ingful values for all file types defined in IEEE Std 1003.1-2001.

For symbolic links, the st_mode member shall contain meaningful information, which can be used with the file type macros described below,
that take a mode argument. The st_size member shall contain the length, in bytes, of the pathname contained in the symbolic link. File mode
bits and the contents of the remaining members of the stat structure are unspecified. The value returned in the st_size field shall be the
length of the contents of the symbolic link, and shall not count a trailing null if one is present.

The following symbolic names for the values of type mode_t shall also be defined.

File type:

S_IFMT Type of file.

S_IFBLK
Block special.

S_IFCHR
Character special.

S_IFIFO
FIFO special.

S_IFREG
Regular.

S_IFDIR
Directory.

S_IFLNK
Symbolic link.

S_IFSOCK
Socket.



File mode bits:

S_IRWXU
Read, write, execute/search by owner.

S_IRUSR
Read permission, owner.

S_IWUSR
Write permission, owner.

S_IXUSR
Execute/search permission, owner.


S_IRWXG
Read, write, execute/search by group.

S_IRGRP
Read permission, group.

S_IWGRP
Write permission, group.

S_IXGRP
Execute/search permission, group.


S_IRWXO
Read, write, execute/search by others.

S_IROTH
Read permission, others.

S_IWOTH
Write permission, others.

S_IXOTH
Execute/search permission, others.


S_ISUID
Set-user-ID on execution.

S_ISGID
Set-group-ID on execution.

S_ISVTX
On directories, restricted deletion flag.


The bits defined by S_IRUSR, S_IWUSR, S_IXUSR, S_IRGRP, S_IWGRP, S_IXGRP, S_IROTH, S_IWOTH, S_IXOTH, S_ISUID, S_ISGID, and S_ISVTX shall be
unique.

S_IRWXU is the bitwise-inclusive OR of S_IRUSR, S_IWUSR, and S_IXUSR.

S_IRWXG is the bitwise-inclusive OR of S_IRGRP, S_IWGRP, and S_IXGRP.

S_IRWXO is the bitwise-inclusive OR of S_IROTH, S_IWOTH, and S_IXOTH.

Implementations may OR other implementation-defined bits into S_IRWXU, S_IRWXG, and S_IRWXO, but they shall not overlap any of the other bits
defined in this volume of IEEE Std 1003.1-2001. The file permission bits are defined to be those corresponding to the bitwise-inclusive OR of
S_IRWXU, S_IRWXG, and S_IRWXO.

The following macros shall be provided to test whether a file is of the specified type. The value m supplied to the macros is the value of
st_mode from a stat structure. The macro shall evaluate to a non-zero value if the test is true; 0 if the test is false.

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_ISREG(m)
Test for a regular file.

S_ISLNK(m)
Test for a symbolic link.

S_ISSOCK(m)
Test for a socket.


The implementation may implement message queues, semaphores, or shared memory objects as distinct file types. The following macros shall be
provided to test whether a file is of the specified type. The value of the buf argument supplied to the macros is a pointer to a stat struc‐
ture. The macro shall evaluate to a non-zero value if the specified object is implemented as a distinct file type and the specified file type
is contained in the stat structure referenced by buf. Otherwise, the macro shall evaluate to zero.

S_TYPEISMQ(buf)
Test for a message queue.

S_TYPEISSEM(buf)
Test for a semaphore.

S_TYPEISSHM(buf)
Test for a shared memory object.


The implementation may implement typed memory objects as distinct file types, and the following macro shall test whether a file is of the
specified type. The value of the buf argument supplied to the macros is a pointer to a stat structure. The macro shall evaluate to a non-
zero value if the specified object is implemented as a distinct file type and the specified file type is contained in the stat structure ref‐
erenced by buf. Otherwise, the macro shall evaluate to zero.

S_TYPEISTMO(buf)
Test macro for a typed memory object.


The following shall be declared as functions and may also be defined as macros. Function prototypes shall be provided.


int chmod(const char *, mode_t);
int fchmod(int, mode_t);
int fstat(int, struct stat *);
int lstat(const char *restrict, struct stat *restrict);
int mkdir(const char *, mode_t);
int mkfifo(const char *, mode_t);

int mknod(const char *, mode_t, dev_t);

int stat(const char *restrict, struct stat *restrict);
mode_t umask(mode_t);

The following sections are informative.

APPLICATION USAGE
Use of the macros is recommended for determining the type of a file.

RATIONALE
A conforming C-language application must include <sys/stat.h> for functions that have arguments or return values of type mode_t, so that sym‐
bolic values for that type can be used. An alternative would be to require that these constants are also defined by including <sys/types.h>.

The S_ISUID and S_ISGID bits may be cleared on any write, not just on open(), as some historical implementations do.

System calls that update the time entry fields in the stat structure must be documented by the implementors. POSIX-conforming systems should
not update the time entry fields for functions listed in the System Interfaces volume of IEEE Std 1003.1-2001 unless the standard requires
that they do, except in the case of documented extensions to the standard.

Note that st_dev must be unique within a Local Area Network (LAN) in a ``system'' made up of multiple computers' file systems connected by a
LAN.

Networked implementations of a POSIX-conforming system must guarantee that all files visible within the file tree (including parts of the
tree that may be remotely mounted from other machines on the network) on each individual processor are uniquely identified by the combination
of the st_ino and st_dev fields.

The unit for the st_blocks member of the stat structure is not defined within IEEE Std 1003.1-2001. In some implementations it is 512 bytes.
It may differ on a file system basis. There is no correlation between values of the st_blocks and st_blksize, and the f_bsize (from
<sys/statvfs.h>) structure members.

Traditionally, some implementations defined the multiplier for st_blocks in <sys/param.h> as the symbol DEV_BSIZE.

FUTURE DIRECTIONS
No new S_IFMT symbolic names for the file type values of mode_t will be defined by IEEE Std 1003.1-2001; if new file types are required, they
will only be testable through S_ISxx() or S_TYPEISxxx() macros instead.

SEE ALSO
<sys/statvfs.h>, <sys/types.h>, the System Interfaces volume of IEEE Std 1003.1-2001, chmod(), fchmod(), fstat(), lstat(), mkdir(), mkfifo(),
mknod(), stat(), umask()

COPYRIGHT
Portions of this text are reprinted and reproduced in electronic form from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
-- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of Elec‐
trical and Electronics Engineers, Inc and The Open Group. In the event of any discrepancy between this version and the original IEEE and The
Open Group Standard, the original IEEE and The Open Group Standard is the referee document. The original Standard can be obtained online at
http://www.opengroup.org/unix/online.html .



IEEE/The Open Group 2003 <sys/stat.h>(0P)
0
599 / 237 / 69
Регистрация: 08.08.2015
Сообщений: 1,637
21.10.2015, 14:28 4
Расскажите разницу между флагами st_mode &S_IFMT и st_mode &S_IFREG а то уже 3 раз перечитываю не въеду!
0
89 / 77 / 38
Регистрация: 11.10.2015
Сообщений: 860
21.04.2018, 15:35 5
Привет ребята! Столкнулся с такой проблемой -
newlib_stubs.c(4): error: #5: cannot open source input file "sys/stat.h": No such file or directory
В проекте используется The Red Hat newlib C Library (не знаю зачем). При построении ругается. Похоже что отсутствует
C++
1
sys/stat.h
, можете сказать что это за библиотека и где ее можно достать?
0
21.04.2018, 15:35
IT_Exp
Эксперт
87844 / 49110 / 22898
Регистрация: 17.06.2006
Сообщений: 92,604
21.04.2018, 15:35
Помогаю со студенческими работами здесь

nvlddmkm.sys, dxgkrnl.sys, dxgmms1.sys, ntoskrnl.exe, watchdog.sys
Здравствуйте! У меня такая проблема компьютер стоит 3 года в последние дни 19 июля оставил игру...

MSI GTX 970 4GD5T OC Nvlddmkm.sys, dxgkrnl.sys и dxgmms1.sys
Всем привет! Видеокарта MSI GTX 970 4GD5T OC. Windows 7 x64. В последнее время стала очень часто...

BSOD 0x116 dxgkrnl.sys + dxgmms1.sys + nvlddmkm.sys
Добрый день! Столкнулся сегодня с таким BSOD. Пока что было всего 2 раза,утром,вовремя старта...

BSoD nvlddmkm.sys dxgmms1.sys dxgkrnl.sys
При обновлении дров видяхи после ребута бсод, иногда даже рабочий стол не прогружает, монитор...


Искать еще темы с ответами

Или воспользуйтесь поиском по форуму:
5
Ответ Создать тему
КиберФорум - форум программистов, компьютерный форум, программирование
Powered by vBulletin
Copyright ©2000 - 2024, CyberForum.ru