小编Ste*_*Ste的帖子

如何使用CAP_SYS_ADMIN

有人可以向我解释如何在c中使用或设置CAP_SYS_ADMIN吗?我需要这种能力来卸载USB驱动器但不知道如何使用它.

c linux-capabilities

7
推荐指数
1
解决办法
7699
查看次数

sendfile64只复制约2GB

我需要使用sendfile64来复制大约16GB的文件.到目前为止我取得的成就是

#include <unistd.h>
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <fcntl.h>
#include <stdlib.h>
#include <sys/sendfile.h>
#include <sys/stat.h>

int main (int argc, char** argv)
{
  long long src;
  long long dest;
  struct stat64 stat_buf;
  off64_t offset = 0LL;
  long long rc;

  if (argc != 3) {
    fprintf(stderr, "usage: %s <source> <destination>\n", argv[0]);
    exit(1);
  }

  src = open64(argv[1], O_RDONLY);
  if (src == -1) {
    fprintf(stderr, "unable to open '%s': %s\n", argv[1], strerror(errno));
    exit(1);
  }

  fstat64(src, &stat_buf);

  dest = open64(argv[2], O_WRONLY|O_CREAT, stat_buf.st_mode);
  if …
Run Code Online (Sandbox Code Playgroud)

c c++ linux sendfile

5
推荐指数
1
解决办法
1076
查看次数

标签 统计

c ×2

c++ ×1

linux ×1

linux-capabilities ×1

sendfile ×1