当前位置: 首页>>代码示例>>C++>>正文


C++ end_request函数代码示例

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


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

示例1: osprd_process_request

/*
 * osprd_process_request(d, req)
 *   Called when the user reads or writes a sector.
 *   Should perform the read or write, as appropriate.
 */
static void osprd_process_request(osprd_info_t *d, struct request *req)
{
    if (!blk_fs_request(req)) {
        end_request(req, 0);
        return;
    }

    // EXERCISE: Perform the read or write request by copying data between
    // our data array and the request's buffer.
    // Hint: The 'struct request' argument tells you what kind of request
    // this is, and which sectors are being read or written.
    // Read about 'struct request' in <linux/blkdev.h>.
    // Consider the 'req->sector', 'req->current_nr_sectors', and
    // 'req->buffer' members, and the rq_data_dir() function.

    // Your code here.

    long int sector_offset = req->sector * SECTOR_SIZE;
    long int request_size = req->current_nr_sectors * SECTOR_SIZE;

    if (rq_data_dir(req) == READ) {
        memcpy(req->buffer, d->data + sector_offset, request_size);
    } else {
        memcpy(d->data + sector_offset, req->buffer, request_size);
    }

    // eprintk("Should process request...\n");

    end_request(req, 1);
}
开发者ID:jacobnisnevich,项目名称:ramdisk-lab,代码行数:35,代码来源:osprd.c

示例2: simpleblkdrv_do_request

static void simpleblkdrv_do_request(struct request_queue *q)
{
	struct request *req;
	while ((req = elv_next_request(q)) != NULL)
	{
		if ((req->sector + req->current_nr_sectors) << 9 > BLK_BYTES)
		{
			printk(KERN_ERR"request error!\n");
			end_request(req, 0);/*transfer fail*/
			continue;
		}

		switch (rq_data_dir(req))
		{
			case READ:
				memcpy(req->buffer, blkdev_data + (req->sector << 9), req->current_nr_sectors << 9);
				end_request(req, 1);/*transfer ok*/
				break;
			case WRITE:
				memcpy(blkdev_data + (req->sector << 9), req->buffer, req->current_nr_sectors << 9);
				end_request(req, 1);/*transfer ok*/
				break;
			default:
				/* No default because rq_data_dir(req) is 1 bit */
				break;
		}
	}
}
开发者ID:cherry-wb,项目名称:quietheart,代码行数:28,代码来源:simpleblkdrv.c

示例3: osprd_process_request

/*
 * osprd_process_request(d, req)
 *   Called when the user reads or writes a sector.
 *   Should perform the read or write, as appropriate.
 */
static void osprd_process_request(osprd_info_t *d, struct request *req)
{
	if (!blk_fs_request(req)) {
		end_request(req, 0);
		return;
	}

	// EXERCISE: Perform the read or write request by copying data between
	// our data array and the request's buffer.
	// Hint: The 'struct request' argument tells you what kind of request
	// this is, and which sectors are being read or written.
	// Read about 'struct request' in <linux/blkdev.h>.
	// Consider the 'req->sector', 'req->current_nr_sectors', and
	// 'req->buffer' members, and the rq_data_dir() function.

	// Your code here.
	unsigned request_type;
	uint8_t *data_ptr;
	request_type = rq_data_dir(req);
	data_ptr = d->data + req->sector * SECTOR_SIZE;
	//eprintk("passwd_hash: %d\n", d->passwd_hash);
	if (request_type == READ) {
		memcpy((void*)req->buffer, (void*)data_ptr,
			req->current_nr_sectors * SECTOR_SIZE);
	}
	else if (request_type == WRITE) {
		memcpy((void*)data_ptr, (void*)req->buffer,
			req->current_nr_sectors * SECTOR_SIZE);
	}
	//eprintk("Should process request...\n");

	end_request(req, 1);
}
开发者ID:m1c0l,项目名称:ramdisk,代码行数:38,代码来源:osprd.c

示例4: osprd_process_request

/*
 * osprd_process_request(d, req)
 *   Called when the user reads or writes a sector.
 *   Should perform the read or write, as appropriate.
 */
