2023-11-22

fallocate

#include <fcntl.h>
#include <unistd.h>

int main() {
  // 파일 이름
  const std::string filename = "/path/to/file.bin";

  // 파일 크기
  const int filesize = 256 * 1024 * 1024;

  // 파일 핸들
  int fd = open(filename, O_CREAT | O_RDWR, 0644);

  // 파일의 크기를 지정하여 파일을 생성
  fallocate(fd, FALLOC_FL_KEEP_SIZE, 0, filesize);

  // 파일 핸들을 닫음
  close(fd);

  return 0;
}

댓글 없음:

댓글 쓰기

[qemu] 실행

DISTRO=nodistro MACHINE=qemuarm source layers/meta-st/scripts/envsetup.sh runqemu qemuarm 다음에는 간단한 distro를 만들어서 해봐야겠다.