- 浏览: 616884 次
- 性别:
- 来自: 上海
-
文章分类
最新评论
-
月光杯:
问题解决了吗?
Exceptions in HDFS -
iostreamin:
神,好厉害,这是我找到的唯一可以ac的Java代码,厉害。
[leetcode] word ladder II -
standalone:
One answer I agree with:引用Whene ...
How many string objects are created? -
DiaoCow:
不错!,一开始对这些确实容易犯迷糊
erlang中的冒号 分号 和 句号 -
standalone:
Exception in thread "main& ...
one java interview question
/* * fallocate - utility to use the fallocate system call * * Copyright (C) 2008 Red Hat, Inc. All rights reserved. * Written by Eric Sandeen <sandeen@redhat.com> * * cvtnum routine taken from xfsprogs, * Copyright (c) 2003-2005 Silicon Graphics, Inc. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation. * * This program is distributed in the hope that it would be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software Foundation, * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include <sys/stat.h> #include <sys/syscall.h> #include <sys/types.h> #include <fcntl.h> #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <ctype.h> #include <linux/falloc.h> void usage(void) { printf("Usage: fallocate [-n] [-o offset] -l length filename\n"); exit(EXIT_FAILURE); } #define EXABYTES(x) ((long long)(x) << 60) #define PETABYTES(x) ((long long)(x) << 50) #define TERABYTES(x) ((long long)(x) << 40) #define GIGABYTES(x) ((long long)(x) << 30) #define MEGABYTES(x) ((long long)(x) << 20) #define KILOBYTES(x) ((long long)(x) << 10) long long cvtnum(char *s) { long long i; char *sp; int c; i = strtoll(s, &sp, 0); if (i == 0 && sp == s) return -1LL; if (*sp == '\0') return i; if (sp[1] != '\0') return -1LL; c = tolower(*sp); switch (c) { case 'k': return KILOBYTES(i); case 'm': return MEGABYTES(i); case 'g': return GIGABYTES(i); case 't': return TERABYTES(i); case 'p': return PETABYTES(i); case 'e': return EXABYTES(i); } return -1LL; } int main(int argc, char **argv) { int fd; char *fname; int opt; loff_t length = -2LL; loff_t offset = 0; int falloc_mode = 0; int error; while ((opt = getopt(argc, argv, "nl:o:")) != -1) { switch(opt) { case 'n': /* do not change filesize */ falloc_mode = FALLOC_FL_KEEP_SIZE; break; case 'l': length = cvtnum(optarg); break; case 'o': offset = cvtnum(optarg); break; default: usage(); } } if (length == -2LL) { printf("Error: no length argument specified\n"); usage(); } if (length <= 0) { printf("Error: invalid length value specified\n"); usage(); } if (offset < 0) { printf("Error: invalid offset value specified\n"); usage(); } if (optind == argc) { printf("Error: no filename specified\n"); usage(); } fname = argv[optind++]; /* Should we create the file if it doesn't already exist? */ fd = open(fname, O_WRONLY|O_CREAT); if (fd < 0) { perror("Error opening file"); exit(EXIT_FAILURE); } error = fallocate(fd, falloc_mode, offset, length); // error = syscall(SYS_fallocate, fd, falloc_mode, offset, length); if (error < 0) { perror("fallocate failed"); exit(EXIT_FAILURE); } close(fd); return 0; }
发表评论
-
std::map
2017-08-06 22:41 639std::map<char,int> my ... -
lost on Py_DECREF/INCREF when handling PyList_Append in Python C extension
2015-11-03 21:41 1070The main hint is in the docs, i ... -
An Example of Using std::tr1::bind
2014-03-10 16:49 1531#include <iostream> #i ... -
c++中的virtual inheritance
2014-01-27 10:20 815http://stackoverflow.com/questi ... -
Java的Generics和c++的Template到底有什么不同?
2012-12-27 16:21 3356先了解Java的Generics: 根据Java的文档,Jav ... -
Calculating Permutations and Job Interview Questions
2011-06-18 17:44 964http://www.bearcave.com/random_ ... -
字符串指针、字符数组的sizeof和strlen结果
2010-09-27 08:36 1470int main(){ char *p1=" ... -
code snippet
2010-09-27 08:31 935char temp[3]; char temp2[3]; ... -
虚继承
2010-09-26 09:03 977http://www.cppblog.com/franksun ... -
调整堆的算法
2010-09-25 10:34 1149Begin adjustHeap(A[], i) // He ... -
multiset usage as heap
2010-09-24 21:37 1459Middle number There is a seque ... -
虚函数表又是怎样实现的?
2010-09-20 22:01 1325每个含有虚函数的类 ... -
正整数分解算法
2010-09-19 16:56 4048问题:将以正整数n表 ... -
异或运算法则
2010-09-14 09:47 22061. a ^ b = b ^ a 2 ... -
常量字符串为什么位于静态存储区
2010-09-13 22:41 1267http://hi.baidu.com/%D0%C7%BB%F ... -
errno.h
2010-08-10 08:46 1525查看错误代码errno是调试程序的一个重要方法。当linuc ... -
Test performance of allocating a zeroed file via various methods
2010-08-07 22:09 1114/* * Test performance of a ... -
how to reverse the word sequence in a sentence?
2010-07-06 22:01 1237For example, "Welcome ... -
c++ dynamic binding
2010-07-06 21:20 914Good tutorial about c++ dynamic ... -
deep copy & shallow copy
2010-07-06 20:57 1139A shallow copy of an object c ...
相关推荐
cstmt = conn.prepareCall("{call test_ref_cursor.test_ref_cursor(?, ?)}"); ``` #### 步骤3:注册REF Cursor输出参数 为了能够接收存储过程返回的REF Cursor,我们需要使用`registerOutParameter`方法注册输出...
HOW TO USE THE CALLGATE TECHNIQUE PAGING ISSUES SUMMARY Chapter 11: Portable Executable File Format OVERVIEW OF A PE FILE STRUCTURE OF A PE FILE RELATIVE VIRTUAL ADDRESS DETAILS OF THE PE ...
HOW TO USE THE CALLGATE TECHNIQUE PAGING ISSUES SUMMARY Chapter 11: Portable Executable File Format OVERVIEW OF A PE FILE STRUCTURE OF A PE FILE RELATIVE VIRTUAL ADDRESS DETAILS OF THE PE ...
How to use TaskMatch Environments in UltraEdit and UEStudio Configure FTP backup Save a local copy of your files when you transfer them to FTP directories Encrypt and Decrypt Text Files Use UltraEdit ...
The book also discusses how to use the free integrated development environment, ebe, designed by the author specifically to meet the needs of assembly language programmers. Ebe is a C++ program which...
We will make use of RegQueryValueEx API call to get the information. LONG RegQueryValueEx( HKEY hKey, // handle to key to query LPTSTR lpValueName, // address of name of value to query LPDWORD ...
Complete source included to demonstrate how to translate a long to red, green and blue values<END><br>35,sleep2.zip This is a small project showing how to use the Sleep API call from within your ...
This project can run as root to call system service IPC from normal apps. You can find the native part here Use This module simple demonstrates how to call the PowerManager.goToSleep(long uptimeMillis...
In which we call services and respond to service requests. 9 Recording and replayingmessages 129 In which we use bag files to record and replaymessages. 10 Conclusion 137 In which we preview some ...
Application memory tuning provides more of the computer's virtual memory to applications by providing less virtual memory to the operating system. Although a system having less than 2 GB of physical ...
An example script for how to use the function is given as iritest.m. This is also the script that generated the attached screenshot. It took a little less than 15 minutes to run on my computer. As...
In this chapter, you’ll explore the foundation of debugging, namely, a system call responsible for a process attaching itself to another process: ptrace. 14. Dynamic Frameworks With dynamic ...
Familiarize yourself with the generation of Metasploit resource files and use the Metasploit Remote Procedure Call to automate exploit generation and execution Exploit the Remote File Inclusion to ...
- **Definition:** How to define and call procedures. - **Procedure Calls:** Understanding how parameters are passed and returned. - **Non-Local References:** Working with variables outside the scope ...
The sample application includes how to use the Windows API for doing file operations, putting an application into the system tray<END><br>51,cwindowontop.zip This little routine will, if included ...
It's pretty easy to use. After installing it, you just need to tell Visual C++ where to find the included header and library file. Then it can be used with any C/C++ project simply by adding the ...
- **Pointers to Structures**: How to use pointers to access and manipulate the fields of structures. - **Defining Your Own Types**: Explanation of how to create custom data types using `typedef`. ###...
Use the Metasploit Remote Procedure Call (MSFRPC) to automate exploit generation and execution Use Python’s Scrapy, network, socket, office, Nmap libraries, and custom modules Parse Microsoft Office ...
All programming languages that can call to such functions and to operate these types of data in the programs executed under Windows, can use this API. In particular, the languages C ++, Pascal, ...