您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ wsect函数代码示例

51自学网 2021-06-03 10:08:09
  C++
这篇教程C++ wsect函数代码示例写得很实用,希望能帮到您。

本文整理汇总了C++中wsect函数的典型用法代码示例。如果您正苦于以下问题:C++ wsect函数的具体用法?C++ wsect怎么用?C++ wsect使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。

在下文中一共展示了wsect函数的19个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: mkfs

int mkfs(int nblocks, int ninodes, int size) {  int i;  char buf[BLOCK_SIZE];  sb.size = xint(size);  sb.nblocks = xint(nblocks); // so whole disk is size sectors  sb.ninodes = xint(ninodes);  bitblocks = size/(512*8) + 1;  usedblocks = ninodes / IPB + 3 + bitblocks;  freeblock = usedblocks;  printf("used %d (bit %d ninode %zu) free %u total %d/n", usedblocks,         bitblocks, ninodes/IPB + 1, freeblock, nblocks+usedblocks);  assert(nblocks + usedblocks == size);  for(i = 0; i < nblocks + usedblocks; i++)    wsect(i, zeroes);  memset(buf, 0, sizeof(buf));  memmove(buf, &sb, sizeof(sb));  wsect(1, buf);  return 0;}
开发者ID:SongZhao,项目名称:Operation-System-Project-Collection,代码行数:29,


示例2: iappend

voidiappend(uint inum, void *xp, int n) {	char *p = (char *)xp;	uint fbn, off, n1;	struct dinode din;	char buf[512];	uint indirect[NINDIRECT];	uint x;	rinode(inum, &din);	off = xint(din.size);	while (n > 0) {		fbn = off / 512;		assert(fbn < MAXFILE);		if (fbn < NDIRECT) {			if (xint(din.addrs[fbn]) == 0) {				din.addrs[fbn] = xint(freeblock++);				usedblocks++;			}			x = xint(din.addrs[fbn]);		} else {			if (xint(din.addrs[NDIRECT]) == 0) {				// printf("allocate indirect block/n");				din.addrs[NDIRECT] = xint(freeblock++);				usedblocks++;			}			// printf("read indirect block/n");			rsect(xint(din.addrs[NDIRECT]), (char *)indirect);			if (indirect[fbn - NDIRECT] == 0) {				indirect[fbn - NDIRECT] = xint(freeblock++);				usedblocks++;				wsect(xint(din.addrs[NDIRECT]), (char *)indirect);			}			x = xint(indirect[fbn - NDIRECT]);		}		n1 = min(n, (fbn + 1) * 512 - off);		rsect(x, buf);		memcpy(buf + off - (fbn * 512), p, n1);		wsect(x, buf);		n -= n1;		off += n1;		p += n1;	}	din.size = xint(off);	winode(inum, &din);}
开发者ID:Tachibana-General-Laboratories,项目名称:lainos-fail,代码行数:55,


示例3: balloc

voidballoc(int used){  uchar buf[512];  int i;  int j = 0;  int temp;  printf("balloc: first %d blocks have been allocated/n", used);  //assert(used < 512*8);  while(used > 0)  {    bzero(buf, 512);    if (used > 4096)    {      temp = 4096;    }    else    {      temp = used;    }    for(i = 0; i < temp; i++){      buf[i/8] = buf[i/8] | (0x1 << (i%8));    }    used -= 4096;    printf("balloc: write bitmap block at sector %zu/n", ninodes/IPB + 3 + j);    wsect(ninodes / IPB + 3 + j, buf);    j++;  }}
开发者ID:YueDayu,项目名称:Themis_GUI,代码行数:30,


示例4: iappend

voidiappend(uint inum, void *xp, int n){  char *p = (char*)xp;  uint fbn, off, n1;  struct dinode din;  char buf[BSIZE];  uint indirect[NINDIRECT];  uint x;  rinode(inum, &din);  off = xint(din.size);  // printf("append inum %d at off %d sz %d/n", inum, off, n);  while(n > 0){    fbn = off / BSIZE;    assert(fbn < MAXFILE);    if(fbn < NDIRECT){      if(xint(din.addrs[fbn]) == 0){        din.addrs[fbn] = xint(freeblock++);      }      x = xint(din.addrs[fbn]);    } else {      if(xint(din.addrs[NDIRECT]) == 0){        din.addrs[NDIRECT] = xint(freeblock++);      }      rsect(xint(din.addrs[NDIRECT]), (char*)indirect);      if(indirect[fbn - NDIRECT] == 0){        indirect[fbn - NDIRECT] = xint(freeblock++);        wsect(xint(din.addrs[NDIRECT]), (char*)indirect);      }      x = xint(indirect[fbn-NDIRECT]);    }    n1 = min(n, (fbn + 1) * BSIZE - off);    rsect(x, buf);    bcopy(p, buf + off - (fbn * BSIZE), n1);    wsect(x, buf);    n -= n1;    off += n1;    p += n1;  }  din.size = xint(off);  winode(inum, &din);}
开发者ID:Dsdubov,项目名称:xv6,代码行数:43,


示例5: winode

voidwinode(uint inum, struct dinode *ip) {	char buf[512];	uint bn;	struct dinode *dip;	bn = i2b(inum);	rsect(bn, buf);	dip = ((struct dinode *)buf) + (inum % IPB);	*dip = *ip;	wsect(bn, buf);}
开发者ID:Tachibana-General-Laboratories,项目名称:lainos-fail,代码行数:12,


示例6: winode

voidwinode(uint inum, struct dinode *ip){  char buf[BSIZE];  uint bn;  struct dinode *dip;  bn = IBLOCK(inum, sb);  rsect(bn, buf);  dip = ((struct dinode*)buf) + (inum % IPB);  *dip = *ip;  wsect(bn, buf);}
开发者ID:Dsdubov,项目名称:xv6,代码行数:13,


示例7: winode

voidwinode(uint inum, struct dinode *ip){  char buf[BSIZE];  uint bn;  struct dinode *dip;  bn = IBLOCK(inum);  rsect(bn, buf);  dip = ((struct dinode*)buf) + (inum % IPB);  *dip = *ip;  printf("winode %d bn %d/n", inum, bn);  wsect(bn, buf);}
开发者ID:extensibl,项目名称:fscq-impl,代码行数:14,


示例8: balloc

voidballoc(int used){  uchar buf[BSIZE];  int i;  printf("balloc: first %d blocks have been allocated/n", used);  assert(used < BSIZE*8);  bzero(buf, BSIZE);  for(i = 0; i < used; i++){    buf[i/8] = buf[i/8] | (0x1 << (i%8));  }  printf("balloc: write bitmap block at sector %d/n", sb.bmapstart);  wsect(sb.bmapstart, buf);}
开发者ID:Dsdubov,项目名称:xv6,代码行数:15,


示例9: balloc

voidballoc(int used){  uchar buf[512];  int i;  printf("balloc: first %d blocks have been allocated/n", used);  assert(used < 512*8);  bzero(buf, 512);  for(i = 0; i < used; i++){    buf[i/8] = buf[i/8] | (0x1 << (i%8));  }  printf("balloc: write bitmap block at sector %zu/n", ninodes/IPB + 3);  wsect(ninodes / IPB + 3, buf);}
开发者ID:bitc,项目名称:3,代码行数:15,


示例10: balloc

voidballoc(int used){  uchar buf[1024];  int i;  uint sz = sizeof(buf)/sizeof(buf[0]);  printf("balloc: first %d blocks have been allocated/n", used);  assert(used < sz);  bzero(buf, sz);  for(i = 0; i < used; i++) {    buf[i/8] = buf[i/8] | (0x1 << (i%8));  }  printf("balloc: write bitmap block at sector %zu/n", ninodes/IPB + 3);  wsect(ninodes / IPB + 3, buf);}
开发者ID:mmerler,项目名称:osgroup,代码行数:16,


示例11: balloc

voidballoc(int used){  uchar buf[512];  int i, j = 0;  printf("balloc: first %d blocks have been allocated/n", used);  //assert(used < 512*8);  while(used > 0)  {    bzero(buf, 512);    for(i = 0; i < used && i < 512; i++){      buf[i/8] = buf[i/8] | (0x1 << (i%8));    }    used -= 512;    printf("%dballoc: write bitmap block at sector %zu/n", used,  ninodes/IPB + 3+j);    wsect(ninodes / IPB + 3 + j, buf);    j ++;  }  printf("balloc finished.");}
开发者ID:treejames,项目名称:xv6,代码行数:22,


示例12: main

intmain(int argc, char *argv[]){  int i, cc, fd;  uint rootino, inum, off;  struct dirent de;  char buf[512];  struct dinode din;  static_assert(sizeof(int) == 4, "Integers must be 4 bytes!");  if(argc < 2){    fprintf(stderr, "Usage: mkfs fs.img files.../n");    exit(1);  }  assert((512 % sizeof(struct dinode)) == 0);  assert((512 % sizeof(struct dirent)) == 0);  fsfd = open(argv[1], O_RDWR|O_CREAT|O_TRUNC, 0666);  if(fsfd < 0){    perror(argv[1]);    exit(1);  }  sb.size = xint(size);  sb.nblocks = xint(nblocks); // so whole disk is size sectors  sb.ninodes = xint(ninodes);  sb.nlog = xint(nlog);  bitblocks = size/(512*8) + 1;  usedblocks = ninodes / IPB + 3 + bitblocks;  freeblock = usedblocks;  printf("used %d (bit %d ninode %zu) free %u log %u total %d/n", usedblocks,         bitblocks, ninodes/IPB + 1, freeblock, nlog, nblocks+usedblocks+nlog);  assert(nblocks + usedblocks + nlog == size);  for(i = 0; i < nblocks + usedblocks + nlog; i++)    wsect(i, zeroes);  memset(buf, 0, sizeof(buf));  memmove(buf, &sb, sizeof(sb));  wsect(1, buf);  rootino = ialloc(T_DIR);  assert(rootino == ROOTINO);  bzero(&de, sizeof(de));  de.inum = xshort(rootino);  strcpy(de.name, ".");  iappend(rootino, &de, sizeof(de));  bzero(&de, sizeof(de));  de.inum = xshort(rootino);  strcpy(de.name, "..");  iappend(rootino, &de, sizeof(de));  for(i = 2; i < argc; i++){    char *name = argv[i];    if (!strncmp(name, "fs/", 3))      name += 3;    assert(index(name, '/') == 0);    if((fd = open(argv[i], 0)) < 0){      perror(argv[i]);      exit(1);    }        inum = ialloc(T_FILE);    bzero(&de, sizeof(de));    de.inum = xshort(inum);    strncpy(de.name, name, DIRSIZ);    iappend(rootino, &de, sizeof(de));    while((cc = read(fd, buf, sizeof(buf))) > 0)      iappend(inum, buf, cc);    close(fd);  }  // fix size of root inode dir  rinode(rootino, &din);  off = xint(din.size);  off = ((off/BSIZE) + 1) * BSIZE;  din.size = xint(off);  winode(rootino, &din);  balloc(usedblocks);  exit(0);}
开发者ID:swetland,项目名称:xv6,代码行数:97,


示例13: main

intmain(int argc, char *argv[]){  int i, cc, fd;  uint rootino, inum, off;  struct dirent de;  char buf[BSIZE];  struct dinode din;  static_assert(sizeof(int) == 4, "Integers must be 4 bytes!");  if(argc < 2){    fprintf(stderr, "Usage: mkfs fs.img files.../n");    exit(1);  }  assert((BSIZE % sizeof(struct dinode)) == 0);  assert((BSIZE % sizeof(struct dirent)) == 0);  fsfd = open(argv[1], O_RDWR|O_CREAT|O_TRUNC, 0666);  if(fsfd < 0){    perror(argv[1]);    exit(1);  }  // 1 fs block = 1 disk sector  nmeta = 2 + nlog + ninodeblocks + nbitmap;  nblocks = FSSIZE - nmeta;  sb.size = xint(FSSIZE);  sb.nblocks = xint(nblocks);  sb.ninodes = xint(NINODES);  sb.nlog = xint(nlog);  sb.logstart = xint(2);  sb.inodestart = xint(2+nlog);  sb.bmapstart = xint(2+nlog+ninodeblocks);  printf("nmeta %d (boot, super, log blocks %u inode blocks %u, bitmap blocks %u) blocks %d total %d/n",         nmeta, nlog, ninodeblocks, nbitmap, nblocks, FSSIZE);  freeblock = nmeta;     // the first free block that we can allocate  for(i = 0; i < FSSIZE; i++)    wsect(i, zeroes);  memset(buf, 0, sizeof(buf));  memmove(buf, &sb, sizeof(sb));  wsect(1, buf);  rootino = ialloc(T_DIR);  assert(rootino == ROOTINO);  bzero(&de, sizeof(de));  de.inum = xshort(rootino);  strcpy(de.name, ".");  iappend(rootino, &de, sizeof(de));  bzero(&de, sizeof(de));  de.inum = xshort(rootino);  strcpy(de.name, "..");  iappend(rootino, &de, sizeof(de));  for(i = 2; i < argc; i++){    assert(index(argv[i], '/') == 0);    if((fd = open(argv[i], 0)) < 0){      perror(argv[i]);      exit(1);    }        // Skip leading _ in name when writing to file system.    // The binaries are named _rm, _cat, etc. to keep the    // build operating system from trying to execute them    // in place of system binaries like rm and cat.    if(argv[i][0] == '_')      ++argv[i];    inum = ialloc(T_FILE);    bzero(&de, sizeof(de));    de.inum = xshort(inum);    strncpy(de.name, argv[i], DIRSIZ);    iappend(rootino, &de, sizeof(de));    while((cc = read(fd, buf, sizeof(buf))) > 0)      iappend(inum, buf, cc);    close(fd);  }  // fix size of root inode dir  rinode(rootino, &din);  off = xint(din.size);  off = ((off/BSIZE) + 1) * BSIZE;  din.size = xint(off);  winode(rootino, &din);  balloc(freeblock);//.........这里部分代码省略.........
开发者ID:Dsdubov,项目名称:xv6,代码行数:101,


示例14: main

intmain(int argc, char *argv[]){	int i, cc, fd;	uint rootino, inum, off, bin_inum, tests_inum, sbin_inum; //dir_inum	struct dirent de;	char buf[BSIZE];	struct dinode din;	static_assert(sizeof(int) == 4, "Integers must be 4 bytes!");	if(argc < 2) {		fprintf(stderr, "Usage: mkfs fs.img files.../n");		exit(1);	}	assert((BSIZE % sizeof(struct dinode)) == 0);	assert((BSIZE % sizeof(struct dirent)) == 0);	fsfd = open(argv[1], O_RDWR | O_CREAT | O_TRUNC, 0666);	if(fsfd < 0) {		perror(argv[1]);		exit(1);	}	// 1 fs block = 1 disk sector	nmeta = 2 + nlog + ninodeblocks + nbitmap;	nblocks = FSSIZE - nmeta;	sb.size = xint(FSSIZE);	sb.nblocks = xint(nblocks);	sb.ninodes = xint(NINODES);	sb.nlog = xint(nlog);	sb.logstart = xint(2);	sb.inodestart = xint(2 + nlog);	sb.bmapstart = xint(2 + nlog + ninodeblocks);	printf("nmeta %d (boot, super, log blocks %u inode blocks %u, bitmap blocks %u) blocks %d total %d/n",		   nmeta, nlog, ninodeblocks, nbitmap, nblocks, FSSIZE);	freeblock = nmeta;     // the first free block that we can allocate	for(i = 0; i < FSSIZE; i++) {		wsect(i, zeroes);	}	memset(buf, 0, sizeof(buf));	memmove(buf, &sb, sizeof(sb));	wsect(1, buf);	rootino = ialloc(T_DIR);	assert(rootino == ROOTINO);	bzero(&de, sizeof(de));	de.inum = xshort(rootino);	strcpy(de.name, ".");	iappend(rootino, &de, sizeof(de));	bzero(&de, sizeof(de));	de.inum = xshort(rootino);	strcpy(de.name, "..");	iappend(rootino, &de, sizeof(de));	// create /bin folder	bin_inum = ialloc(T_DIR);	bzero(&de, sizeof(de));	de.inum = xshort(bin_inum);	strcpy(de.name, "bin");	iappend(rootino, &de, sizeof(de));	bzero(&de, sizeof(de));	de.inum = xshort(bin_inum);	strcpy(de.name, ".");	iappend(bin_inum, &de, sizeof(de));	bzero(&de, sizeof(de));	de.inum = xshort(rootino);	strcpy(de.name, "..");	iappend(bin_inum, &de, sizeof(de));	// create /dev folder	inum = ialloc(T_DIR);	bzero(&de, sizeof(de));	de.inum = xshort(inum);	strcpy(de.name, "dev");	iappend(rootino, &de, sizeof(de));	bzero(&de, sizeof(de));	de.inum = xshort(inum);	strcpy(de.name, ".");	iappend(inum, &de, sizeof(de));	bzero(&de, sizeof(de));	de.inum = xshort(rootino);	strcpy(de.name, "..");	iappend(inum, &de, sizeof(de));	// create /sbin folder	sbin_inum = ialloc(T_DIR);//.........这里部分代码省略.........
开发者ID:tim48134,项目名称:xylos,代码行数:101,


示例15: iappend

voidiappend(uint inum, void *xp, int n){  char *p = (char*)xp;  uint fbn, off, n1;  struct dinode din;  char buf[512];  uint indirect[512];  uint x;    rinode(inum, &din);    int temp_fbn, d1, d2, k1, k2, k3, a1, a2, a3;  off = xint(din.size);  while(n > 0){    //printf("%d/n", n);    fbn = off / 512;    //assert(fbn < MAXFILE);    if(fbn < NDIRECT){      //printf("hjw 1 %d/n", n);      if(xint(din.addrs[fbn]) == 0){        din.addrs[fbn] = xint(freeblock++);        usedblocks++;      }      x = xint(din.addrs[fbn]);    } else {            temp_fbn = fbn;      temp_fbn -= NDIRECT;      d1 = temp_fbn / 128;      k1 = temp_fbn % 128;      d2 = d1 / 128;      k2 = d1 % 128;      //d3 = d2 / 128;      k3 = d2 % 128;      if((a1 = din.addrs[NDIRECT]) == 0)      {	 a1 = din.addrs[NDIRECT] = xint(freeblock++);	 usedblocks ++;      }      rsect(xint(a1), (char*)indirect);      if((a2 = indirect[k3]) == 0)      {	a2 = indirect[k3] = xint(freeblock++);        usedblocks ++;        wsect(xint(a1), (char*)indirect);      }      rsect(xint(a2), (char*)indirect);      if((a3 = indirect[k2]) == 0)      {	a3 = indirect[k2] = xint(freeblock++);        usedblocks ++;        wsect(xint(a2), (char*)indirect);      }      rsect(xint(a3), (char*)indirect);      if((x = indirect[k1]) == 0)      {	x = indirect[k1] = xint(freeblock++);        usedblocks ++;        wsect(xint(a3), (char*)indirect);      }      x = xint(x);      //printf("%d--", fbn);    }    //printf("%d/n", x);    n1 = min(n, (fbn + 1) * 512 - off);    rsect(x, buf);    //printf("hjw 2 %d %d %d %d/n", n, off - (fbn * 512), n1, sizeof(p));    bcopy(p, buf + off - (fbn * 512), n1);      //   printf("hjw 3 %d/n", n);    wsect(x, buf);    n -= n1;    off += n1;    p += n1;  }  din.size = xint(off);  winode(inum, &din);}
开发者ID:treejames,项目名称:xv6,代码行数:78,


示例16: szero

void szero(uint sec){  uchar buf[SECSIZE];  memset(buf, 0, SECSIZE);  wsect(sec, buf);}
开发者ID:WyxJsdf,项目名称:xv6-public,代码行数:6,


示例17: main

int main(int argc, char *argv[]){  // 局部变量  char buf[SECSIZE];  // FAT表表头标记  uchar fatStartContent[8] = {0xf8,0xff,0xff,0x0f,0xff,0xff,0xff,0xff};  struct direntry dire;  uint dirClusNum;  // 为文件分配的簇号  uint wClusNum;  // 根目录簇号  uint fileSize;  // 文件大小  uint cc, fd;  // cc一次读取文件的字节数,打开文件的fd  int rootWSize = 0;  // 已向根目录写入的字节数  int fileWSize = 0;  // 已向文件中写入的字节数  char filename[FNSIZE]; // 文件名  int i;  static_assert(sizeof(int) == 4, "Integers must be 4 bytes!");  if(argc < 2){    fprintf(stderr, "Usage: mkfs fs.img files.../n");    exit(1);  }  initDat();  // 是否有需要断言  // ?  fsfd = open(argv[1], O_RDWR|O_CREAT|O_TRUNC, 0666);  if(fsfd < 0){    perror(argv[1]);    exit(1);  }  printf("DBR : %d, retain sectors: %d, FAT sector: %d, 2 FATs, data sectors: %d, clusters: %d",     nDBR, nRetain, nFAT, nData, nDataClus);  // 清零fs  for(i = 0; i < FSSIZE; i++)    szero(i);  // 向第0扇区写入DBR  initDBR();  memset(buf, 0, sizeof(buf));  memmove(buf, &fatDBR, sizeof(fatDBR));  wsect(0, buf);  // 写入FAT表头标记  rsect4bytes(fatFstSec, 0, fatStartContent);  rsect4bytes(fatFstSec, 1, fatStartContent + 4);  // 写入根目录  dire = mkFCB(T_DIR, "/", sizeof(DIR)*argc, &dirClusNum);  dirClusNum = appendBuf(dirClusNum, &dire, sizeof(DIR), rootWSize);  rootWSize += sizeof(DIR);  wClusNum = dirClusNum;  dire = mkFCB(T_DIR, ".", sizeof(DIR)*argc, &dirClusNum);  wClusNum = appendBuf(wClusNum, &dire, sizeof(DIR), rootWSize);  rootWSize += sizeof(DIR);  dire = mkFCB(T_DIR, "..", 0, &dirClusNum);  wClusNum = appendBuf(wClusNum, &dire, sizeof(DIR), rootWSize);  rootWSize += sizeof(DIR);  // 写入其他文件  for(i = 2; i < argc; i++){    fileWSize = 0;    assert(index(argv[i], '/') == 0);    fileSize = retFileSize(argv[i]);    if((fd = open(argv[i], 0)) < 0){      perror(argv[i]);      exit(1);    }        if(argv[i][0] == '_')      ++argv[i];    // 写到目录区    strncpy(filename, argv[i], FNSIZE);    dire = mkFCB(T_FILE, filename, fileSize, &dirClusNum);    wClusNum = appendBuf(wClusNum, &dire, sizeof(DIR), rootWSize);    rootWSize += sizeof(DIR);    // 写入文件    while((cc = read(fd, buf, sizeof(buf))) > 0)    {      dirClusNum = appendBuf(dirClusNum, buf, cc, fileWSize);      fileWSize += cc;    }    close(fd);  }  // 向第1扇区写入FSI  initFSI();  memset(buf, 0, sizeof(buf));  memmove(buf, &fsi, sizeof(fsi));//.........这里部分代码省略.........
开发者ID:WyxJsdf,项目名称:xv6-public,代码行数:101,


示例18: main

intmain(int argc, char *argv[]){  int i, cc, fd;  uint rootino, inum, off;  struct dirent de;  char buf[512];  struct dinode din;  if(argc < 2){    fprintf(stderr, "Usage: mkfs fs.img files.../n");    exit(1);  }  assert((512 % sizeof(struct dinode)) == 0);  assert((512 % sizeof(struct dirent)) == 0);  fsfd = open(argv[1], O_RDWR|O_CREAT|O_TRUNC, 0666);  if(fsfd < 0){    perror(argv[1]);    exit(1);  }  sb.size = xint(size);  sb.nblocks = xint(nblocks); // so whole disk is size sectors  sb.ninodes = xint(ninodes);  bitblocks = size/(512*8) + 1;  usedblocks = ninodes / IPB + 3 + bitblocks;  freeblock = usedblocks;  printf("used %d (bit %d ninode %zu) free %u total %d/n", usedblocks,         bitblocks, ninodes/IPB + 1, freeblock, nblocks+usedblocks);  assert(nblocks + usedblocks == size);  for(i = 0; i < nblocks + usedblocks; i++)    wsect(i, zeroes);  wsect(1, &sb);  rootino = ialloc(T_DIR);  assert(rootino == ROOTINO);  bzero(&de, sizeof(de));  de.inum = xshort(rootino);  strcpy(de.name, ".");  iappend(rootino, &de, sizeof(de));  bzero(&de, sizeof(de));  de.inum = xshort(rootino);  strcpy(de.name, "..");  iappend(rootino, &de, sizeof(de));  for(i = 2; i < argc; i++){    assert(index(argv[i], '/') == 0);    if((fd = open(argv[i], 0)) < 0){      perror(argv[i]);      exit(1);    }        // Skip leading _ in name when writing to file system.    // The binaries are named _rm, _cat, etc. to keep the    // build operating system from trying to execute them    // in place of system binaries like rm and cat.    if(argv[i][0] == '_')      ++argv[i];    inum = ialloc(T_FILE);    bzero(&de, sizeof(de));    de.inum = xshort(inum);    strncpy(de.name, argv[i], DIRSIZ);    iappend(rootino, &de, sizeof(de));    while((cc = read(fd, buf, sizeof(buf))) > 0)      iappend(inum, buf, cc);    close(fd);  }  // fix size of root inode dir  rinode(rootino, &din);  off = xint(din.size);  off = ((off/BSIZE) + 1) * BSIZE;  din.size = xint(off);  winode(rootino, &din);  balloc(usedblocks);  exit(0);}
开发者ID:mmerler,项目名称:osgroup,代码行数:93,


示例19: main

int main(int argc, char *argv[]){  int i;  uint rootino, off;  struct dirent de;  char buf[512];  struct dinode din;  static_assert(sizeof(int) == 4, "Integers must be 4 bytes!");  if(argc != 3)  {    fprintf(stderr, "Usage: mkfs.xv6 <image name> <test|release>/n");    exit(1);  }  assert((512 % sizeof(struct dinode)) == 0);  assert((512 % sizeof(struct dirent)) == 0);  fsfd = open(argv[1], O_RDWR|O_CREAT|O_TRUNC, 0666);  if(fsfd < 0){    perror(argv[1]);    exit(1);  }  sb.size = xint(size);  sb.nblocks = xint(nblocks); // so whole disk is size sectors  sb.ninodes = xint(ninodes);  sb.nlog = xint(nlog);  bitblocks = size/(512*8) + 1;  usedblocks = ninodes / IPB + 3 + bitblocks;  freeblock = usedblocks;  if (0)  {    printf("used %d (bit %d ninode %zu) free %u log %u total %d/n", usedblocks,           bitblocks, ninodes/IPB + 1, freeblock, nlog, nblocks+usedblocks+nlog);  }  assert(nblocks + usedblocks + nlog == size);  for(i = 0; i < nblocks + usedblocks + nlog; i++)    wsect(i, zeroes);  memset(buf, 0, sizeof(buf));  memmove(buf, &sb, sizeof(sb));  wsect(1, buf);  rootino = ialloc(T_DIR);  assert(rootino == ROOTINO);  bzero(&de, sizeof(de));  de.d_ino = xshort(rootino);  strcpy(de.d_name, ".");  iappend(rootino, &de, sizeof(de));  bzero(&de, sizeof(de));  de.d_ino = xshort(rootino);  strcpy(de.d_name, "..");  iappend(rootino, &de, sizeof(de));  if (!strcmp(argv[2], "release"))  {    create_fhs(rootino, "coreutils/init");  }  else if (!strcmp(argv[2], "test"))  {    create_fhs(rootino, "tests/init");    create_tests(rootino);  }  // fix size of root inode dir  rinode(rootino, &din);  off = xint(din.size);  off = ((off/BSIZE) + 1) * BSIZE;  din.size = xint(off);  winode(rootino, &din);  balloc(usedblocks);  exit(0);}
开发者ID:NewbiZ,项目名称:xv6,代码行数:83,



注:本文中的wsect函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


C++ wsprintfW函数代码示例
C++ wscrl函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。