static void osprd_process_request(osprd_info_t *d, struct request *req)
{
	sector_t offset = req->sector * SECTOR_SIZE;
	if (!blk_fs_request(req)) {
		end_request(req, 0);
		return;
	}

	// EXERCISE: Perform the read or write request by copying data between
	// our data array and the request's buffer.
	// Hint: The 'struct request' argument tells you what kind of request
	// this is, and which sectors are being read or written.
	// Read about 'struct request' in <linux/blkdev.h>.
	// Consider the 'req->sector', 'req->current_nr_sectors', and
	// 'req->buffer' members, and the rq_data_dir() function.

	// Your code here.
	// Calculate offset per ramdisk
	if(rq_data_dir(req)==WRITE){
		// Write - copy contents of req to d
		memcpy(&(d->data[offset]), req->buffer,
				req->current_nr_sectors * SECTOR_SIZE);
	} else {
		// Read - copy contents of d to req
		memcpy(req->buffer, &(d->data[offset]), 
				req->current_nr_sectors * SECTOR_SIZE);
	}
	end_request(req, 1);
}
开发者ID:smanikar,项目名称:ramdisk,代码行数:34,代码来源:osprd.c

示例5: do_mcd_request

static void do_mcd_request(request_queue_t * q)
{
	test2(printk(" do_mcd_request(%ld+%ld)\n", CURRENT->sector,
	       CURRENT->nr_sectors));

		mcd_transfer_is_active = 1;
	while (current_valid()) {
		mcd_transfer();
		if (CURRENT->nr_sectors == 0) {
			end_request(CURRENT, 1);
		} else {
			mcd_buf_out = -1;	/* Want to read a block not in buffer */
			if (mcd_state == MCD_S_IDLE) {
				if (!tocUpToDate) {
					if (updateToc() < 0) {
						while (current_valid())
							end_request(CURRENT, 0);
						break;
					}
				}
				mcd_state = MCD_S_START;
				McdTries = 5;
				mcd_timer.function = mcd_poll;
				mod_timer(&mcd_timer, jiffies + 1);
			}
			break;
		}
	}
	mcd_transfer_is_active = 0;
	test2(printk(" do_mcd_request ends\n"));
}
开发者ID:NandanPhadke,项目名称:oslab,代码行数:31,代码来源:mcd.c

示例6: do_pd_write_done

static void do_pd_write_done( void )

{       int	unit = pd_unit;
	long    saved_flags;

        if (pd_wait_for(unit,STAT_READY,"do_pd_write_done") & STAT_ERR) {
                pi_disconnect(PI);
                if (pd_retries < PD_MAX_RETRIES) {
                        pd_retries++;
                        pi_do_claimed(PI,do_pd_write_start);
                        return;
                }
		spin_lock_irqsave(&io_request_lock,saved_flags);
                end_request(0);
                pd_busy = 0;
		do_pd_request(NULL);
		spin_unlock_irqrestore(&io_request_lock,saved_flags);
                return;
        }
        pi_disconnect(PI);
	spin_lock_irqsave(&io_request_lock,saved_flags);
        end_request(1);
        pd_busy = 0;
	do_pd_request(NULL);
	spin_unlock_irqrestore(&io_request_lock,saved_flags);
}
开发者ID:TitaniumBoy,项目名称:lin,代码行数:26,代码来源:pd.c

示例7: Virtual_blkdev_do_request

static void Virtual_blkdev_do_request(struct request_queue *q)
{
	struct request *req;
	while ((req = elv_next_request(q)) != NULL) 
	{
		if ((req->sector + req->current_nr_sectors) << 9> VIRTUAL_BLKDEV_BYTES) 
		{
		printk(KERN_ERR VIRTUAL_BLKDEV_DISKNAME": bad request: block=%llu, count=%u\n",
			(unsigned long long)req->sector,
			req->current_nr_sectors);
		end_request(req, 0);
		continue;
	    }/*endif*/
		switch (rq_data_dir(req)) 
		{
			case READ:
				memcpy(req->buffer,Virtual_blkdev_data + (req->sector << 9),
					req->current_nr_sectors << 9);
				end_request(req, 1);
				break;
			case WRITE:
				memcpy(Virtual_blkdev_data + (req->sector << 9),
					req->buffer, req->current_nr_sectors << 9);
				end_request(req, 1);
				break;
			default:
				/* No default because rq_data_dir(req) is 1 bit */
				break;
		}
	}/*endwhile*/
}
开发者ID:gatieme,项目名称:LDD-LinuxDeviceDrivers,代码行数:31,代码来源:Virtual_blkdev.c

