CN105808550B - A kind of method and device accessing file - Google Patents
A kind of method and device accessing file Download PDFInfo
- Publication number
- CN105808550B CN105808550B CN201410840910.0A CN201410840910A CN105808550B CN 105808550 B CN105808550 B CN 105808550B CN 201410840910 A CN201410840910 A CN 201410840910A CN 105808550 B CN105808550 B CN 105808550B
- Authority
- CN
- China
- Prior art keywords
- file
- handle
- value
- thread
- handle value
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Active
Links
Abstract
The embodiment of the present invention provides a kind of method and device for accessing file, is related to computing technique field, realizes standard input, the output, wrong file of linux system adaptation vxWorks system, reduces to the modification complexity for migrating application in vxWorks system;If the handle value that scheme provided by the invention includes: first position in the handle set of thread is preset value, handle value of the handle value of first position in global handle set as the first file is obtained;Wherein, first position is position of the handle value of preset first file in handle set;First file is standard files input, standard output file, any one in standard error file;If the handle value of first position is non-default value in the handle set of thread, handle value of the handle value of the first position in the handle set of thread as the first file is obtained;Access the file of the handle value instruction of the first file.The present invention is for accessing file.
Description
Technical field
The present invention relates to computer field more particularly to a kind of method and devices for accessing file.
Background technique
With the development of data communication technology, original vxWorks real time operating system be can no longer meet newly in hardware
Support, cost and new function etc. demand, equipment vendor gradually attempts to move to vxWorks real time operating system
Linux system.
There are multiple applications in vxWorks system, each application can correspond to multiple tasks, can when executing each task
To access independent standard input, output, wrong file, can also be inputted with the standard of the read and write access system overall situation, output, mistake
File;And in linux system, there is also multiple applications, each application can correspond to multiple processes or thread, executive process
When access the input of independent standard, output, wrong file, standard input, the output, mistake of share and access process when execution thread
File;
Therefore, the application in vxWorks system is moved into linux system, in order to adapt to the access standard of linux system
Input exports, the mode of wrong file, needs to modify to the application migrated in vxWorks system, if
The task of vxWorks corresponds to Linux process, then file access mode is from shared model, (the shared standard of access system is defeated
Enter, export, wrong file) become not shared model (accessing the input of independent standard, output, wrong file), or if
VxWorks task corresponds to Linux thread, and never shared model becomes shared model.
And the modification to application, need to carry out the logic of application big adjustment, modification complexity is high.
Summary of the invention
The embodiment of the present invention provides a kind of method and device for accessing file, realizes that linux system is adapted to vxWorks system
Standard input, the output, wrong file of system, reduce to the modification complexity for migrating application in vxWorks system.
In order to achieve the above objectives, the embodiment of the present invention adopts the following technical scheme that
In a first aspect, providing a kind of method for accessing file, it is applied to (SuSE) Linux OS, the (SuSE) Linux OS
Applications trigger thread is executed, when accessing the first file during executing the thread, which comprises
If the handle value of first position is preset value in the handle set of the thread, the is obtained in global handle set
Handle value of the handle value of one position as first file;Wherein, the first position is preset first file
Position of the handle value in handle set;First file is standard files input, standard output file, standard error text
Any one in part;
If the handle value of first position described in the handle set of the thread is non-default value, the thread is obtained
Handle value of the handle value of the first position in handle set as first file;
Access the file of the handle value instruction of first file.
Second aspect, the device for providing a kind of access file applied to (SuSE) Linux OS include:
First acquisition unit obtains if the handle value for first position in the handle set of the thread is preset value
Take the handle value of first position in global handle set as the handle value of first file;Wherein, the first position is
Position of the handle value of preset first file in handle set;First file is standard files input, standard
Any one in output file, standard error file;
If the handle value of first position described in the handle set of the thread is non-default value, the thread is obtained
Handle value of the handle value of the first position in handle set as first file;
Access unit, the file that the handle value for accessing first file indicates.
The embodiment of the present invention provides a kind of method and device for accessing file, is applied to (SuSE) Linux OS, operating system
Execute applications trigger thread;Preset value, instruction access are configured to by the handle value of first position in the handle set by thread
The file shared when the file of first position using system;It configures the handle value of first position in the handle set of thread to non-
Preset value, instruction access independent file when accessing the file of first position;In this way, the process access file of execution thread then may be used
Corresponding file is accessed according to the handle value in the handle set of thread, realizes that linux system is adapted to vxWorks system standard
Input, output, wrong file, reduce to the modification complexity for migrating application in vxWorks system;It solves in the prior art,
When the application in vxWorks system is moved to linux system, need to carry out the logic of the application in vxWorks system
Big adjustment, the high problem of modification complexity.
Detailed description of the invention
In order to illustrate the technical solution of the embodiments of the present invention more clearly, below will be in embodiment or description of the prior art
Required attached drawing is briefly described, it should be apparent that, the accompanying drawings in the following description is only some realities of the invention
Example is applied, it for those of ordinary skill in the art, without creative efforts, can also be according to these attached drawings
Obtain other attached drawings.
Fig. 1 is a kind of method flow schematic diagram for accessing file provided in an embodiment of the present invention;
Fig. 2 is a kind of schematic diagram of a scenario provided in an embodiment of the present invention;
Fig. 3 is the method flow schematic diagram of another access file provided in an embodiment of the present invention;
Fig. 4 is another schematic diagram of a scenario provided in an embodiment of the present invention;
Fig. 5 is a kind of apparatus structure schematic diagram for accessing file provided in an embodiment of the present invention;
Fig. 6 is the apparatus structure schematic diagram of another access file provided in an embodiment of the present invention.
Specific embodiment
Following will be combined with the drawings in the embodiments of the present invention, and technical solution in the embodiment of the present invention carries out clear, complete
Site preparation description, it is clear that described embodiments are only a part of the embodiments of the present invention, instead of all the embodiments.It is based on
Embodiment in the present invention, it is obtained by those of ordinary skill in the art without making creative efforts every other
Embodiment shall fall within the protection scope of the present invention.
Embodiment one
The embodiment of the present invention one provides a kind of method for accessing file, is applied to (SuSE) Linux OS, and operating system executes
Applications trigger thread, as shown in Figure 1, this method may include: when accessing the first file during execution thread
If the handle value of first position is preset value in the handle set of S101, thread, obtain in global handle set
Handle value of the handle value of first position as the first file;
Wherein, first position is position of the handle value of preset first file in handle set;First file is mark
Quasi- input file, standard output file, any one in standard error file;
Handle value is the mark of file, passes through the available unique file of the handle value of file;Optionally, handle
Value can use long binary number representation;
Handle set refers to the set including multiple handle values, and optionally, handle set can be to include multiple handle values
Array or chained list etc.;
Type (the handle of standard files input of file indicated by the handle value stored in each position in handle set
The handle value of value, the handle value of standard output file, standard error file) be it is preset, optionally, each position in handle set
The type for setting file indicated by the handle value of storage can be realized by macrodefinition;
Illustratively, if a handle collection is combined into handle count group, first position in handle set is indicated by macrodefinition
Handle value is the handle value of standard files input, and the handle value of the second position is the handle of standard output file in handle set
It is worth, the handle value of the third place is the handle value of standard error file in handle set;
It is the handle value of standard files input for handle array b [3], b0, b1 is the handle value of standard output file, b2
For the handle value of standard error file;
It should be noted that the above-mentioned handle for only illustrating each position in handle array to save in the form of illustrative
The type of value is not the restriction of the type of the handle value saved to each position in handle array, in the mistake of practical application
Cheng Zhong can be set according to actual needs, and the present invention is not specifically limited in this embodiment.
The handle set of thread refers to the handle set in thread, only enables the thread just and will use the sentence in the thread
Handle set;
Global handle set refers to the shared handle set of system, any one thread can use global handle collection
It closes;
When the handle value of first position in the handle set of thread is preset value, then explanation is not provided with the handle of the thread
The handle value of first position in set, at this time, it may be necessary to obtain the handle value of first position in global handle set.
It should also be noted that, in practical applications, preset value can be set according to actual needs;
Preferably, preset value is -1.
If the handle value of first position is non-default value in the handle set of S102, thread, the handle collection of thread is obtained
Handle value of the handle value of first position in conjunction as the first file.
The file that S103, the handle value for accessing the first file indicate;
Illustratively, in linux operating system, applications trigger thread is executed, as shown in Fig. 2, the thread control of thread
Clamp dog includes task handle array TASK_STDFD [3]={ -1,1, -1 }, and global handle collection is combined into global handle array
GLOBAL_STDFD [3]={ 3,2,4 };Wherein, by macrodefinition STDIN_FILENO (handle value of standard files input),
STDOUT_FILENO (handle value of standard output file), STDERR_FILENO (handle value of standard error file), instruction
First position in TASK_STDFD array and GLOBAL_STDFD array is standard files input handle value, and the second position is mark
Quasi- output file handle value, the third place is standard error file handle value, and preset value is -1;
When accessing standard files input, due in the task handle array (TASK_STDFD array) of thread, first
The handle value (TASK_STDFD0=-1) set is preset value, then obtains in global handle array (GLOBAL_STDFD array) the
The handle value (GLOBAL_STDFD0=3) of one position, the standard files input that access handle value 3 indicates;
When accessing standard output file, due in the task handle array (TASK_STDFD array) of thread, second
The handle value (TASK_STDFD1=1) set is non-default value, then obtains the handle value 1 of the second position in TASK_STDFD array,
The standard output file that access handle value 1 indicates;
When accessing standard error file, due in the task handle array (TASK_STDFD array) of thread, third position
The handle value (TASK_STDFD2=-1) set is preset value, then obtains in global handle array (GLOBAL_STDFD array) the
The handle value (GLOBAL_STDFD2=4) of three positions, the standard error file that access handle value 4 indicates;
Further, it in system initialization, needs to initialize global handle set;
Specifically, initializing to global handle set can be realized by following methods:
Application in system by using open function access system default file (such as/dev/console equipment text
Part), the file handle of return is obtained, the file handle of return is arranged into global handle set;
After the initialization of global handle set, if desired handle values one or more in global profile handle set are carried out
Modification, then the application in system can pass through the new file of the open function access (text different from the file accessed when initialization
Part), the new file handle value of return is obtained, the corresponding handle value in global handle set is revised as new handle value;
Illustratively, it if entered from the keyboard change into from file is inputted, needs in global profile handle set
The handle value of standard files input is modified, and output is shown to other equipment if output is shown to display and is changed into
When (such as serial port terminal), then the handle value to the standard output file in global profile handle set is needed to modify.
Illustratively, it is assumed that global handle collection is combined into handle count group overall situation GLOBAL_STDFD [3], to the handle array
When initialization, by accessing the file 1 of system default, the standard files input handle value of return is obtained: 3, standard output file
Handle value: 4, standard error file handle value: 5, the file handle value of return is respectively provided in global profile handle array,
Global handle array after then initializing is GLOBAL_STDFD [3]={ 3,4,5 };
If desired modify the standard files input of system, then it can be by accessing new file 2, the standard for obtaining return is defeated
Enter the handle value of file: 1, the standard output file of system is if desired modified, then can be returned by accessing new file 3
The handle value of the standard output file returned: 2, the handle value in global handle array is revised as new handle value accordingly, is repaired
Global handle array after changing is GLOBAL_STDFD [3]={ 1,2,5 }.
The embodiment of the present invention provides a kind of method for accessing file, is applied to (SuSE) Linux OS, and operating system execution is answered
With triggering thread;Preset value, instruction access first are configured to by the handle value of first position in the handle set by thread
The file shared when the file set using system;It configures the handle value of first position in the handle set of thread to non-default
Value, instruction access independent file when accessing the file of first position;In this way, the process access file of execution thread then can basis
Handle value in the handle set of thread accesses corresponding file, realizes that linux system adaptation vxWorks system standard is defeated
Enter, export, wrong file, reducing to the modification complexity for migrating application in vxWorks system;Solve in the prior art,
When application in vxWorks system is moved to linux system, need to carry out the logic of the application in vxWorks system big
Adjustment, the high problem of modification complexity.
Embodiment two
Second embodiment of the present invention provides a kind of methods for accessing file, are applied to (SuSE) Linux OS, and operating system executes
Applications trigger thread, as shown in figure 3, this method may include:
S301, preset value is initialized as to each position handle value in the handle set of thread;
Illustratively, it is assumed that the handle collection of thread is combined into handle count group TASK_STDFD [3], carries out just to the handle array
After beginningization, the initialization value of the handle value of each position is preset value in the array, it is assumed that preset value is -1, then initializes
Handle array afterwards are as follows: TASK_STDFD [3]={ -1, -1, -1 }.
When accessing the first file during execution thread, then following steps are executed:
Whether S302, the handle value for judging first position in the handle set of thread are preset value;
If so, executing S303;
If it is not, then executing S304.
Wherein, first position is position of the handle value of preset first file in handle set;First file is mark
Quasi- input file, standard output file, any one in standard error file.
Illustratively, it is assumed that the handle collection of thread is combined into handle count group TASK_STDFD [3], and is indicated by macrodefinition,
TASK_STDFD0 is the handle value of standard files input, TASK_STDFD1 is the handle value of standard output file, TASK_
STDFD2 is the handle value of standard error file;
If the first file is input file, first position is the TASK_ in handle array TASK_STDFD [3]
STDFD0。
S303, handle value of the handle value of first position in global handle set as the first file is obtained;
It should be noted that S303 is identical as the process of S101, no longer repeated herein.
S304, handle value of the handle value as the first file for obtaining first position in the handle set of thread;
It should be noted that S304 is identical as the process of S102, no longer repeated herein.
The file that S305, the handle value for accessing the first file indicate.
The file for accessing the handle value instruction of the first file can be realized by following two mode:
First way: the file of handle value instruction is accessed by handle value;
The second way: the file of stream file instruction is accessed by stream file;
When obtaining standard input, output, wrong file using C library standard stdin, stdout, stderr keyword, then
Need to access the file of stream file instruction by stream file;
Specifically, accessing the file of stream file instruction by stream file may include following three kinds of situations:
If the second position is sky in the stream file set of situation 1, thread, the file of the first stream file instruction is accessed;
Wherein, the second position is position of the stream file of preset first file in stream file set;
First stream file is stream file corresponding with the handle value of the first file;
Optionally, stream file and handle value are one-to-one relationships, and the corresponding relationship of stream file and handle value can be with
The form of database stores, and as shown in table 1, illustrates the corresponding relationship of a kind of stream file and handle value;
Table 1
Stream file | Handle value |
Stream file 1 | Handle value 1 |
Stream file 2 | Handle value 2 |
Stream file 3 | Handle value 3 |
…… | …… |
It should be noted that table 1 only illustrates the form and content of database in table form, it is not logarithm
According to the specific restriction of the form and content in library;Certainly, database can also be stored in the form of other, also may include others
Content, the present invention are not specifically limited in this embodiment.
It should also be noted that, the corresponding relationship of stream file and handle value can also in other way (non-database)
Storage, the present invention are not specifically limited in this embodiment.
Stream file is the mark of file, passes through the available unique file of the stream file of file;Optionally, stream text
Part can be indicated with structural body;
Stream file set refers to the set including multiple stream files, and optionally, stream file set can be to include multiple streams
The array of file or chained list etc.;
Type (the stream of standard files input of file indicated by the stream file stored in each position in stream file set
File, the stream file of standard output file, standard error file stream file) be it is preset, optionally, in stream file set
Position can be realized with the type with file indicated by the stream file that stores in the position by definition of keywords;
Illustratively, it if a stream file collection is combined into stream file array, is indicated in stream file set by definition of keywords
The stream file of first position is the stream file of standard files input, and the stream file of the second position is standard output in stream file set
The stream file of file, the stream file of the third place is the stream file of standard error file in stream file set;
It is the stream file of standard files input for stream file array c [3], c0, c1 is the stream file of standard output file,
C2 is the stream file of standard error file.
The second position is that sky refers in the second position of stream file set without storage times in the stream file set of thread
What stream file.
If the second position is not empty in the stream file set of situation 2, thread, and the corresponding handle value of the second stream file and the
The handle value of one file is identical, then accesses the file of the second stream file instruction;
Wherein, the second stream file is the stream file of the second position in the stream file set of thread;
If the second position is not empty in the stream file set of situation 3, thread, and the corresponding handle value of the second stream file and the
The handle value of one file is different, then accesses the file of the 4th stream file instruction;
Wherein, the 4th stream file is stream file corresponding with the handle value of the first file;
Illustratively, as shown in figure 4, the thread control block of thread include stream file array TASK_STDFP [3]=it is empty,
Stream file 2, stream file 3 }, by keyword definition stdin (standard input stream file), stdout (standard output stream file),
Stderr (standard error stream file) instruction, TASK_STDFP0 are the stream file of standard files input, and TASK_STDFP1 is mark
The stream file of quasi- output file, TASK_STDFP2 are the stream file of standard error file;
As shown in figure 4, the thread control block of thread further includes task handle array TASK_STDFD [3]={ -1,1,3 },
Global handle collection is combined into global handle array GLOBAL_STDFD [3]={ 2,4,6 } and is indicated by macrodefinition, TASK_STDFD0,
GLOBAL_STDFD0 is the handle value of standard files input, and TASK_STDFD1, GLOBAL_STDFD1 are standard output file
Handle value, TASK_STDFD2, GLOBAL_STDFD2 are the handle value of standard error file;
When accessing standard files input, since the first position (TASK_STDFP0) of stream file array is sky, then exist first
The handle value that first position is obtained in task handle array TASK_STDFD [3], due to TASK_STDFD0=-1, then in the overall situation
The handle value (GLOBAL_STDFD0=2) that first position is obtained in handle array then obtains the handle value pair of standard files input
The stream file 1 answered, the file that access stream file 1 indicates;
When accessing standard output file, since the second position (TASK_STDFP1) of stream file array is not sky, it is assumed that stream
The corresponding handle value of file 2 is 1, identical as handle value (TASK_STDFD1=1) of standard output file, then accesses stream file 2
The file of instruction;
When accessing standard error file, since the third place (TASK_STDFP2) of stream file array is not sky, it is assumed that stream
The corresponding handle value of file 3 is 4, not identical as the handle value (TASK_STDFD2=3) of standard files input, then obtains standard
The corresponding stream file 4 of the handle value of wrong file, the file that access stream file 4 indicates.
Further, if accessing the file of the handle value instruction of the first file, the side in S305 using the second way
Method can also include:
The stream file for accessing the second file is updated to the third place in the stream file set of thread;
Wherein, the third place is position of the stream file of preset second file in stream file set;Second file is
Standard files input, standard output file, any one in standard error file;
Illustratively, based on the example in S305, by stream file array TASK_STDFP [3]=empty, stream file 2,
Stream file 3 } it updates are as follows: TASK_STDFP [3]={ stream file 1, stream file 2, stream file 4 }.
Further, if accessing the file of the handle value instruction of the first file, the side in S305 using first way
Method can also include: the handle value that dynamic modifies in handle set according to demand.
Preferably, using may include default modification condition, handle collection when modification condition meets in instruction thread is preset
The handle value of the 4th position needs to be modified in conjunction;4th position is position of the handle value of third file in handle set;
Third file is standard files input, standard output file, any one in standard error file;
Illustratively, entered from the keyboard change into from file can be inputted for some application by presetting modification condition.
It should be noted that default modification condition, this hair can be set according to actual needs during practical application
It is bright to be not specifically limited in this embodiment.
Specifically, the handle value in dynamic modification handle set according to demand, it can be with are as follows: when default modification condition satisfaction
When, it modifies to the handle value in handle set.
Further, when default modification condition meets, the concrete modification modified to the handle value in handle set
Process can be realized by following two steps:
Step A, access preset normative document obtains the handle value that preset standard file returns;
Preset standard file is that system is pre-set, and by accessing the default file, can obtain the pre- bidding
The handle value that quasi- file returns;Optionally, preset standard file can be/dev/console.
Step B, the handle value of the 4th position in the handle set of thread is revised as to the handle of preset standard file return
Value.
Illustratively, it based on the example in S301, if the standard files input of thread accesses need to be to be modified, visits
Ask preset standard file 1, the handle value that acquisition preset standard file 1 returns: 2, then by the handle array (TASK_STDFD of thread
[3]={ -1, -1, -1 }) in the handle value (TASK_STDFD 0=-1) of standard files input be revised as 2;That is, TASK_
STDFD [3]={ 2, -1, -1 };
Further, if the standard error file of thread accesses is also required to be modified, access preset normative document 2 is obtained
The handle value for taking preset standard file 2 to return: 3;It then will be in the handle array of thread (TASK_STDFD [3]={ 2, -1, -1 })
The handle value (TASK_STDFD 2=-1) of standard error file be revised as 3;That is, TASK_STDFD [3]={ 2, -1,3 }.
The embodiment of the present invention provides a kind of method for accessing file, is applied to (SuSE) Linux OS, and operating system execution is answered
With triggering thread;Preset value, instruction access first are configured to by the handle value of first position in the handle set by thread
The file shared when the file set using system;It configures the handle value of first position in the handle set of thread to non-default
Value, instruction access independent file when accessing the file of first position;In this way, the process access file of execution thread then can basis
Handle value in the handle set of thread accesses corresponding file, realizes that linux system adaptation vxWorks system standard is defeated
Enter, export, wrong file, reducing to the modification complexity for migrating application in vxWorks system;Solve in the prior art,
When application in vxWorks system is moved to linux system, need to carry out the logic of the application in vxWorks system big
Adjustment, the high problem of modification complexity.
Embodiment three
The embodiment of the present invention three provides a kind of device 50 of access file applied to (SuSE) Linux OS, is included in behaviour
Make system, as shown in figure 5, the device 50 of access file includes:
First acquisition unit 501 obtains if the handle value for first position in the handle set of thread is preset value
Handle value of the handle value of first position as the first file in global handle set;Wherein, first position is preset first
Position of the handle value of file in handle set;First file is standard files input, standard output file, standard error text
Any one in part;
If the handle value of first position is non-default value in the handle set of thread, obtain in the handle set of thread
Handle value of the handle value of first position as the first file;
Access unit 502, the file that the handle value for accessing the first file indicates.
Further, access unit 502 specifically can be also used for:
If the second position is sky in the stream file set of thread, the file of the first stream file instruction is accessed;Wherein, second
Position is position of the stream file of preset first file in stream file set;First stream file is the handle with the first file
It is worth corresponding stream file;
Alternatively,
If the second position is not empty in the stream file set of thread, and the corresponding handle value of the second stream file and the first file
Handle value it is identical, then access the second stream file instruction file;Wherein, the second stream file is the in the stream file set of thread
The stream file of two positions;
Alternatively,
If the second position is not empty in the stream file set of thread, and the corresponding handle value of the second stream file and the first file
Handle value it is different, then access the file of the 4th stream file instruction;Wherein, the 4th stream file is the handle value pair with the first file
The stream file answered.
Further, as shown in fig. 6, the device 50 of access file can also include:
Updating unit 503, for the stream file for accessing the second file to be updated to the third in the stream file set of thread
Position;Wherein, the third place is position of the stream file of preset second file in stream file set;Second file is standard
Input file, standard output file, any one in standard error file.
Wherein, the initialization value of each position handle value is preset value in the handle set of thread.
Further, using may include default modification condition;Wherein, it presets when modification condition meets in instruction thread
The handle value of the 4th position needs to be modified in handle set;4th position is the handle value of third file in handle set
Position;Third file is standard files input, standard output file, any one in standard error file;
Further, as shown in fig. 6, the device 50 of access file can also include:
Second acquisition unit 504, for when default modification condition meets, access preset normative document to obtain pre- bidding
The handle value that quasi- file returns;
Unit 505 is modified, the handle value for the 4th position in the handle set by thread is revised as preset standard file
The handle value of return.
The embodiment of the present invention provides a kind of device 50 of access file applied to (SuSE) Linux OS, and operating system is held
Row applications trigger thread;Preset value is configured to by the handle value of first position in the handle set by thread, instruction access the
The file shared when the file of one position using system;It configures the handle value of first position in the handle set of thread to non-pre-
If value, instruction accesses independent file when accessing the file of first position;In this way, the process access file of execution thread then can root
Corresponding file is accessed according to the handle value in the handle set of thread, realizes that linux system adaptation vxWorks system standard is defeated
Enter, export, wrong file, reducing to the modification complexity for migrating application in vxWorks system;Solve in the prior art,
When application in vxWorks system is moved to linux system, need to carry out the logic of the application in vxWorks system big
Adjustment, the high problem of modification complexity.
It is apparent to those skilled in the art that for convenience and simplicity of description, the system of foregoing description,
The specific work process of device and unit, can refer to corresponding processes in the foregoing method embodiment, and details are not described herein.
In several embodiments provided herein, it should be understood that disclosed system, device and method can be with
It realizes by another way.For example, the apparatus embodiments described above are merely exemplary, for example, the unit
It divides, only a kind of logical function partition, there may be another division manner in actual implementation, such as multiple units or components
It can be combined or can be integrated into another system, or some features can be ignored or not executed.Another point, it is shown or
The mutual coupling, direct-coupling or communication connection discussed can be through some interfaces, the indirect coupling of device or unit
It closes or communicates to connect, can be electrical property, mechanical or other forms.
The unit as illustrated by the separation member may or may not be physically separated, aobvious as unit
The component shown may or may not be physical unit, it can and it is in one place, or may be distributed over multiple
In network unit.It can select some or all of unit therein according to the actual needs to realize the mesh of this embodiment scheme
's.
It, can also be in addition, the functional units in various embodiments of the present invention may be integrated into one processing unit
It is that the independent physics of each unit includes, can also be integrated in one unit with two or more units.Above-mentioned integrated list
Member both can take the form of hardware realization, can also realize in the form of hardware adds SFU software functional unit.
The above-mentioned integrated unit being realized in the form of SFU software functional unit can store and computer-readable deposit at one
In storage media.Above-mentioned SFU software functional unit is stored in a storage medium, including some instructions are used so that a computer
Equipment (can be personal computer, server or the network equipment etc.) executes the portion of each embodiment the method for the present invention
Step by step.And storage medium above-mentioned includes: USB flash disk, mobile hard disk, read-only memory (Read-Only Memory, abbreviation
ROM), random access memory (Random Access Memory, abbreviation RAM), magnetic or disk etc. are various can store
The medium of program code.
Finally, it should be noted that the above embodiments are merely illustrative of the technical solutions of the present invention, rather than its limitations;Although
Present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that: it still may be used
To modify the technical solutions described in the foregoing embodiments or equivalent replacement of some of the technical features;
And these are modified or replaceed, technical solution of various embodiments of the present invention that it does not separate the essence of the corresponding technical solution spirit and
Range.
Claims (10)
1. a kind of method for accessing file, is applied to (SuSE) Linux OS, the (SuSE) Linux OS executes applications trigger line
Journey, which is characterized in that when accessing the first file during executing the thread, which comprises
If the handle value of first position is preset value in the handle set of the thread, first is obtained in global handle set
Handle value of the handle value set as first file;Wherein, the first position is the sentence of preset first file
Position of the bin value in handle set;First file is standard files input, in standard output file, standard error file
Any one;
If the handle value of first position is non-default value in the handle set of the thread, the handle set of the thread is obtained
In the first position handle value of the handle value as first file;
Access the file of the handle value instruction of first file.
2. the method according to claim 1, wherein the text of the handle value instruction of access first file
Part, comprising:
If the second position is sky in the stream file set of the thread, the file of the first stream file instruction is accessed;Wherein, described
The second position is position of the stream file of preset first file in stream file set;First stream file for institute
State the corresponding stream file of handle value of the first file;
Alternatively,
If the second position described in the stream file set of the thread be not it is empty, and the corresponding handle value of the second stream file with it is described
The handle value of first file is identical, then accesses the file of the second stream file instruction;Wherein, second stream file is described
The stream file of the second position described in the stream file set of thread;
Alternatively,
If the second position described in the stream file set of the thread be not it is empty, and the corresponding handle value of the second stream file with it is described
The handle value of first file is different, then accesses the file of the 4th stream file instruction;Wherein, the 4th stream file is and described the
The corresponding stream file of the handle value of one file.
3. according to the method described in claim 2, it is characterized in that, in the handle value instruction for accessing first file
After file, the method also includes:
The stream file for accessing the second file is updated to the third place in the stream file set of the thread;Wherein, described
Three positions are position of the stream file of preset second file in stream file set;Second file is standard input
File, standard output file, any one in standard error file.
4. method according to claim 1-3, which is characterized in that each position in the handle set of the thread
The initialization value of handle value is preset value.
5. according to the method described in claim 4, it is characterized in that, the application includes default modification condition;Wherein, described pre-
If modification condition indicates that the handle value of the 4th position in the handle set in the thread needs when meeting to be modified;Described 4th
Position is position of the handle value of third file in handle set;The third file is standard files input, standard output
Any one in file, standard error file;
When the default modification condition meets, the method also includes:
Access preset normative document obtains the handle value that the preset standard file returns;
The handle value of 4th position in the handle set of the thread is revised as the handle value that the preset standard file returns.
6. a kind of device of the access file applied to (SuSE) Linux OS, the (SuSE) Linux OS execute applications trigger line
Journey, which is characterized in that described device includes:
First acquisition unit obtains complete if the handle value for first position in the handle set of the thread is preset value
Handle value of the handle value of first position as the first file in office's handle set;Wherein, the first position is preset institute
State position of the handle value of the first file in handle set;First file be standard files input, standard output file,
Any one in standard error file;
If the handle value of first position is non-default value in the handle set of the thread, the handle set of the thread is obtained
In the first position handle value of the handle value as first file;
Access unit, the file that the handle value for accessing first file indicates.
7. device according to claim 6, which is characterized in that the access unit is specifically used for:
If the second position is sky in the stream file set of the thread, the file of the first stream file instruction is accessed;Wherein, described
The second position is position of the stream file of preset first file in stream file set;First stream file for institute
State the corresponding stream file of handle value of the first file;
Alternatively,
If the second position described in the stream file set of the thread be not it is empty, and the corresponding handle value of the second stream file with it is described
The handle value of first file is identical, then accesses the file of the second stream file instruction;Wherein, second stream file is described
The stream file of the second position described in the stream file set of thread;
Alternatively,
If the second position described in the stream file set of the thread be not it is empty, and the corresponding handle value of the second stream file with it is described
The handle value of first file is different, then accesses the file of the 4th stream file instruction;Wherein, the 4th stream file is and described the
The corresponding stream file of the handle value of one file.
8. device according to claim 7, which is characterized in that described device further include:
Updating unit, for the stream file for accessing the second file to be updated to the third position in the stream file set of the thread
It sets;Wherein, the third place is position of the stream file of preset second file in stream file set;Described second
File is standard files input, standard output file, any one in standard error file.
9. according to the described in any item devices of claim 6-8, which is characterized in that each position in the handle set of the thread
The initialization value of handle value is preset value.
10. device according to claim 9, which is characterized in that the application includes default modification condition;Wherein, described
Default modification condition indicates that the handle value of the 4th position in the handle set in the thread needs when meeting to be modified;Described
Four positions are position of the handle value of third file in handle set;The third file is standard files input, standard is defeated
File, any one in standard error file out;
Described device further include:
Second acquisition unit, for when the default modification condition meets, access preset normative document to obtain the pre- bidding
The handle value that quasi- file returns;
Unit is modified, the handle value for the 4th position in the handle set by the thread is revised as the preset standard file
The handle value of return.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201410840910.0A CN105808550B (en) | 2014-12-30 | 2014-12-30 | A kind of method and device accessing file |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201410840910.0A CN105808550B (en) | 2014-12-30 | 2014-12-30 | A kind of method and device accessing file |
Publications (2)
Publication Number | Publication Date |
---|---|
CN105808550A CN105808550A (en) | 2016-07-27 |
CN105808550B true CN105808550B (en) | 2019-02-15 |
Family
ID=56980299
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201410840910.0A Active CN105808550B (en) | 2014-12-30 | 2014-12-30 | A kind of method and device accessing file |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN105808550B (en) |
Families Citing this family (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN109840208B (en) * | 2019-01-07 | 2022-08-05 | 烽火通信科技股份有限公司 | Method and system for detecting abnormal operation of file |
Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN1409223A (en) * | 2001-09-14 | 2003-04-09 | 北京瑞星科技股份有限公司 | Computer system and file system access method |
CN101142553A (en) * | 2003-06-25 | 2008-03-12 | 英特尔公司 | Os agnostic resource sharing across multiple computing platforms |
CN101576908A (en) * | 2009-03-12 | 2009-11-11 | 北京中星微电子有限公司 | Method and system for acquiring file handle by file name |
CN102520944A (en) * | 2011-12-06 | 2012-06-27 | 北京航空航天大学 | Method for realizing virtualization of Windows application program |
CN103677820A (en) * | 2013-12-05 | 2014-03-26 | 上海斐讯数据通信技术有限公司 | Embedded development software output method and system |
Family Cites Families (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US8468501B2 (en) * | 2010-04-21 | 2013-06-18 | International Business Machines Corporation | Partial recording of a computer program execution for replay |
-
2014
- 2014-12-30 CN CN201410840910.0A patent/CN105808550B/en active Active
Patent Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN1409223A (en) * | 2001-09-14 | 2003-04-09 | 北京瑞星科技股份有限公司 | Computer system and file system access method |
CN101142553A (en) * | 2003-06-25 | 2008-03-12 | 英特尔公司 | Os agnostic resource sharing across multiple computing platforms |
CN101576908A (en) * | 2009-03-12 | 2009-11-11 | 北京中星微电子有限公司 | Method and system for acquiring file handle by file name |
CN102520944A (en) * | 2011-12-06 | 2012-06-27 | 北京航空航天大学 | Method for realizing virtualization of Windows application program |
CN103677820A (en) * | 2013-12-05 | 2014-03-26 | 上海斐讯数据通信技术有限公司 | Embedded development software output method and system |
Also Published As
Publication number | Publication date |
---|---|
CN105808550A (en) | 2016-07-27 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN107111450B (en) | Disk partition stitching and rebalancing using partition tables | |
US9223564B2 (en) | Update systems responsive to ongoing processing at a storage system | |
CN104636414B (en) | The method of access to updated file is provided and executes the computer of this method | |
CN104516769B (en) | For the method for the switching between verifying logic zone configuration, medium and system | |
US11372834B2 (en) | Optimizing space management of tablespaces in database systems | |
CN104932933B (en) | A kind of method and device obtaining spin lock | |
CN112783640B (en) | Method and apparatus for pre-allocating memory, circuit, electronic device and medium | |
CN109241193B (en) | Distributed database processing method and device, and server cluster | |
DE102022105725A1 (en) | METHODS AND EQUIPMENT FOR PERFORMING WEIGHT AND ACTIVATION COMPRESSION AND DECOMPRESSION | |
WO2014184606A1 (en) | Identifying workload and sizing of buffers for the purpose of volume replication | |
CN105302536A (en) | Configuration method and apparatus for related parameters of MapReduce application | |
CN108052622A (en) | A kind of storage method based on non-relational database, device and equipment | |
CN104205780A (en) | Data storage method and device | |
CN105808550B (en) | A kind of method and device accessing file | |
CN109033184B (en) | Data processing method and device | |
CN109788006B (en) | Data equalization method and device and computer equipment | |
KR20150117522A (en) | Graphics state manage apparatus and method | |
US9111114B1 (en) | Method of transforming database system privileges to object privileges | |
US20170344504A1 (en) | Method for accessing a number of slave devices with registers by a master device over a network | |
CN114341847A (en) | Correspondence of external operations on containers to mutation events | |
CN107273527A (en) | A kind of Hadoop clusters and distributed system | |
CN107169115A (en) | Add the method and device of self-defined participle | |
CN111414422A (en) | Data distribution method, device, equipment and storage medium | |
CN110851245A (en) | Distributed asynchronous task scheduling method and electronic equipment | |
CN113272785A (en) | Method for mounting file system, terminal equipment and storage medium |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
C06 | Publication | ||
PB01 | Publication | ||
C10 | Entry into substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |