



技术领域technical field
本发明涉及计算机技术领域,特别是涉及一种文件的管理方法、装置、设备及介质。The present invention relates to the field of computer technology, and in particular, to a file management method, device, device and medium.
背景技术Background technique
随着科技的快速发展,数据管理系统需要进行大量的数据的读、写操作。因此,对于一个数据管理系统来说,文件的管理是一项十分重要的技术。With the rapid development of science and technology, the data management system needs to read and write a large amount of data. Therefore, for a data management system, file management is a very important technology.
在数据管理系统中,当一个进程创建或打开一个文件时,系统会为该文件分配一个文件描述符,用来唯一标识已经被打开的文件。并且,系统对一个进程能打开的文件数量进行限制,也就是说,一个进程可以获得的文件描述符是有限的。当一个进程打开的文件数量达到该限制数量时,再次打开文件将会出现打开失败的情况,同时也无法获取到相应的文件描述符。In a data management system, when a process creates or opens a file, the system assigns a file descriptor to the file to uniquely identify the opened file. Moreover, the system limits the number of files that a process can open, that is, the file descriptors that a process can obtain are limited. When the number of files opened by a process reaches the limit, opening the file again will fail to open the file, and the corresponding file descriptor cannot be obtained.
现有技术中针对以上情况,需要通过修改系统中限制参数的方式,从而提高一个进程可打开文件的数量,以避免产生文件打开失败的情况。但是,由于更改限制参数后可能会对系统的其他操作也造成影响,因此不便于频繁更改;并且每次更改系统参数操作繁琐,造成时间资源的浪费,降低了用户体验感。因此,提供一种便捷、高效的文件管理方法是十分必要的。In view of the above situation in the prior art, it is necessary to modify the method of limiting parameters in the system, thereby increasing the number of files that can be opened by one process, so as to avoid the situation of file opening failure. However, since changing the restriction parameters may also affect other operations of the system, it is inconvenient to change frequently; and changing the system parameters every time is cumbersome, resulting in a waste of time and resources and reducing the user experience. Therefore, it is very necessary to provide a convenient and efficient file management method.
发明内容SUMMARY OF THE INVENTION
本发明的目的是提供一种文件的管理方法、装置、设备及介质。能够在进程打开的文件数达到系统要求上限时,通过删除目标描述符并关闭相应的文件的方式,使进程可以再次正常打开新的文件。避免对系统参数进行修改的繁琐过程,保证文件能够高效、便捷地进行正常操作,提高用户的体验感。The purpose of the present invention is to provide a file management method, device, device and medium. When the number of files opened by the process reaches the upper limit of the system requirement, the process can normally open a new file again by deleting the target descriptor and closing the corresponding file. Avoid the tedious process of modifying system parameters, ensure that files can be operated efficiently and conveniently, and improve user experience.
为解决上述技术问题,本发明提供一种文件的管理方法,包括:In order to solve the above-mentioned technical problems, the present invention provides a file management method, comprising:
根据进程获取的各文件描述符,创建对应的虚拟描述符;According to each file descriptor obtained by the process, create the corresponding virtual descriptor;
统计全部的所述虚拟描述符的数量;Count the number of all the virtual descriptors;
判断所述数量是否等于预设的目标数量;其中,所述目标数量具体为系统限制所述进程打开文件的最大数量;Determine whether the number is equal to a preset target number; wherein, the target number is specifically the maximum number of files that the system limits the process to open;
如果是,则在接收到用于打开文件的申请指令后,获取满足预设要求的目标描述符进行删除,并关闭所述目标描述符对应的文件。If yes, after receiving the application instruction for opening the file, obtain and delete the target descriptor that meets the preset requirements, and close the file corresponding to the target descriptor.
优选地,所述虚拟描述符中包含的信息具体包括所述进程的标识号、文件名、所述文件描述符的使用频率及上次使用时间。Preferably, the information contained in the virtual descriptor specifically includes the identification number of the process, the file name, the usage frequency and the last usage time of the file descriptor.
优选地,所述获取满足预设要求的目标描述符进行删除具体包括:Preferably, the acquiring and deleting target descriptors that meet the preset requirements specifically includes:
获取所述使用频率最少的虚拟描述符作为所述目标描述符;obtaining the least frequently used virtual descriptor as the target descriptor;
删除所述目标描述符。Delete the target descriptor.
优选地,所述获取满足预设要求的目标描述符进行删除具体包括:Preferably, the acquiring and deleting target descriptors that meet the preset requirements specifically includes:
获取所述上次使用时间最早的虚拟描述符作为所述目标描述符;obtaining the virtual descriptor with the earliest time of last use as the target descriptor;
删除所述目标描述符。Delete the target descriptor.
优选地,还包括:Preferably, it also includes:
生成用于记录删除的目标描述符的日志。Generates a log that records the target descriptor for deletion.
优选地,还包括:Preferably, it also includes:
判断文件在打开和关闭过程中是否存在异常;Determine whether there is an exception in the process of opening and closing the file;
如果是,在所述日志中进行提示。If so, prompt in the log.
优选地,还包括:Preferably, it also includes:
根据系统设置的参数,更新所述目标数量。The target quantity is updated according to the parameters set by the system.
为解决上述技术问题,本发明还提供一种文件的管理装置,包括:In order to solve the above-mentioned technical problems, the present invention also provides a file management device, including:
创建模块,用于根据进程获取的各文件描述符,创建对应的虚拟描述符;Create a module to create a corresponding virtual descriptor according to each file descriptor obtained by the process;
统计模块,用于统计全部的所述虚拟描述符的数量;a statistics module, used to count the number of all the virtual descriptors;
判断模块,用于判断所述数量是否等于预设的目标数量;其中,所述目标数量具体为系统限制所述进程打开文件的最大数量;如果是,则进入关闭模块;A judging module for judging whether the number is equal to a preset target number; wherein, the target number is specifically the maximum number of files that the system limits the process to open; if so, enter the closing module;
关闭模块,用于在接收到用于打开文件的申请指令后,获取满足预设要求的目标描述符进行删除,并关闭所述目标描述符对应的文件。The closing module is used to obtain and delete the target descriptor that meets the preset requirements after receiving the application instruction for opening the file, and close the file corresponding to the target descriptor.
为解决上述技术问题,本发明还提供一种文件的管理设备,包括存储器,用于存储计算机程序;In order to solve the above technical problems, the present invention also provides a file management device, including a memory for storing computer programs;
处理器,用于执行所述计算机程序时实现如上述任一项所述的文件的管理方法的步骤。The processor is configured to implement the steps of the file management method according to any one of the above when executing the computer program.
为解决上述技术问题,本发明还提供一种计算机可读存储介质,所述计算机可读存储介质上存储有计算机程序,所述计算机程序被处理器执行时实现如上述任一项所述的文件的管理方法的步骤。In order to solve the above-mentioned technical problems, the present invention also provides a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, the file described in any of the above-mentioned items is realized. steps of the management method.
本发明所提供的一种文件的管理方法,首先,根据进程在对各文件进行操作时获取的各文件描述符,创建对应的虚拟描述符;通过判断全部的虚拟描述符的数量是否等于预设的目标数量;其中,目标数量具体为系统限制进程打开文件的最大数量;从而判断出进程打开文件的数量是否达到系统要求的上限,如果等于则说明进程不能继续打开文件。当再次接收到用于打开文件的申请指令后,则先删除满足预设要求的目标描述符,并关闭目标描述符对应的文件,使当前的虚拟描述符的数量小于目标数量,当前打开的文件的数量小于系统限制打开的最大数量,从而实现进程对新文件进行正常打开的操作。由此可见,本发明提供的方法在进程打开的文件数达到系统要求上限时,通过删除目标描述符并关闭相应的文件的方式,使进程可以再次正常打开新的文件;避免了对系统参数进行修改的繁琐过程,节省了大量时间,保证了文件能够高效、便捷地进行正常操作,提高了用户的体验感。In a file management method provided by the present invention, firstly, according to each file descriptor obtained by a process when operating each file, a corresponding virtual descriptor is created; by judging whether the number of all virtual descriptors is equal to a preset The target number; where, the target number is the maximum number of files that the system limits the process to open; thus it is judged whether the number of files opened by the process reaches the upper limit required by the system, and if it is equal, it means that the process cannot continue to open files. When the application instruction for opening a file is received again, the target descriptor that meets the preset requirements is deleted first, and the file corresponding to the target descriptor is closed, so that the current number of virtual descriptors is less than the target number, and the currently opened file The number of files is less than the maximum number opened by the system limit, so that the process can normally open the new file. It can be seen that, when the number of files opened by the process reaches the upper limit of the system requirement, the method provided by the present invention enables the process to open a new file normally again by deleting the target descriptor and closing the corresponding file; it avoids the need for system parameters to be checked. The tedious process of modification saves a lot of time, ensures that the file can be operated efficiently and conveniently, and improves the user experience.
此外,本发明所提供的一种文件的管理装置、设备及介质与上述方法对应,具有同样的有益效果。In addition, a file management device, device and medium provided by the present invention correspond to the above method and have the same beneficial effects.
附图说明Description of drawings
为了更清楚地说明本发明实施例,下面将对实施例中所需要使用的附图做简单的介绍,显而易见地,下面描述中的附图仅仅是本发明的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。In order to explain the embodiments of the present invention more clearly, the following will briefly introduce the accompanying drawings that need to be used in the embodiments. Obviously, the accompanying drawings in the following description are only some embodiments of the present invention, which are not relevant to ordinary skills in the art. As far as personnel are concerned, other drawings can also be obtained from these drawings on the premise of no creative work.
图1为本发明实施例提供的一种文件的管理方法的流程图;1 is a flowchart of a file management method provided by an embodiment of the present invention;
图2为本发明实施例提供的另一种文件的管理方法的流程图;2 is a flowchart of another file management method provided by an embodiment of the present invention;
图3为本发明实施例提供的一种文件的管理装置的结构图;3 is a structural diagram of a file management device provided by an embodiment of the present invention;
图4为本发明实施例提供的一种文件的管理设备的结构图。FIG. 4 is a structural diagram of a file management device according to an embodiment of the present invention.
具体实施方式Detailed ways
下面将结合本发明实施例中的附图,对本发明实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例仅仅是本发明一部分实施例,而不是全部实施例。基于本发明中的实施例,本领域普通技术人员在没有做出创造性劳动前提下,所获得的所有其他实施例,都属于本发明保护范围。The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention. Obviously, the described embodiments are only a part of the embodiments of the present invention, but not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those of ordinary skill in the art without creative work fall within the protection scope of the present invention.
本发明的核心是提供一种文件的管理方法、装置、设备及介质。能够在进程打开的文件数达到系统要求上限时,通过删除目标描述符并关闭相应的文件的方式,使进程可以再次正常打开新的文件。避免对系统参数进行修改的繁琐过程,保证文件能够高效、便捷地进行正常操作,提高用户的体验感。The core of the present invention is to provide a file management method, device, device and medium. When the number of files opened by the process reaches the upper limit of the system requirement, the process can normally open a new file again by deleting the target descriptor and closing the corresponding file. Avoid the tedious process of modifying system parameters, ensure that files can be operated efficiently and conveniently, and improve user experience.
为了使本技术领域的人员更好地理解本发明方案,下面结合附图和具体实施方式对本发明作进一步的详细说明。In order to make those skilled in the art better understand the solution of the present invention, the present invention will be further described in detail below with reference to the accompanying drawings and specific embodiments.
图1为本发明实施例提供的一种文件的管理方法的流程图;如图1所示,本发明实施例提供的文件的管理方法,包括步骤S101-步骤S104:FIG. 1 is a flowchart of a file management method provided by an embodiment of the present invention; as shown in FIG. 1 , the file management method provided by an embodiment of the present invention includes steps S101 to S104:
步骤S101:根据进程获取的各文件描述符,创建对应的虚拟描述符;Step S101: Create a corresponding virtual descriptor according to each file descriptor obtained by the process;
需要说明的是,本实施例提出的虚拟描述符具体为包含有文件描述符信息及其他文件信息的数据结构,此处命名为虚拟描述符。可以理解地,一个进程打开不同的文件会产生不同的文件描述符,根据不同的文件描述符相应创建不同的虚拟描述符。具体地,可将创建的虚拟描述符存储于缓冲池中进行管理。It should be noted that the virtual descriptor proposed in this embodiment is specifically a data structure including file descriptor information and other file information, and is named as a virtual descriptor here. Understandably, when a process opens different files, different file descriptors will be generated, and different virtual descriptors will be created accordingly according to different file descriptors. Specifically, the created virtual descriptor can be stored in a buffer pool for management.
在一个实施例中,虚拟描述符中包含的信息具体包括进程的标识号、文件名、文件描述符的使用频率及上次使用时间。文件名为当前打开的物理文件的文件名;文件描述符的使用频率为在一定时间段获取文件描述符的次数;上次使用时间为距离当前最近的一次使用该文件描述符的时间。另外,虚拟描述符中还可记录其它内容,例如:对应的物理文件的句柄、虚拟描述符的状态标记位、当前读写指针的位置、文件打开时的标志等。本领域技术人员可根据实际应用情况,为虚拟描述符中添加或删除与文件相关的内容,本实施例不作限定。In one embodiment, the information contained in the virtual descriptor specifically includes the identification number of the process, the file name, the usage frequency of the file descriptor, and the last usage time. The file name is the file name of the currently opened physical file; the use frequency of the file descriptor is the number of times the file descriptor is obtained in a certain period of time; the last use time is the time when the file descriptor was used most recently. In addition, other contents may also be recorded in the virtual descriptor, for example: the handle of the corresponding physical file, the status flag bit of the virtual descriptor, the position of the current read/write pointer, the flag when the file is opened, and the like. Those skilled in the art can add or delete content related to the file from the virtual descriptor according to the actual application, which is not limited in this embodiment.
步骤S102:统计全部的虚拟描述符的数量;Step S102: count the number of all virtual descriptors;
步骤S103:判断数量是否等于预设的目标数量;其中,目标数量具体为系统限制进程打开文件的最大数量;如果是,则进入步骤S104;Step S103: judging whether the number is equal to the preset target number; wherein, the target number is specifically the maximum number of files opened by the system limit process; if so, go to step S104;
步骤S104:在接收到用于打开文件的申请指令后,获取满足预设要求的目标描述符进行删除,并关闭目标描述符对应的文件。Step S104: After receiving the application instruction for opening the file, acquire and delete the target descriptor that meets the preset requirements, and close the file corresponding to the target descriptor.
在具体实施中,统计创建的全部虚拟描述符的数量,并判断数量是否等于预设的目标数量,也就是系统限制进程打开文件的最大数量。当虚拟描述符的数量等于目标数量时,则说明进程打开文件的数量已达到系统限制的打开文件的最大数量,无法再打开新的文件。当再次接收到用于打开文件的申请指令时,需要先获取满足预设要求的目标描述符,并删除该目标描述符,然后关闭目标描述符对应的文件。需要说明的是,将全部虚拟描述符中满足预设要求的虚拟描述符称为目标描述符。此时,虚拟描述符的数量变为小于目标数量,并且进程打开文件的数量也小于系统限制的最大数量。进程可再次打开新的文件。In a specific implementation, the number of all created virtual descriptors is counted, and it is determined whether the number is equal to the preset target number, that is, the system limits the maximum number of files opened by a process. When the number of virtual descriptors is equal to the target number, it means that the number of open files of the process has reached the maximum number of open files limited by the system, and no new files can be opened. When an application instruction for opening a file is received again, it is necessary to obtain a target descriptor that meets the preset requirements, delete the target descriptor, and then close the file corresponding to the target descriptor. It should be noted that the virtual descriptors that satisfy the preset requirements among all the virtual descriptors are called target descriptors. At this point, the number of virtual descriptors becomes less than the target number, and the number of open files by the process is also less than the maximum number limited by the system. Processes can open new files again.
具体地,设置缓冲池的容量为系统限制进程打开文件的最大数量,通过判断缓冲池中的虚拟描述符是否存满来判断虚拟描述符的数量是否等于预设的目标数量;当缓冲池的虚拟描述符存满时,则说明虚拟描述符数量等于目标数量;当缓冲池的虚拟描述符未存满时,则说明虚拟描述符数量小于目标数量。同时,由此也能确定出当前进程打开文件的数量的情况。Specifically, the capacity of the buffer pool is set as the maximum number of files opened by the system limit process, and whether the number of virtual descriptors is equal to the preset target number is determined by judging whether the virtual descriptors in the buffer pool are full; When the descriptors are full, it means that the number of virtual descriptors is equal to the target number; when the virtual descriptors of the buffer pool are not full, it means that the number of virtual descriptors is less than the target number. At the same time, it can also determine the number of files opened by the current process.
本发明所提供的一种文件的管理方法,首先,根据进程在对各文件进行操作时获取的各文件描述符,创建对应的虚拟描述符;通过判断全部的虚拟描述符的数量是否等于预设的目标数量;其中,目标数量具体为系统限制进程打开文件的最大数量;从而判断出进程打开文件的数量是否达到系统要求的上限,如果等于则说明进程不能继续打开文件。当再次接收到用于打开文件的申请指令后,则先删除满足预设要求的目标描述符,并关闭目标描述符对应的文件,使当前的虚拟描述符的数量小于目标数量,当前打开的文件的数量小于系统限制打开的最大数量,从而实现进程对新文件进行正常打开的操作。由此可见,本发明提供的方法在进程打开的文件数达到系统要求上限时,通过删除目标描述符并关闭相应的文件的方式,使进程可以再次正常打开新的文件;避免了对系统参数进行修改的繁琐过程,节省了大量时间,保证了文件能够高效、便捷地进行正常操作,提高了用户的体验感。In a file management method provided by the present invention, firstly, according to each file descriptor obtained by a process when operating each file, a corresponding virtual descriptor is created; by judging whether the number of all virtual descriptors is equal to a preset The target number; where, the target number is the maximum number of files that the system limits the process to open; thus it is judged whether the number of files opened by the process reaches the upper limit required by the system, and if it is equal, it means that the process cannot continue to open files. When the application instruction for opening a file is received again, the target descriptor that meets the preset requirements is deleted first, and the file corresponding to the target descriptor is closed, so that the current number of virtual descriptors is less than the target number, and the currently opened file The number of files is less than the maximum number opened by the system limit, so that the process can normally open the new file. It can be seen that, when the number of files opened by the process reaches the upper limit of the system requirement, the method provided by the present invention enables the process to open a new file normally again by deleting the target descriptor and closing the corresponding file; it avoids the need for system parameters to be checked. The tedious process of modification saves a lot of time, ensures that the file can be operated efficiently and conveniently, and improves the user experience.
在具体实施中,本发明提供的一种文件的管理方法中获取满足预设要求的目标描述符进行删除具体包括:In a specific implementation, in a file management method provided by the present invention, acquiring and deleting target descriptors that meet preset requirements specifically includes:
获取使用频率最少的虚拟描述符作为目标描述符;Get the least frequently used virtual descriptor as the target descriptor;
删除目标描述符。Delete the target descriptor.
需要说明的是,虚拟描述符中记录有文件描述符的使用频率,可以理解为是文件在一定时间内的使用次数。在一个实施例中,在缓冲池中按照文件描述符的使用频率由高到低的顺序对存储的虚拟描述符进行排序;获取位于缓冲池最后的虚拟描述符作为目标描述符。It should be noted that the usage frequency of the file descriptor is recorded in the virtual descriptor, which can be understood as the number of times the file is used within a certain period of time. In one embodiment, the virtual descriptors stored in the buffer pool are sorted in descending order of the usage frequency of the file descriptors; the virtual descriptor located at the end of the buffer pool is obtained as the target descriptor.
可以理解地,使用频率最少则说明该文件描述符对应的文件的使用次数最少,为不常用的文件。可将该虚拟描述符作为目标描述符进行删除,并且关闭虚拟描述符对应的不常用的文件。从而可满足进程打开新的文件的要求;同时,由于关闭的文件为使用次数最少的文件,则可反映出关闭该文件对系统操作的影响最小。Understandably, the least frequency of use indicates that the file corresponding to the file descriptor has the least number of times of use, and is an infrequently used file. The virtual descriptor can be deleted as the target descriptor, and the infrequently used file corresponding to the virtual descriptor can be closed. Therefore, the requirement of a process to open a new file can be satisfied; at the same time, since the closed file is the file with the least number of times, it can be reflected that closing the file has the least impact on the system operation.
在具体实施中,本发明提供的一种文件的管理方法中获取满足预设要求的目标描述符进行删除具体包括:In a specific implementation, in a file management method provided by the present invention, acquiring and deleting target descriptors that meet preset requirements specifically includes:
获取上次使用时间最早的虚拟描述符作为目标描述符;Get the virtual descriptor with the earliest last use time as the target descriptor;
删除目标描述符。Delete the target descriptor.
需要说明的是,虚拟描述符中记录有上次使用时间,即距离当前最近的一次使用该文件描述符的时间。在一个实施例中,在缓冲池中按照上次使用时间距离当前时刻由近到远的顺序对存储的虚拟描述符进行排序;获取存储于缓冲池最后的虚拟描述符作为目标描述符,也就是获取上次使用时间最远的文件描述符对应的虚拟描述符作为目标描述符。It should be noted that the last use time is recorded in the virtual descriptor, that is, the time when the file descriptor is used most recently. In one embodiment, the stored virtual descriptors are sorted in the buffer pool according to the order from the last used time to the current moment; the last virtual descriptor stored in the buffer pool is obtained as the target descriptor, that is, Get the virtual descriptor corresponding to the file descriptor with the oldest last used time as the target descriptor.
可以理解地,上次使用时间最早则说明该文件描述符对应的文件在很长一段时间没有执行操作,可看为不常用的文件。可将该虚拟描述符作为目标描述符进行删除,并且关闭虚拟描述符对应的不常用的文件。从而可满足进程打开新的文件的要求;同时,由于关闭的文件很长时间没有被使用,则可反映出该文件在未来一段时间内被使用的概率较低,则关闭该文件对系统操作的影响最小。Understandably, if the last used time is the earliest, it means that the file corresponding to the file descriptor has not been operated for a long time, and can be regarded as an uncommon file. The virtual descriptor can be deleted as the target descriptor, and the infrequently used file corresponding to the virtual descriptor can be closed. This can meet the requirements of the process to open new files; at the same time, since the closed file has not been used for a long time, it can be reflected that the probability of the file being used in the future is low, then closing the file will affect the system operation. minimal impact.
图2为本发明实施例提供的另一种文件的管理方法的流程图;如图2所示,本发明实施例提供的一种文件的管理方法,还包括步骤S105-步骤S108:FIG. 2 is a flowchart of another file management method provided by an embodiment of the present invention; as shown in FIG. 2, a file management method provided by an embodiment of the present invention further includes steps S105-S108:
步骤S105:生成用于记录删除的目标描述符的日志。Step S105: Generate a log for recording the deleted target descriptor.
具体地,在删除目标描述符的过程中,将被删除的目标描述符记录到日志中,便于在发生误删或需要重新添加等操作时,及时补充被删除掉的目标描述符;同时,工作人员可根据日志中的记录的目标描述符,了解进程对文件的操作情况。本实施例提高了操作的灵活性,也防止由于误删除操作对系统的其它操作产生影响。Specifically, in the process of deleting the target descriptor, the deleted target descriptor is recorded in the log, so that the deleted target descriptor can be replenished in time when an operation such as mistaken deletion or re-adding is required; at the same time, the work Personnel can learn about the operation of the process on the file based on the target descriptor recorded in the log. This embodiment improves the flexibility of the operation, and also prevents other operations of the system from being affected by the mistaken deletion operation.
如图2所示,本发明实施例提供的文件的管理方法,还包括:As shown in FIG. 2, the file management method provided by the embodiment of the present invention further includes:
步骤S106:判断文件在打开和关闭过程中是否存在异常;如果是,进入步骤S107;Step S106: determine whether there is any abnormality in the process of opening and closing the file; if so, go to step S107;
步骤S107:在日志中进行提示。Step S107: prompt in the log.
在一个实施例中,当文件在打开和关闭过程中发生异常时,如打开失败、关闭失败或无法查找到文件等;可以通过日志来进行异常提示,便于工作人员及时发现。也可根据预先存储有的工作人员的联系方式,例如,邮箱或者电话号等。在出现异常时将异常信息发送给工作人员,使工作人员能够及时做出处理。保证系统对文件操作的有效性和及时性。In one embodiment, when an exception occurs during the opening and closing of a file, such as failure to open, failure to close, or inability to find the file, etc.; the log can be used to prompt the exception, which is convenient for staff to discover in time. It can also be based on pre-stored staff contact information, such as email or phone number. When an exception occurs, the abnormal information is sent to the staff, so that the staff can deal with it in time. Ensure the system's effectiveness and timeliness of file operations.
如图2所示,本发明实施例提供的文件的管理方法,还包括:As shown in FIG. 2, the file management method provided by the embodiment of the present invention further includes:
步骤S108:根据系统设置的参数,更新目标数量。Step S108: Update the target quantity according to the parameters set by the system.
具体地,由于系统中设置的运行进程打开文件的最大数量这一参数可变更,当系统设置的该参数发生改变时,需要相应的更新目标数量。保证目标数量为当前最新设置的参数,使能够准确地判断出虚拟描述符是否等于目标数量,也就是能够准确地判断出进程打开的文件的数量是否达到了限制的最大数量,便于后续执行其它相关操作,保证进程在打开文件数量达到最大数量的情况下,不影响新的文件的正常打开。本实施例提供的方法保证了目标数据的时效性,能根据实际情况不断进行调整,更好地满足用户的需求。Specifically, since the parameter set in the system, the maximum number of files opened by the running process, can be changed, when the parameter set by the system changes, the target number needs to be updated accordingly. Ensure that the target number is the latest parameter set, so that it can accurately determine whether the virtual descriptor is equal to the target number, that is, it can accurately determine whether the number of files opened by the process has reached the maximum number of restrictions, which is convenient for subsequent execution of other related tasks. Operation to ensure that the process does not affect the normal opening of new files when the number of open files reaches the maximum number. The method provided in this embodiment ensures the timeliness of the target data, and can be continuously adjusted according to the actual situation, so as to better meet the needs of users.
本发明还提供一种文件的管理装置对应的实施例,基于功能模块的角度对文件的管理装置进行了说明。The present invention also provides a corresponding embodiment of the file management device, and the file management device is described based on the perspective of functional modules.
图3为本发明实施例提供的一种文件的管理装置的结构图;如图3所示,本发明实施例提供的一种文件的管理装置,包括:FIG. 3 is a structural diagram of a file management device provided by an embodiment of the present invention; as shown in FIG. 3 , a file management device provided by an embodiment of the present invention includes:
创建模块10,用于根据进程获取的各文件描述符,创建对应的虚拟描述符;The
统计模块11,用于统计全部的虚拟描述符的数量;The
判断模块12,用于判断数量是否等于预设的目标数量;其中,目标数量具体为系统限制进程打开文件的最大数量;如果是,则进入关闭模块13;The judging
关闭模块13,用于在接收到用于打开文件的申请指令后,获取满足预设要求的目标描述符进行删除,并关闭目标描述符对应的文件。The
本发明实施例提供的一种文件的管理装置,还包括:A file management device provided by an embodiment of the present invention further includes:
生成模块,用于生成用于记录删除的目标描述符的日志;A generation module for generating a log for recording deleted target descriptors;
判断模块,用于判断文件在打开和关闭过程中是否存在异常;如果是,则在日志中进行提示;The judgment module is used to judge whether there is an abnormality in the process of opening and closing the file; if so, it will be prompted in the log;
更新模块,用于根据系统设置的参数,更新目标数量。The update module is used to update the target quantity according to the parameters set by the system.
由于本部分的实施例与方法部分的实施例相互对应,因此本部分的实施例请参见方法部分的实施例的描述,这里暂不赘述。Since the embodiments in this part correspond to the embodiments in the method part, the embodiments in this part refer to the description of the embodiments in the method part, and details are not described here for the time being.
本发明所提供的一种文件的管理装置,首先,根据进程在对各文件进行操作时获取的各文件描述符,创建对应的虚拟描述符;通过判断全部的虚拟描述符的数量是否等于预设的目标数量;其中,目标数量具体为系统限制进程打开文件的最大数量;从而判断出进程打开文件的数量是否达到系统要求的上限,如果等于则说明进程不能继续打开文件。当再次接收到用于打开文件的申请指令后,则先删除满足预设要求的目标描述符,并关闭目标描述符对应的文件,使当前的虚拟描述符的数量小于目标数量,当前打开的文件的数量小于系统限制打开的最大数量,从而实现进程对新文件进行正常打开的操作。由此可见,本发明提供的装置在进程打开的文件数达到系统要求上限时,通过删除目标描述符并关闭相应的文件的方式,使进程可以再次正常打开新的文件;避免了对系统参数进行修改的繁琐过程,节省了大量时间,保证了文件能够高效、便捷地进行正常操作,提高了用户的体验感。In the file management device provided by the present invention, firstly, according to each file descriptor obtained by a process when operating each file, a corresponding virtual descriptor is created; by judging whether the number of all virtual descriptors is equal to a preset The target number; where, the target number is the maximum number of files that the system limits the process to open; thus it is judged whether the number of files opened by the process reaches the upper limit required by the system, and if it is equal, it means that the process cannot continue to open files. When the application instruction for opening a file is received again, the target descriptor that meets the preset requirements is deleted first, and the file corresponding to the target descriptor is closed, so that the current number of virtual descriptors is less than the target number, and the currently opened file The number of files is less than the maximum number opened by the system limit, so that the process can normally open the new file. It can be seen that, when the number of files opened by the process reaches the upper limit of the system requirement, the device provided by the present invention deletes the target descriptor and closes the corresponding file, so that the process can normally open a new file again; it avoids the need for system parameters. The tedious process of modification saves a lot of time, ensures that the file can be operated efficiently and conveniently, and improves the user experience.
本发明还提供一种文件的管理设备对应的实施例,基于硬件的角度对文件的管理设备进行了说明。The present invention also provides an embodiment corresponding to a file management device, and the file management device is described from the perspective of hardware.
图4为本发明实施例提供的一种文件的管理设备的结构图;如图4所示,本发明实施例提供的文件的管理设备,包括存储器20,用于存储计算机程序;FIG. 4 is a structural diagram of a file management device provided by an embodiment of the present invention; as shown in FIG. 4 , the file management device provided by the embodiment of the present invention includes a memory 20 for storing computer programs;
处理器21,用于执行计算机程序时实现如上述任一项的文件的管理方法的步骤。The processor 21 is configured to implement the steps of the file management method according to any one of the above when executing the computer program.
其中,处理器21可以包括一个或多个处理核心,比如4核心处理器、8核心处理器等。处理器21可以采用DSP(Digital Signal Processing,数字信号处理)、FPGA(Field-Programmable Gate Array,现场可编程门阵列)、PLA(Programmable Logic Array,可编程逻辑阵列)中的至少一种硬件形式来实现。处理器21也可以包括主处理器和协处理器,主处理器是用于对在唤醒状态下的数据进行处理的处理器,也称CPU(Central ProcessingUnit,中央处理器);协处理器是用于对在待机状态下的数据进行处理的低功耗处理器。在一些实施例中,处理器21可以在集成有GPU(Graphics Processing Unit,图像处理器),GPU用于负责显示屏所需要显示的内容的渲染和绘制。一些实施例中,处理器21还可以包括AI(Artificial Intelligence,人工智能)处理器,该AI处理器用于处理有关机器学习的计算操作。The processor 21 may include one or more processing cores, such as a 4-core processor, an 8-core processor, and the like. The processor 21 may use at least one hardware form among DSP (Digital Signal Processing, digital signal processing), FPGA (Field-Programmable Gate Array, field programmable gate array), PLA (Programmable Logic Array, programmable logic array) accomplish. The processor 21 may also include a main processor and a coprocessor. The main processor is a processor used to process data in the wake-up state, also called a CPU (Central Processing Unit, central processing unit); A low-power processor for processing data in a standby state. In some embodiments, the processor 21 may be integrated with a GPU (Graphics Processing Unit, image processor), and the GPU is used for rendering and drawing the content that needs to be displayed on the display screen. In some embodiments, the processor 21 may further include an AI (Artificial Intelligence, artificial intelligence) processor, where the AI processor is used to process computing operations related to machine learning.
存储器20可以包括一个或多个计算机可读存储介质,该计算机可读存储介质可以是非暂态的。存储器20还可包括高速随机存取存储器,以及非易失性存储器,比如一个或多个磁盘存储设备、闪存存储设备。本实施例中,存储器20至少用于存储以下计算机程序201,其中,该计算机程序被处理器21加载并执行之后,能够实现前述任一实施例公开的文件的管理方法中的相关步骤。另外,存储器20所存储的资源还可以包括操作系统202和数据203等,存储方式可以是短暂存储或者永久存储。其中,操作系统202可以包括Windows、Unix、Linux等。Memory 20 may include one or more computer-readable storage media, which may be non-transitory. Memory 20 may also include high-speed random access memory, as well as non-volatile memory, such as one or more magnetic disk storage devices, flash storage devices. In this embodiment, the memory 20 is used to store at least the following computer program 201 , where, after the computer program is loaded and executed by the processor 21 , the relevant steps in the file management method disclosed in any of the foregoing embodiments can be implemented. In addition, the resources stored in the memory 20 may also include an operating system 202, data 203, etc., and the storage mode may be short-term storage or permanent storage. The operating system 202 may include Windows, Unix, Linux, and the like.
在一些实施例中,文件的管理设备还可包括有输入输出接口22、通信接口23、电源24以及通信总线25。In some embodiments, the file management device may further include an input/output interface 22 , a communication interface 23 , a power supply 24 and a communication bus 25 .
本领域技术人员可以理解,图4中示出的结构并不构成对文件的管理设备的限定,可以包括比图示更多或更少的组件。Those skilled in the art can understand that the structure shown in FIG. 4 does not constitute a limitation on the file management device, and may include more or less components than those shown in the drawings.
由于设备部分的实施例与方法部分的实施例相互对应,因此设备部分的实施例请参见方法部分的实施例的描述,这里暂不赘述。Since the embodiments of the device part and the embodiments of the method part correspond to each other, the embodiments of the device part refer to the description of the embodiments of the method part, which will not be repeated here.
本发明所提供的一种文件的管理设备,能够实现以下方法:首先,根据进程在对各文件进行操作时获取的各文件描述符,创建对应的虚拟描述符;通过判断全部的虚拟描述符的数量是否等于预设的目标数量;其中,目标数量具体为系统限制进程打开文件的最大数量;从而判断出进程打开文件的数量是否达到系统要求的上限,如果等于则说明进程不能继续打开文件。当再次接收到用于打开文件的申请指令后,则先删除满足预设要求的目标描述符,并关闭目标描述符对应的文件,使当前的虚拟描述符的数量小于目标数量,当前打开的文件的数量小于系统限制打开的最大数量,从而实现进程对新文件进行正常打开的操作。由此可见,本发明提供的方法在进程打开的文件数达到系统要求上限时,通过删除目标描述符并关闭相应的文件的方式,使进程可以再次正常打开新的文件;避免了对系统参数进行修改的繁琐过程,节省了大量时间,保证了文件能够高效、便捷地进行正常操作,提高了用户的体验感。A file management device provided by the present invention can implement the following methods: first, according to each file descriptor obtained by a process when operating each file, a corresponding virtual descriptor is created; Whether the number is equal to the preset target number; among them, the target number is the maximum number of files that the system limits the process to open; thus it is judged whether the number of files opened by the process reaches the upper limit required by the system, and if it is equal, the process cannot continue to open files. When the application instruction for opening a file is received again, the target descriptor that meets the preset requirements is deleted first, and the file corresponding to the target descriptor is closed, so that the current number of virtual descriptors is less than the target number, and the currently opened file The number of files is less than the maximum number opened by the system limit, so that the process can normally open the new file. It can be seen that, when the number of files opened by the process reaches the upper limit of the system requirement, the method provided by the present invention enables the process to open a new file normally again by deleting the target descriptor and closing the corresponding file; it avoids the need for system parameters to be checked. The tedious process of modification saves a lot of time, ensures that the file can be operated efficiently and conveniently, and improves the user experience.
最后,本发明还提供一种计算机可读存储介质对应的实施例。计算机可读存储介质上存储有计算机程序,计算机程序被处理器执行时实现如上述方法实施例中记载的步骤。Finally, the present invention also provides an embodiment corresponding to a computer-readable storage medium. A computer program is stored on the computer-readable storage medium, and when the computer program is executed by the processor, the steps described in the foregoing method embodiments are implemented.
可以理解的是,如果上述实施例中的方法以软件功能单元的形式实现并作为独立的产品销售或使用时,可以存储在一个计算机可读取存储介质中。基于这样的理解,本发明的技术方案本质上或者说对现有技术做出贡献的部分或者该技术方案的全部或部分可以以软件产品的形式体现出来,该计算机软件产品存储在一个存储介质中,执行本发明各个实施例所述方法的全部或部分步骤。而前述的存储介质包括:U盘、移动硬盘、只读存储器(Read-Only Memory,ROM)、随机存取存储器(Random Access Memory,RAM)、磁碟或者光盘等各种可以存储程序代码的介质。It can be understood that, if the methods in the above embodiments are implemented in the form of software functional units and sold or used as independent products, they may be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention is essentially or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium , execute all or part of the steps of the methods described in the various embodiments of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (Read-Only Memory, ROM), random access memory (Random Access Memory, RAM), magnetic disk or optical disk and other media that can store program codes .
以上对本发明所提供的一种文件的管理方法、装置、设备及介质进行了详细介绍。说明书中各个实施例采用递进的方式描述,每个实施例重点说明的都是与其他实施例的不同之处,各个实施例之间相同相似部分互相参见即可。对于实施例公开的装置而言,由于其与实施例公开的方法相对应,所以描述的比较简单,相关之处参见方法部分说明即可。应当指出,对于本技术领域的普通技术人员来说,在不脱离本发明原理的前提下,还可以对本发明进行若干改进和修饰,这些改进和修饰也落入本发明权利要求的保护范围内。The file management method, device, device and medium provided by the present invention have been described in detail above. The various embodiments in the specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments, and the same and similar parts between the various embodiments can be referred to each other. As for the device disclosed in the embodiment, since it corresponds to the method disclosed in the embodiment, the description is relatively simple, and the relevant part can be referred to the description of the method. It should be pointed out that for those skilled in the art, without departing from the principle of the present invention, several improvements and modifications can also be made to the present invention, and these improvements and modifications also fall within the protection scope of the claims of the present invention.
还需要说明的是,在本说明书中,诸如第一和第二等之类的关系术语仅仅用来将一个实体或者操作与另一个实体或操作区分开来,而不一定要求或者暗示这些实体或操作之间存在任何这种实际的关系或者顺序。而且,术语“包括”、“包含”或者其任何其他变体意在涵盖非排他性的包含,从而使得包括一系列要素的过程、方法、物品或者设备不仅包括那些要素,而且还包括没有明确列出的其他要素,或者是还包括为这种过程、方法、物品或者设备所固有的要素。在没有更多限制的情况下,由语句“包括一个……”限定的要素,并不排除在包括所述要素的过程、方法、物品或者设备中还存在另外的相同要素。It should also be noted that, in this specification, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply these entities or operations. There is no such actual relationship or sequence between operations. Moreover, the terms "comprising", "comprising" or any other variation thereof are intended to encompass a non-exclusive inclusion such that a process, method, article or device that includes a list of elements includes not only those elements, but also includes not explicitly listed or other elements inherent to such a process, method, article or apparatus. Without further limitation, an element qualified by the phrase "comprising a..." does not preclude the presence of additional identical elements in a process, method, article or apparatus that includes the element.
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN201910968188.1ACN110795400B (en) | 2019-10-12 | 2019-10-12 | File management method, device, equipment and medium |
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN201910968188.1ACN110795400B (en) | 2019-10-12 | 2019-10-12 | File management method, device, equipment and medium |
| Publication Number | Publication Date |
|---|---|
| CN110795400Atrue CN110795400A (en) | 2020-02-14 |
| CN110795400B CN110795400B (en) | 2022-03-22 |
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| CN201910968188.1AActiveCN110795400B (en) | 2019-10-12 | 2019-10-12 | File management method, device, equipment and medium |
| Country | Link |
|---|---|
| CN (1) | CN110795400B (en) |
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN111832054A (en)* | 2020-07-16 | 2020-10-27 | 郑州信大捷安信息技术股份有限公司 | Transparent encryption and decryption method, system and storage medium based on multithreading environment |
| CN112732640A (en)* | 2020-12-28 | 2021-04-30 | 杭州迪普科技股份有限公司 | Method and device for detecting file descriptor leakage |
| CN112732560A (en)* | 2020-12-31 | 2021-04-30 | 杭州迪普科技股份有限公司 | Method and device for detecting file descriptor leakage risk |
| CN113835891A (en)* | 2021-09-24 | 2021-12-24 | 哲库科技(北京)有限公司 | Resource allocation method, device, electronic equipment and computer readable storage medium |
| CN114912103A (en)* | 2021-02-09 | 2022-08-16 | 华为技术有限公司 | A kind of access control method and related device |
| CN117991993A (en)* | 2024-03-01 | 2024-05-07 | 北京安博通金安科技有限公司 | File management method and device and processing equipment |
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN101147133A (en)* | 2005-02-16 | 2008-03-19 | 桑迪士克股份有限公司 | Direct file data programming and erasing in flash memory |
| CN107179950A (en)* | 2017-06-29 | 2017-09-19 | 努比亚技术有限公司 | A kind of application process processing method, mobile terminal and computer-readable recording medium |
| CN107423213A (en)* | 2017-04-11 | 2017-12-01 | 腾讯科技(深圳)有限公司 | A kind of filec descriptor distribution detection method and device |
| CN108628740A (en)* | 2018-04-10 | 2018-10-09 | 杭州迪普科技股份有限公司 | A kind of filec descriptor leakage detection method and device |
| CN110309257A (en)* | 2018-03-14 | 2019-10-08 | 杭州海康威视数字技术股份有限公司 | A kind of file read-write deployment method and device |
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN101147133A (en)* | 2005-02-16 | 2008-03-19 | 桑迪士克股份有限公司 | Direct file data programming and erasing in flash memory |
| CN107423213A (en)* | 2017-04-11 | 2017-12-01 | 腾讯科技(深圳)有限公司 | A kind of filec descriptor distribution detection method and device |
| CN107179950A (en)* | 2017-06-29 | 2017-09-19 | 努比亚技术有限公司 | A kind of application process processing method, mobile terminal and computer-readable recording medium |
| CN110309257A (en)* | 2018-03-14 | 2019-10-08 | 杭州海康威视数字技术股份有限公司 | A kind of file read-write deployment method and device |
| CN108628740A (en)* | 2018-04-10 | 2018-10-09 | 杭州迪普科技股份有限公司 | A kind of filec descriptor leakage detection method and device |
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN111832054A (en)* | 2020-07-16 | 2020-10-27 | 郑州信大捷安信息技术股份有限公司 | Transparent encryption and decryption method, system and storage medium based on multithreading environment |
| CN111832054B (en)* | 2020-07-16 | 2022-03-15 | 郑州信大捷安信息技术股份有限公司 | Transparent encryption and decryption method, system and storage medium based on multithreading environment |
| CN112732640A (en)* | 2020-12-28 | 2021-04-30 | 杭州迪普科技股份有限公司 | Method and device for detecting file descriptor leakage |
| CN112732640B (en)* | 2020-12-28 | 2023-07-25 | 杭州迪普科技股份有限公司 | Method and device for detecting leakage of file descriptor |
| CN112732560A (en)* | 2020-12-31 | 2021-04-30 | 杭州迪普科技股份有限公司 | Method and device for detecting file descriptor leakage risk |
| CN112732560B (en)* | 2020-12-31 | 2023-10-27 | 杭州迪普科技股份有限公司 | Method and device for detecting leakage risk of file descriptor |
| CN114912103A (en)* | 2021-02-09 | 2022-08-16 | 华为技术有限公司 | A kind of access control method and related device |
| CN113835891A (en)* | 2021-09-24 | 2021-12-24 | 哲库科技(北京)有限公司 | Resource allocation method, device, electronic equipment and computer readable storage medium |
| CN113835891B (en)* | 2021-09-24 | 2023-05-23 | 哲库科技(北京)有限公司 | Resource allocation method, device, electronic equipment and computer readable storage medium |
| CN117991993A (en)* | 2024-03-01 | 2024-05-07 | 北京安博通金安科技有限公司 | File management method and device and processing equipment |
| Publication number | Publication date |
|---|---|
| CN110795400B (en) | 2022-03-22 |
| Publication | Publication Date | Title |
|---|---|---|
| CN110795400A (en) | A file management method, device, equipment and medium | |
| CN108287708A (en) | A kind of data processing method, device, server and computer readable storage medium | |
| CN108764667A (en) | Risk data determines method and device | |
| WO2023035524A1 (en) | Intention recognition-based process node jump method and apparatus, device, and medium | |
| US20240061599A1 (en) | Method and system for processing file read-write service, device, and medium | |
| CN118940686A (en) | Chip verification method, device, equipment and medium | |
| CN116303589A (en) | A workflow construction method, device, equipment and readable storage medium | |
| CN115016735B (en) | A control method, device and medium of a distributed cache system | |
| CN118466955A (en) | Code-free configuration of form page control system based on form designer | |
| CN107577962A (en) | Method, system and the relevant apparatus that a kind of more algorithms of cipher card perform side by side | |
| CN118197305A (en) | Voice control method and device and electronic equipment | |
| CN114443767B (en) | Methods, devices, equipment and media for determining the consistency level of distributed systems | |
| CN114065632B (en) | Computer-implemented packaging method, device, and electronic equipment | |
| CN116860776A (en) | Label updating method, device, equipment and medium | |
| CN118821675A (en) | Chip verification method, device, equipment and medium | |
| CN115169294A (en) | A data conversion method, device and medium | |
| CN115309701A (en) | A file migration method, device and medium of a distributed file system | |
| CN114968114A (en) | Object storage method, device and medium | |
| CN106934555B (en) | Workflow organization method and device, computer equipment and storage medium | |
| CN110704241A (en) | Method, device, equipment and medium for recovering file metadata | |
| CN119002897B (en) | File execution method, device, equipment and medium based on running time | |
| CN113495753B (en) | Method and device for acquiring label of item, electronic equipment and storage medium | |
| CN117235397B (en) | Form data input method, device and medium | |
| CN116842156B (en) | Data generation method, device, equipment and medium | |
| CN113377796B (en) | Method, device and storage medium for automatically updating buried events and their fields |
| Date | Code | Title | Description |
|---|---|---|---|
| PB01 | Publication | ||
| PB01 | Publication | ||
| SE01 | Entry into force of request for substantive examination | ||
| SE01 | Entry into force of request for substantive examination | ||
| GR01 | Patent grant | ||
| GR01 | Patent grant | ||
| CP03 | Change of name, title or address | Address after:Building 9, No.1, guanpu Road, Guoxiang street, Wuzhong Economic Development Zone, Wuzhong District, Suzhou City, Jiangsu Province Patentee after:Suzhou Yuannao Intelligent Technology Co.,Ltd. Country or region after:China Address before:Building 9, No.1, guanpu Road, Guoxiang street, Wuzhong Economic Development Zone, Wuzhong District, Suzhou City, Jiangsu Province Patentee before:SUZHOU LANGCHAO INTELLIGENT TECHNOLOGY Co.,Ltd. Country or region before:China |