basic.c
来自「Coda分布式文件系统源代码。其特色在于可以支持离线文件操作以及在线后的自动更新」· C语言 代码 · 共 75 行
C
75 行
/* BLURB gpl Coda File System Release 6 Copyright (c) 1987-2003 Carnegie Mellon University Additional copyrights listed belowThis code is distributed "AS IS" without warranty of any kind underthe terms of the GNU General Public Licence Version 2, as shown in thefile LICENSE. The technical and financial contributors to Coda arelisted in the file CREDITS. Additional copyrights none currently#*/#include <util.h>#include <../partition.h>#include <../vicetab.h>extern void printnames(struct DiskPartition *dp, int low, int step, int high);intmain(int argc, char **argv){ struct DiskPartition *dp; Inode testcreate; Device devno; int fd, count; char *buff="This is a test string"; InitPartitions("vicetab"); dp = VGetPartition("simpled"); devno = dp->device; testcreate = icreate(devno, 0, 0, 0, 0, 0); printf("icreate returned: %d\n", testcreate); if ( testcreate == 0 ) exit(1); fd = iopen(devno, testcreate, O_RDONLY); printf("iopen returned: %d\n", fd); if ( fd != -1 ) close(fd); else exit(2); count = iwrite(devno, testcreate, 0, 0, buff, strlen(buff)); printf("iwrite returned %d (of %d)\n", count, strlen(buff)); printnames(VGetPartition("/tmp/f"), 0, 1, 64); dp = VGetPartition("/tmp/f"); devno = dp->device; testcreate = icreate(devno, 0, 0, 0, 0, 0); printf("icreate returned: %d\n", testcreate); if ( testcreate == 0 ) exit(1); fd = iopen(devno, testcreate, O_RDONLY); printf("iopen returned: %d\n", fd); if ( fd != -1 ) close(fd); else exit(2); count = iwrite(devno, testcreate, 0, 0, buff, strlen(buff)); printf("iwrite returned %d (of %d)\n", count, strlen(buff)); return 0;}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?