Chinaunix首页 | 论坛 | 博客
  • 博客访问: 344953
  • 博文数量: 92
  • 博客积分: 2500
  • 博客等级: 少校
  • 技术积分: 960
  • 用 户 组: 普通用户
  • 注册时间: 2009-08-21 19:38
文章分类

全部博文(92)

文章存档

2010年(71)

2009年(21)

我的朋友

分类: 嵌入式

2009-09-02 19:47:30

Reference: "Embedded Linux, C-language programming practice"

1. File I / O operations functions

   * open function: open file
          int open (const char * pathname, int flags)

   * close function: close file

   * read function: read the file
          ssize_t read (int_fd, void * buf, size_t count)
            transfer bytes of count number into point buf
         

   * write function: write file
          ssize_t write (int fd, const void * buf, size_t count)
          write bytes of count number into file(fd) with beginning of point buf in the memory

   * lseek Function: File Positioning
          off_t lseek (int fildes, off_t offset, int whence);
          retuen the current position of reading and writing

   * flock function: lock file
          int flock (int fd, int operation)

   * mmap function and munmap functions: memory-mapped
          int munmap (void * start, size_t length)
         map the contents of a file into memory, to write or read this memory region is the direct access to to the content of the document.

   * create a function: to create a new file
          int create (const char * pathname, mode_t mode)

   * fcntl function: to change the file attributes which has been opened

          int fcntl (int fields, int cmd, int arg)
          If success,return the implementation of the new descriptor, otherwise returns -1

2. the function of related file permissions

   * access functions: to determine whether access to the file permissions
          int access (const char * pathname, int mode)
          if (0 == access (argv [1], W_OK)) R_OK X_OK F_OK

   * chown function and fchown function: to change the file owner of the
          int fchown (int fd, uid_t owner, gid_t group)

   * chmod function and fchmod function: to change the permissions
         int fchmod (int fildes, mode_t mode)

   * unlink function: delete the file

3. User group manipulation functions

   * getegid function and setegid function: get / set the effective group ID
         gid_t gete (gid_t egid)

   * geteuid function and seteuid function: get / set the real user ID

         uid_t getuid (void)

  4. Signaling Function

    * kill function: to send a signal to the specified process

         int kill (pid_t pid, int sig)

    * rais function: signaling

         int raise (int sig)

    * alarm function: Set the timer

         unsigned int alarm (unsigned int seconds)

    * signal function: Signal Installation Function
         sighandler_t signal (int signum, sighandler_t handler)

5. The process of dealing with the function

    * getpid function and getppid function: to obtain the process ID and the parent process ID
         pid_t getpid (void)
         pid_t getppid (void)

    * fork function: the establishment of child process
         pid_t fork (void)
         The parent process has been the return value is the child process ID, while the child process returns 0

    * sleep function: Let the process was suspended for a period of time
         unsigned int sleep (unsigned int seconds)

    * exec function: find the executable file

    * _exit function: the end of the process of implementation of the
阅读(1094) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~