stop initial building
echo 1 >/sys/block/md128/md/skip_md_resync
__mode_t的定义:
#define __mode_t __MODE_T_TYPE#define __MODE_T_TYPE __U32_TYPE
#define __U32_TYPE unsigned int
#include <sys/stat.h>
#include <fcntl.h>
#include "tlpi_hdr.h"
#ifndef BUF_SIZE /* Allow "cc -D" to override definition */
#define BUF_SIZE 1024
#endif
int
main(int argc, char *argv[])
{
int inputFd, outputFd, openFlags;
mode_t filePerms;
ssize_t numRead;
char buf[BUF_SIZE];
if (argc != 3 || strcmp(argv[1], "--help") == 0)
usageErr("%s old-file new-file\n", argv[0]);
/* Open input and output files */
inputFd = open(argv[1], O_RDONLY);
if (inputFd == -1)
errExit("opening file %s", argv[1]);
openFlags = O_CREAT | O_WRONLY | O_TRUNC;
filePerms = S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP |
S_IROTH | S_IWOTH; /* rw-rw-rw- */
outputFd = open(argv[2], openFlags, filePerms);
if (outputFd == -1)
errExit("opening file %s", argv[2]);
/* Transfer data until we encounter end of input or an error */
while ((numRead = read(inputFd, buf, BUF_SIZE)) > 0)
if (write(outputFd, buf, numRead) != numRead)
fatal("couldn't write whole buffer");
if (numRead == -1)
errExit("read");
if (close(inputFd) == -1)
errExit("close input");
if (close(outputFd) == -1)
errExit("close output");
exit(EXIT_SUCCESS);
}
read函数(读取文件)
read函数可以读取文件。读取文件指从某一个已打开地文件中,读取一定数量地字符,然后将这些读取的字符放入某一个预存的缓冲区内,供以后使用。
使用格式如下:
number = read(handle, buffer ,n) ;
上述read调用函数中,各个参数的定义如下:
handle: 这是一个已经打开的文件句柄,表示从这个文件句柄所代表的文件读取数据。
buffer: 指缓冲区,即读取的数据会被放到这个缓冲区中去。
n: 表示调用一次read操作,应该读多少数量的字符。
number:表示系统实际所读取的字符数量。
#include <unistd.h>
ssize_t write(int fd, const void *buf, size_t count);
参数:
fd:要进行写操作的文件描述词。
buf:需要输出的缓冲区
count:最大输出字节计数
rpm -q python
which whereis locate
linux系统管理技术手册1.10推荐读物