示例8: get_address

 void partition_resolver_simple::handle_pending_requests(std::deque<request_context_ptr>& reqs, error_code err)
 {
     for (auto& req : reqs)
     {
         if (err == ERR_OK)
         {
             rpc_address addr;
             err = get_address(req->partition_index, addr);
             if (err == ERR_OK)
             {
                 end_request(std::move(req), err, addr);
             }
             else
             {
                 call(std::move(req), true);
             }
         }
         else if (err == ERR_HANDLER_NOT_FOUND)
         {
             end_request(std::move(req), err, rpc_address());
         }
         else
         {
             call(std::move(req), true);
         }
     }
     reqs.clear();
 }
开发者ID:Microsoft,项目名称:rDSN,代码行数:28,代码来源:partition_resolver_simple.cpp

示例9: osprd_process_request

/*
 * osprd_process_request(d, req)
 *	 Called when the user reads or writes a sector.
 *	 Should perform the read or write, as appropriate.
 */
static void osprd_process_request(osprd_info_t *d, struct request *req)
{
	void *data_offset;
	unsigned int data_length;

	if (!blk_fs_request(req)) {
		end_request(req, 0);
		return;
	}

	// EXERCISE: Perform the read or write request by copying data between
	// our data array and the request's buffer.
	// Hint: The 'struct request' argument tells you what kind of request
	// this is, and which sectors are being read or written.
	// Read about 'struct request' in <linux/blkdev.h>.
	// Consider the 'req->sector', 'req->current_nr_sectors', and
	// 'req->buffer' members, and the rq_data_dir() function.

	data_offset = d->data + (SECTOR_SIZE * req->sector);
	data_length = req->current_nr_sectors * SECTOR_SIZE;

	// TODO: include a test for out-of-range read/writes
	if (rq_data_dir(req) == WRITE)
		memcpy(data_offset, req->buffer, data_length);
	else if (rq_data_dir(req) == READ)
		memcpy(req->buffer, data_offset, data_length);
	else {
		eprintk("Unrecognized command.\n");
		end_request(req, 0);
	}

	end_request(req, 1);
}
开发者ID:akhahaha,项目名称:os-ramdisk,代码行数:38,代码来源:osprd.c

示例10: request_exemple

static void request_exemple(request_queue_t * rqueue)
{
	unsigned long secteur_debut;
	unsigned long nb_secteurs;
	struct request * rq;

	while ((rq = elv_next_request(rqueue)) != NULL) {
		if (! blk_fs_request(rq)) {
			end_request(rq, 0);
			continue;
		}
		
		/*
		 * Les numeros de secteurs pour le transfert correspondent 
		 * a des secteurs de 512 octets... -> convertir.
		 */
		secteur_debut = rq->sector * 512 / lg_sect_exemple;
		nb_secteurs   = rq->current_nr_sectors * 512 / lg_sect_exemple;
		if (secteur_debut + nb_secteurs > nb_sect_exemple) {
			end_request(rq,1);
			continue;
		}
		if (rq_data_dir(rq)) /* write */
			memmove(& data_exemple[secteur_debut * lg_sect_exemple],
			        rq->buffer,
			        nb_secteurs * lg_sect_exemple);
		else /* read */
			memmove(rq->buffer,
			        & data_exemple[secteur_debut * lg_sect_exemple],
			        nb_secteurs * lg_sect_exemple);
		end_request(rq, 1);
	}
}
开发者ID:YorkZ,项目名称:docs_utils,代码行数:33,代码来源:exemple_05.c

示例11: mem_block_requeut_fn

static void mem_block_requeut_fn(struct request_queue* q)
{
    struct request* req = NULL;
   while(NULL != (req = elv_next_request(q))) 
   {
       if(req -> sector + req -> current_nr_sectors > get_capacity(req->rq_disk))
       {
           end_request(req,0);
          // return 0;
          LogPath();
          continue;
       }
  //  Log("sector:%d,current_nr_sectors:%d",req->sector,req->current_nr_sectors);
       switch(rq_data_dir(req))
       {
           case READ:
           {
               memcpy(req->buffer,g_mem_buf + (req->sector << 9),req->current_nr_sectors << 9);
               end_request(req,1);
               break;
           }
           case WRITE:
           {
               memcpy(g_mem_buf + (req->sector << 9), req->buffer,req->current_nr_sectors << 9);
               end_request(req,1);
                break;
           }
           default:
                Log("[Error] Unknown request...");
				break;
             //   return 0;
       }
   }
}
开发者ID:laitianli,项目名称:loongson-linux-2.6.36-3_mips,代码行数:34,代码来源:block_demo.c

示例12: do_mbd_request

