- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
<分区>
为什么我总是收到这个错误?我正在尝试使用 nfs 共享访问文件。我不断收到这些错误。我想通过 nfs 共享访问网络上的一些文件。我引用了一些代码,当我尝试编译这些代码时,出现了这些错误。我是 c++ 的新手。请帮我..!!谢谢。
test@wsm-ela-inc6:~/salu$ make all
g++ -g -Wall -c FS.cpp
FS.cpp: In member function ‘int FS::open(Volume&, const char*, const char*)’:
FS.cpp:128:19: error: no match for ‘operator=’ (operand types are ‘Volume’ and ‘Volume*’)
open_file.volume= &volume;
^
In file included from FS.h:12:0,
from FS.cpp:8:
Volume.h:19:7: note: candidate: Volume& Volume::operator=(const Volume&)
class Volume
^
Volume.h:19:7: note: no known conversion for argument 1 from ‘Volume*’ to ‘const Volume&’
FS.cpp: In member function ‘void FS::close(int)’:
FS.cpp:162:32: error: base operand of ‘->’ has non-pointer type ‘Volume’
Directory dir(open_file.volume->get_fat());
^
FS.cpp: In member function ‘int FS::read(int, char*, int)’:
FS.cpp:196:17: error: no match for ‘operator*’ (operand type is ‘Volume’)
Volume &vol = *open_file.volume;
^
FS.cpp:230:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
if(read_len<block_size) {
^
FS.cpp: In member function ‘int FS::write(int, char*, int)’:
FS.cpp:267:15: error: no match for ‘operator*’ (operand type is ‘Volume’)
Volume &vol = *open_file.volume;
^
FS.cpp:320:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
if(read_len<block_size){
^
FS.cpp:275:8: warning: unused variable ‘blk’ [-Wunused-variable]
char blk[MAX_BLOCK_SIZE];
^
FS.cpp: In member function ‘int FS::seek(int, int)’:
FS.cpp:353:35: error: base operand of ‘->’ has non-pointer type ‘Volume’
FAT &fat_file = (open_file.volume->get_fat());
^
FS.cpp: In member function ‘int FS::rmdir(Volume&, const char*, const char*)’:
FS.cpp:462:6: error: ‘file_fcb’ was not declared in this scope
if(file_fcb->type !=DIR_TYPE) return DISK_ERROR;
^
Makefile:13: recipe for target 'FS.o' failed
make: *** [FS.o] Error 1
完整的代码在下面的链接中给出: https://github.com/anieshchawla/networkfilesystem/
/** @file FS.cpp
*
* File System implementation
*
* @author Copyright Robert van Engelen, March 2006
**/
//#include "FCB.h"
#include "FS.h"
#include "Directory.h"
#include <iostream>
FS::FS()
{ }
FS::~FS()
{ }
int FS::open(const Volume& volume, const char *path, const char *name)
{
int fd = 0;
// TODO("Implement FS::open()");
// Check if file was already opened (has entry in open file table):
// Check all open file entries for count > 0.
// If the volume, path, and file name match, then ++count and return fd.
// Otherwise, set fd to a free entry in the open file table with count ==0
// and set the open_file.name to the open() name argument.
// If no entries are available then report error and return DISK_ERROR.
//assert(open_file_table[fd].count == 0);
while((fd < MAX_OPEN_FILES)){
if(strcmp(open_file_table[fd].name.cstr() , name)==0){
break;
}
fd++;
}
if (fd==MAX_OPEN_FILES){
fd = 0;
while(open_file_table[fd].count!=0 && fd<MAX_OPEN_FILES){
fd++;
}
if(fd == MAX_OPEN_FILES) fd=DISK_ERROR;
else {
assert(open_file_table[fd].count == 0);
open_file_table[fd].name = name;
}
}
///////// OpenFile& open_file = open_file_table[fd];
// Create a Directory object for the volume's FAT and use Directory::chdir()
// to move to the path location of the file.
// The dir should now point to the directory of the file.
// If the dir does not exist, then report and return DISK_ERROR.
// Get the FCB of the file via the dir object.
// If there is no FCB, then this is a new file so we create a new FCB with
// size = 0, type = FILE_TYPE, created = time(NULL), and we allocate a new
// start_block from the FAT of the volume.
// Otherwise, if there is an FCB, then set the open_file.size and
// open_file.start_block from the FCB attributes.
// Set the other open_file attributes:
// open_file.pos = 0;
// open_file.current_block = open_file.start_block;
// open_file.current_block_pos = 0;
// open_file.updated = false;
// Increment the open_file.count.
// fd = DISK_ERROR;
OpenFile& open_file = open_file_table[fd];//we used & symbol because if we change open_file we want corresponding
//change to happend in open_file_table entry also
// Create a Directory object for the volume's FAT and use Directory::chdir()
// to move to the path location of the file.
// The dir should now point to the directory of the file.
// If the dir does not exist, then report and return DISK_ERROR.
Directory dir(volume.get_fat());
dir.chdir(path);
//if(!dir.exists(open_file.name)) return DISK_ERROR;
// Get the FCB of the file via the dir object.
const FCB *fcb_file = dir.get_fcb(open_file.name);
// If there is no FCB, then this is a new file so we create a new FCB with
// size = 0, type = FILE_TYPE, created = time(NULL), and we allocate a new
// start_block from the FAT of the volume.
if(fcb_file == NULL) {
FCB fcb;
fcb.size = 0;
fcb.type = FILE_TYPE;
fcb.created = time(NULL);
fcb.start_block = volume.get_fat().alloc();
open_file.start_block = fcb.start_block;
dir.set_fcb(open_file.name, fcb);
}
// Otherwise, if there is an FCB, then set the open_file.size and
// open_file.start_block from the FCB attributes.
else{
open_file.size = fcb_file->size;
open_file.start_block = fcb_file->start_block;
}
// Set the other open_file attributes:
open_file.pos = 0;
open_file.volume= &volume;
open_file.current_block = open_file.start_block;
open_file.current_block_pos = 0;
open_file.updated = false;
// Increment the open_file.count.
open_file.count++;
//fd = DISK_ERROR;
return fd;
/////////////// return fd;
}
void FS::close(int fd)
{
OpenFile& open_file = open_file_table[fd];
assert(open_file.count > 0);
// TODO("Implement FS::close()");
// If the file was updated, update its FCB in the directory:
if (open_file.updated)
{
// Create a Directory object for the volume's FAT and use Directory::chdir()
// to move to the path location of the file.
// The dir should now point to the directory of the file.
// If the dir does not exist, then report and return DISK_ERROR.
Directory dir(open_file.volume->get_fat());
dir.chdir(open_file.path);
if(!dir.exists(open_file.name)) exit DISK_ERROR;
// Get the FCB object of the file, update it with the open_file attributes
// such as size, and set the FCB of the file
const FCB *fcb_file = dir.get_fcb(open_file.name);
if(fcb_file==NULL){
}
open_file.count--;
// What to do if the FCB was not found? This could happen when the file is
// deleted before closed. So rm() must check if the file is not open!
}
// Decrement the open_file.count
}
int FS::read(int fd, char *buf, int len)
{
OpenFile& open_file = open_file_table[fd];
assert(open_file.count > 0);
// TODO("Implement FS::read()");
int block_num = open_file.current_block;
int byte_to_read = len;
Volume &vol = *open_file.volume;
FAT &file_table = vol.get_fat();
Disk &read_fm_disk = file_table.get_disk();
int block_size = read_fm_disk.block_size();
char blk[MAX_BLOCK_SIZE];
// We need to copy data of at most len bytes from disk to the buf argument.
while(len>0){
open_file.current_block = block_num;
size_t read_len = std::min(len,block_size);
read_fm_disk.read(block_num,blk);
int read_length = open_file.current_block_pos + read_len;
//std::cout<<"read length= "<<read_length<<" current_block_pos= "<<open_file.current_block_pos<<std::endl;
//std::cout<<"block_size= "<<read_fm_disk.block_size()<<" block_num "<<block_num<<std::endl;
open_file.pos +=read_len;
if(read_length > block_size ){
memcpy(buf,blk+open_file.current_block_pos,block_size-open_file.current_block_pos);
block_num = file_table.find_next(block_num);
open_file.current_block = block_num;
read_fm_disk.read(block_num,blk);
//std::cout<<"value copied till now is "<< buf<<std::endl;
//std::cout<<"value to be copied "<< blk<<std::endl;
read_len -= (block_size - open_file.current_block_pos);
buf+= (block_size - open_file.current_block_pos);
len-= (block_size - open_file.current_block_pos);
open_file.current_block_pos = 0;
}
//if(block_num==24) std::cout<<"value should be "<<blk+open_file.current_block_pos<<std::endl;
memcpy(buf,blk+open_file.current_block_pos,read_len);
buf+=read_len;
if(read_len<block_size) {
open_file.current_block_pos += read_len;
if(open_file.current_block_pos > block_size) open_file.current_block_pos-=block_size;
}
else{
block_num = file_table.find_next(block_num);
}
len-=read_len;
}
// To do so, use a loop to copy the data in chunks.
// Within the loop, update the open_file.pos position in the file,
// the open_file.current_block, and open_file.current_block_pos offset into
// the current block being read.
// You need to get the FAT of the volume of the open file and use find_next()
// to find the blocks.
// Return the number of bytes copied, or DISK_ERROR when an error occurred.
///////// return DISK_ERROR;
return byte_to_read;
}
int FS::write(int fd, char *buf, int len)
{
OpenFile& open_file = open_file_table[fd];
assert(open_file.count > 0);
open_file.updated = true;
//TODO("Implement FS::write()");
Volume &vol = *open_file.volume;
FAT &file_table = vol.get_fat();
Disk &fm_disk = file_table.get_disk();
Directory dir(file_table);
FCB fcb_of_file;
int block_size = fm_disk.block_size();
char blk[MAX_BLOCK_SIZE];
const FCB *old_fcb_file = dir.get_fcb(open_file.name);
int block_num = open_file.current_block;
// We need to copy data from buf of length len to disk.
// To do so, use a loop to copy the data in chunks.
// Within the loop, update the open_file.size, open_file.pos,
// the open_file.current_block, and open_file.current_block_pos offset into
// the current block being written.
while(len>0){
size_t read_len = std::min(len,block_size);
char buf_disk[block_size];
//std::cout<<"the block number is "<<block_num<<std::endl;
if(open_file.current_block_pos == block_size){
//std::cout<<"we are inside this block num "<<block_num<<std::endl;
block_num = file_table.alloc_next(block_num);
open_file.current_block = block_num;
open_file.current_block_pos = 0;
fm_disk.read(block_num,buf_disk);
}
fm_disk.read(block_num,buf_disk);
char write_buf[block_size];
memcpy(write_buf,buf_disk,open_file.current_block_pos);
int read_length = open_file.current_block_pos+read_len;
open_file.pos +=read_len;
open_file.size+=read_len;
if(read_length > block_size){
memcpy(write_buf+open_file.current_block_pos,buf,block_size- open_file.current_block_pos);
fm_disk.write(block_num,write_buf);
block_num = file_table.alloc_next(block_num);
open_file.current_block = block_num;
buf+=block_size-open_file.current_block_pos;
read_len -= block_size - open_file.current_block_pos;
len-= block_size - open_file.current_block_pos;
open_file.current_block_pos = 0;
fm_disk.read(block_num,buf_disk);
read_length = read_len;
}
memcpy(write_buf+open_file.current_block_pos,buf,read_len);
memcpy(write_buf+read_length, buf_disk + read_length,block_size- read_length);
if(read_len<block_size){
open_file.current_block_pos+=read_len;
if(open_file.current_block_pos>block_size){
open_file.current_block_pos-=block_size;
}
}
fm_disk.write(block_num,write_buf);
buf+=read_len;
len-=read_len;
}
fcb_of_file.type = old_fcb_file->type;
fcb_of_file.size = open_file.size;
fcb_of_file.created = old_fcb_file->created;
fcb_of_file.start_block = old_fcb_file->start_block;
dir.set_fcb(open_file.name,fcb_of_file);
// You need to get the FAT of the volume of the open file and use
// alloc_next() to find or get new blocks.
// Note that writing data inside blocks may require reading blocks first.
// Return DISK_OK or DISK_ERROR.
return DISK_OK;
}
int FS::seek(int fd, int pos)
{
OpenFile& open_file = open_file_table[fd];
assert(open_file.count > 0);
FAT &fat_file = (open_file.volume->get_fat());
int block_size = fat_file.get_disk().block_size();
//TODO("Implement FS::seek()");
//std::cout<<"the file position= "<<open_file.pos<<" requested pos= "<<pos<<std::endl;
int block_shifts = (pos - open_file.pos);
int offset = pos%block_size;
//std::cout<<"block shifts "<<block_shifts<<" offset "<<offset<<std::endl;
if(open_file.size < pos) return DISK_ERROR;
else{
if(block_shifts < 0) {
block_shifts = (int)(pos/block_size) - (int)(open_file.pos/block_size);
if(open_file.pos == ((int)(open_file.pos/block_size))*block_size) block_shifts++;
//std::cout<<"block shifts negative is "<<block_shifts<<std::endl;
block_shifts = open_file.current_block - open_file.start_block + block_shifts;
//std::cout<<"the block shifts from start are "<<block_shifts<<std::endl;
open_file.current_block = open_file.start_block;
}
open_file.pos = pos;
while(block_shifts > 0 ){
open_file.current_block = fat_file.find_next(open_file.current_block);
block_shifts--;
}
open_file.current_block_pos = offset;
return DISK_OK;
}
// Change the open_file.pos, open_file.current_block, and
// open_file.current_block_pos within the allowable range of the file
// where the range is 0 to size-1.
// Return DISK_OK or DISK_ERROR when an error occurred
return DISK_ERROR;
}
int FS::ls(Volume& volume, const char *path)
{
Directory dir(volume.get_fat());
dir.chdir(path);
printf("Volume %s:%s (%d blocks, %d free)\n", volume.get_name(), path, volume.get_fat().num_blocks(), volume.get_fat().num_free_blocks());
dir.list();
return DISK_OK;
}
int FS::rm(Volume& volume, const char *path, const char *name)
{
//TODO("Implement FS::rm()");
int fd = -1;
Directory dir(volume.get_fat());
dir.chdir(path);
FileName file_name(name);
const FCB* file_fcb = dir.get_fcb(file_name);
// Check if this is a regular file.
if(file_fcb->type !=FILE_TYPE) return DISK_ERROR;
// Check if the file is not open.
while((fd < MAX_OPEN_FILES)){
if(strcmp(open_file_table[fd].name.cstr() , name)==0){
break;
}
fd++;
}
// Create a Directory object for the volume's FAT and use Directory::chdir()
// to move to the path location of the file.
// The dir should now point to the directory of the file.
// If the dir does not exist, then report and return DISK_ERROR.
// Use Directory::erase() to remove the file.
if(fd != MAX_OPEN_FILES){
assert(open_file_table[fd].count ==0);
dir.erase(file_name);
return DISK_OK;
}
// Return DISK_OK or DISK_ERROR.
return DISK_ERROR;
}
int FS::mkdir(Volume& volume, const char *path, const char *name)
{
Directory dir(volume.get_fat());
dir.chdir(path);
FileName dir_name(name);
return dir.mkdir(dir_name);
}
int FS::rmdir(Volume& volume, const char *path, const char *name)
{
Directory dir(volume.get_fat());
dir.chdir(path);
FileName dir_name(name);
const FCB* file_fcb = dir.get_fcb(dir_name);
//TODO("Complete FS::rmdir()");
// Check if this is a directory.
if(file_fcb->type !=DIR_TYPE) return DISK_ERROR;
if(!dir.exists(dir_name)) return DISK_ERROR;
// Check if the directory is empty.
//if(!dir.empty()) return DISK_ERROR;
dir.erase(dir_name);
return DISK_OK;
}
/** @file Volume.h
*
* Volume structure
*
* @author Copyright Robert van Engelen, March 2006
**/
#ifndef VOLUME_H
#define VOLUME_H
#include "includes.h"
#include "Disk.h"
#include "FAT.h"
/** A Volume object associates a volume name with a formatted Disk.
*
* The Volume object contains a FAT and a reference to the Disk object.
**/
class Volume
{
private:
/// The volume name.
const char *name;
/// The FAT with the Disk reference.
FAT fat;
public:
/// Create a new named Volume (and FAT) for a formatted Disk object.
Volume(const char *name, Disk& disk);
~Volume();
/// Return the name of this volume.
const char *get_name() const;
/// Return a reference to the FAT of the Disk for this volume.
FAT& get_fat();
//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
/*
Volume(const char *name, Disk& disk) : name(strdup(name)), fat(disk)
{ }
~Volume()
{
if (name)
free((void*)name);
}
const char * get_name() const
{
return name;
}
FAT& get_fat()
{
return fat;
}
*/
//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
};
#endif
docker volume 命令中使用的两个标志之间的确切区别是什么 -v和 --volumes-from .在我看来,他们正在做同样的工作,请考虑以下场景。 首先让我们创建一个名为 myvol 的卷
关闭。这个问题需要debugging details .它目前不接受答案。 编辑问题以包含 desired behavior, a specific problem or error, and th
我正在尝试创建一个 docker 容器,该容器具有一个应包含多个文件夹的外部卷,因此我的 Dockerfile 简化版本如下所示: FROM ubuntu:12.04 # Create a volum
我正在使用打开 Kubernetes 选项的 docker 应用程序运行 mac OSX Catalina。我使用以下 yaml 和命令创建了一个 PersistentVolume。 apiVersi
我看到了 docker-compose 模式,但我很困惑。制作组合容器的最佳方法是什么。什么时候应该使用 link 或 volumes_from。我什么时候应该使用 volumes_from, vol
我对创建 docker volume create my-vol 之间的区别感到困惑。和 VOLUME ["/var/www"] . 我的理解是: 1) docker volume create my
要在 Kubernetes POD 中使用存储,我可以使用 volumes和 persistent volumes .而卷像emptyDir是短暂的,我可以使用 hostPath以及许多其他基于云的卷
使用 btrfs 驱动程序在 RHEL 7.1 上运行 docker v1.10.1。我有一个单独的 xfs 分区,我想在其中挂载数据卷。我宁愿让 docker 本地管理卷(即使用 docker vo
我想在我的 docker-compose 文件中设置一个标志,如果我不需要我的数据库卷是否不会在容器外持久化,但我仍然想要一个卷条目,如果我的数据库很小那么我不希望它执着于外。 最佳答案 您可以使用两
我是 Kubernetes 的新手,我很难理解 Kubernetes 中持久存储背后的整个想法。 这就足够了吗,或者我必须创建持久卷,如果我只部署这两个对象而不创建 PV 会发生什么情况? 存储应该在
我正在研究 kubeflow 管道以及管道的不同组件如何相互链接。为此,我使用了官方 GitHub 存储库中提供的 MNIST 项目示例。但我无法理解以下代码片段中 vop.volume 和 mnis
我正在尝试设置 Dockerfile将我的主机目录挂载到我指定的 docker 容器目录(因此代码更改将立即反射(reflect)出来)。当我运行 docker run -p 3000:3000 -d
我有一个使用 docker-compose 在 Ubuntu 服务器上运行的 Jira 实例。 我最初通过将 jira 安装文件夹映射到名为 jiravolume 的 docker 卷来设置它。 vo
如何检测在 iOS/Android 上是否按下了 + 或 - 按钮? 最佳答案 我认为它对 iOS 有帮助.. - (void)viewWillAppear:(BOOL)animated {
我是 Docker 的新手。我在 Windows 10 企业版 上运行,并尝试将在 Windows 上运行的现有应用容器化(因此它是一个 Windows 容器)。我不知道这是否重要,但容器相当大 (8
我已经断断续续地搜索文档、邮件列表几天了,但似乎找不到答案。 我有一个 OS X 应用程序,除其他外,它可以使用 kAudioDevicePropertyVolumeScalar 等查询可用的硬件设备
了解了docker(在Ubuntu 18.04 LTE(仿生)上),特别是关于管理持久数据的知识,我发现docker volumes。 按照那里的示例,我尝试将一些文件添加到卷中,然后从容器中列出它们
在这段代码中,如果Volume>10mil,我开始将体积添加到Cumulative Volume,我们在蜡烛下面创建一条线,一直延伸到当前条,因此Volume>10mil,我们创建一条线,Cumvol
这个问题在这里已经有了答案: Kubernetes NFS Persistent Volumes - multiple claims on same volume? Claim stuck in p
使用 docker-compose synthax v2,我们能够做这样的事情: version: '2' services: app: image: tianon/true vo
我是一名优秀的程序员,十分优秀!