static void do_mbd_request(request_queue_t * q)
{
	int result = 0;
	struct request *req;

	while ((req = elv_next_request(q)) != NULL) {
		int minor = req->rq_disk->first_minor;

		switch (rq_data_dir(req)) {
		case READ:
			result = MamboBogusDiskRead(minor,
						    req->buffer, req->sector,
						    req->current_nr_sectors);
			break;
		case WRITE:
			result = MamboBogusDiskWrite(minor,
						     req->buffer, req->sector,
						     req->current_nr_sectors);
		};

		if (result)
			end_request(req, 0);	/* failure */
		else
			end_request(req, 1);	/* success */
	}
}
开发者ID:BackupTheBerlios,项目名称:arp2-svn,代码行数:26,代码来源:mambo_bd.c

示例13: do_pd_read_drq

static void do_pd_read_drq( void )

{       int	unit = pd_unit;
	long    saved_flags;

	while (1) {
            if (pd_wait_for(unit,STAT_DRQ,"do_pd_read_drq") & STAT_ERR) {
                pi_disconnect(PI);
                if (pd_retries < PD_MAX_RETRIES) {
                        pd_retries++;
                        pi_do_claimed(PI,do_pd_read_start);
                        return;
                }
		spin_lock_irqsave(&io_request_lock,saved_flags);
                end_request(0);
                pd_busy = 0;
		do_pd_request(NULL);
		spin_unlock_irqrestore(&io_request_lock,saved_flags);
                return;
            }
            pi_read_block(PI,pd_buf,512);
            pd_count--; pd_run--;
            pd_buf += 512;
	    pd_block++;
	    if (!pd_run) break;
	    if (!pd_count) pd_next_buf(unit);
        }
        pi_disconnect(PI);
	spin_lock_irqsave(&io_request_lock,saved_flags);
        end_request(1);
        pd_busy = 0;
	do_pd_request(NULL);
	spin_unlock_irqrestore(&io_request_lock,saved_flags);
}
开发者ID:TitaniumBoy,项目名称:lin,代码行数:34,代码来源:pd.c

示例14: do_z2_request

static void do_z2_request(struct request_queue *q)
{
	struct request *req;
	while ((req = elv_next_request(q)) != NULL) {
		unsigned long start = req->sector << 9;
		unsigned long len  = req->current_nr_sectors << 9;

		if (start + len > z2ram_size) {
			printk( KERN_ERR DEVICE_NAME ": bad access: block=%lu, count=%u\n",
				req->sector, req->current_nr_sectors);
			end_request(req, 0);
			continue;
		}
		while (len) {
			unsigned long addr = start & Z2RAM_CHUNKMASK;
			unsigned long size = Z2RAM_CHUNKSIZE - addr;
			if (len < size)
				size = len;
			addr += z2ram_map[ start >> Z2RAM_CHUNKSHIFT ];
			if (rq_data_dir(req) == READ)
				memcpy(req->buffer, (char *)addr, size);
			else
				memcpy((char *)addr, req->buffer, size);
			start += size;
			len -= size;
		}
		end_request(req, 1);
	}
}
开发者ID:PennPanda,项目名称:linux-repo,代码行数:29,代码来源:z2ram.c

示例15: do_pd_request

static void do_pd_request (request_queue_t * q)
{
	int	unit;

        if (pd_busy) return;
repeat:
        if (QUEUE_EMPTY || (CURRENT->rq_status == RQ_INACTIVE)) return;
        INIT_REQUEST;

        pd_dev = minor(CURRENT->rq_dev);
	pd_unit = unit = DEVICE_NR(CURRENT->rq_dev);
        pd_block = CURRENT->sector;
        pd_run = CURRENT->nr_sectors;
        pd_count = CURRENT->current_nr_sectors;

        if ((pd_dev >= PD_DEVS) || 
	    ((pd_block+pd_count) > pd_hd[pd_dev].nr_sects)) {
                end_request(0);
                goto repeat;
        }

	pd_cmd = rq_data_dir(CURRENT);
        pd_buf = CURRENT->buffer;
        pd_retries = 0;

	pd_busy = 1;
        if (pd_cmd == READ) pi_do_claimed(PI,do_pd_read);
        else if (pd_cmd == WRITE) pi_do_claimed(PI,do_pd_write);
        else {  pd_busy = 0;
		end_request(0);
                goto repeat;
        }
}
开发者ID:fgeraci,项目名称:cs518-sched,代码行数:33,代码来源:pd.c


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